找回密码
 快速注册
搜索
查看: 398|回复: 7

用mdframed做的例,引用时怎么弄好?

[复制链接]

413

主题

1558

回帖

1万

积分

积分
11498

显示全部楼层

abababa 发表于 2022-1-9 10:58 |阅读模式
  1. \documentclass[a4paper]{article}
  2. \usepackage{amsmath,bm,yhmath,amssymb,etoolbox,esvect,stmaryrd,cite,enumitem,extarrows,mathtools,ifthen}
  3. \usepackage[framemethod=tikz,ntheorem]{mdframed}
  4. \usepackage{xltxtra,fontspec,xunicode}
  5. \usepackage[slantfont,boldfont]{xeCJK}
  6. \usepackage[amsmath, thmmarks]{ntheorem}
  7. {
  8.         \theoremstyle{nonumberplain}
  9.         \theoremheaderfont{\indent\bfseries}
  10.         \theorembodyfont{\normalfont}
  11.         \theoremsymbol{\ensuremath{\Box}}
  12.         \newtheorem{proof}{证明}
  13. }
  14. \newtheorem{example}{例}
  15. \newcommand\exampleautorefname{例}
  16. \theoremstyle{nonumberplain}
  17. \mdfdefinestyle{exampleStyle}{linewidth=0pt,innerleftmargin=0,innerrightmargin=0,innertopmargin=-\topskip}
  18. \newmdtheoremenv[style=exampleStyle]{myexample}{例}
  19. \usepackage[pdfencoding=auto,psdextra,colorlinks,linkcolor=red,anchorcolor=blue,citecolor=blue]{hyperref}
  20. \begin{document}
  21. \begin{example}
  22. \end{example}
  23. \begin{myexample}\label{myexam}
  24. my example
  25. \end{myexample}
  26. \autoref{myexam}
  27. \end{document}
复制代码
如上代码,我为了写footnote时能紧跟在例的后面,用mdframed做了一个这样的“myexample”,这个应该属于内嵌页吧,然后为了让它们显示的编号不冲突,我给它设成了\theoremstyle{nonumberplain},这种例就都没有编号了。
以前没有需要引用这种例的时候,但现在有一个需要引用了,发现引用时就显示一个1,这个怎么做引用才好呢?

730

主题

1万

回帖

9万

积分

积分
93593
QQ

显示全部楼层

kuing 发表于 2022-1-9 17:37
要引用还是得有编号啊。
至于编号冲突的问题,得看 example 和你的 myexample 是什么关系。
如果是下属关系,那可以 example 是“例1”,接下来的 myexample 就是“例1.1”、“例1.2”等就行了。
  1. \documentclass[a4paper]{article}
  2. \usepackage{amsmath,bm,yhmath,amssymb,etoolbox,esvect,stmaryrd,cite,enumitem,extarrows,mathtools,ifthen}
  3. \usepackage[framemethod=tikz,ntheorem]{mdframed}
  4. \usepackage{xltxtra,fontspec,xunicode}
  5. \usepackage[slantfont,boldfont]{xeCJK}
  6. \usepackage[amsmath, thmmarks]{ntheorem}
  7.         \theoremheaderfont{\indent\bfseries}
  8.         \theorembodyfont{\normalfont}
  9.         \theoremsymbol{\ensuremath{\Box}}
  10.         \newtheorem{proof}{证明}
  11. \newtheorem{example}{例}
  12. \newcommand\exampleautorefname{例}
  13. \mdfdefinestyle{exampleStyle}{linewidth=0pt,innerleftmargin=0,innerrightmargin=0,innertopmargin=-\topskip}
  14. \newmdtheoremenv[style=exampleStyle]{myexample}{例}[example]
  15. \newcommand\myexampleautorefname{例}
  16. \usepackage[pdfencoding=auto,psdextra,colorlinks,linkcolor=red,anchorcolor=blue,citecolor=blue]{hyperref}
  17. \begin{document}
  18. \begin{example}
  19. 大佬
  20. \end{example}
  21. \begin{myexample}\label{myexama}
  22. 小弟a
  23. \end{myexample}
  24. \begin{myexample}\label{myexamb}
  25. 小弟b
  26. \end{myexample}
  27. \autoref{myexama}、\autoref{myexamb}
  28. \end{document}
复制代码

413

主题

1558

回帖

1万

积分

积分
11498

显示全部楼层

 楼主| abababa 发表于 2022-1-9 19:54
回复 2# kuing

平行关系,都在section下面,所以有编号的话,会弄出两个例1.1来。

730

主题

1万

回帖

9万

积分

积分
93593
QQ

显示全部楼层

kuing 发表于 2022-1-9 20:01
回复 3# abababa

那就改成 \newmdtheoremenv[style=exampleStyle]{myexample}[example]{例}

413

主题

1558

回帖

1万

积分

积分
11498

显示全部楼层

 楼主| abababa 发表于 2022-1-9 20:37
回复 4# kuing

原来如此,放前面和放后面还不一样。而且这样的话,好像还不需要\newcommand\myexampleautorefname{例}这一句了,引用时也能带上前面的汉字。

730

主题

1万

回帖

9万

积分

积分
93593
QQ

显示全部楼层

kuing 发表于 2022-1-9 20:38
回复 5# abababa

应该还是需要的吧

413

主题

1558

回帖

1万

积分

积分
11498

显示全部楼层

 楼主| abababa 发表于 2022-1-9 20:40
回复 6# kuing
我刚才测试了一下,把这句注释了,显示的引用确实是“例1.2”
  1. \documentclass[a4paper]{article}
  2. \usepackage{amsmath,bm,yhmath,amssymb,etoolbox,esvect,stmaryrd,cite,enumitem,extarrows,mathtools,ifthen}
  3. \usepackage[framemethod=tikz,ntheorem]{mdframed}
  4. \usepackage{xltxtra,fontspec,xunicode}
  5. \usepackage[slantfont,boldfont]{xeCJK}
  6. \usepackage[amsmath, thmmarks]{ntheorem}
  7. {
  8.         \theoremstyle{nonumberplain}
  9.         \theoremheaderfont{\indent\bfseries}
  10.         \theorembodyfont{\normalfont}
  11.         \theoremsymbol{\ensuremath{\Box}}
  12.         \newtheorem{proof}{证明}
  13. }
  14. \newtheorem{example}{例}[section]
  15. \newcommand\exampleautorefname{例}
  16. %\theoremstyle{nonumberplain}
  17. \mdfdefinestyle{exampleStyle}{linewidth=0pt,innerleftmargin=0,innerrightmargin=0,innertopmargin=-\topskip}
  18. %\newmdtheoremenv[style=exampleStyle]{myexample}{例}[section]
  19. \newmdtheoremenv[style=exampleStyle]{myexample}[example]{例}
  20. %\newcommand\myexampleautorefname{例}
  21. \usepackage[pdfencoding=auto,psdextra,colorlinks,linkcolor=red,anchorcolor=blue,citecolor=blue]{hyperref}
  22. \begin{document}
  23. \section{测试节}
  24. \begin{example}
  25. \end{example}
  26. \begin{myexample}\label{myexam}
  27. my example
  28. \end{myexample}
  29. \autoref{myexam}
  30. \end{document}
复制代码

730

主题

1万

回帖

9万

积分

积分
93593
QQ

显示全部楼层

kuing 发表于 2022-1-9 20:46
回复 7# abababa

哦,还真的行

手机版|悠闲数学娱乐论坛(第3版)

GMT+8, 2025-3-4 12:00

Powered by Discuz!

× 快速回复 返回顶部 返回列表