Forgot password?
 Create new account
View 484|Reply 7

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

[Copy link]

418

Threads

1628

Posts

110K

Credits

Credits
11891

Show all posts

abababa Posted at 2022-1-9 10:58:51 |Read mode
  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}
Copy the Code
如上代码,我为了写footnote时能紧跟在例的后面,用mdframed做了一个这样的“myexample”,这个应该属于内嵌页吧,然后为了让它们显示的编号不冲突,我给它设成了\theoremstyle{nonumberplain},这种例就都没有编号了。
以前没有需要引用这种例的时候,但现在有一个需要引用了,发现引用时就显示一个1,这个怎么做引用才好呢?

701

Threads

110K

Posts

910K

Credits

Credits
94172
QQ

Show all posts

kuing Posted at 2022-1-9 17:37:20
要引用还是得有编号啊。
至于编号冲突的问题,得看 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}
Copy the Code

418

Threads

1628

Posts

110K

Credits

Credits
11891

Show all posts

 Author| abababa Posted at 2022-1-9 19:54:20
回复 2# kuing

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

701

Threads

110K

Posts

910K

Credits

Credits
94172
QQ

Show all posts

kuing Posted at 2022-1-9 20:01:44
回复 3# abababa

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

418

Threads

1628

Posts

110K

Credits

Credits
11891

Show all posts

 Author| abababa Posted at 2022-1-9 20:37:46
回复 4# kuing

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

701

Threads

110K

Posts

910K

Credits

Credits
94172
QQ

Show all posts

kuing Posted at 2022-1-9 20:38:54
回复 5# abababa

应该还是需要的吧

418

Threads

1628

Posts

110K

Credits

Credits
11891

Show all posts

 Author| abababa Posted at 2022-1-9 20:40:30
回复 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}
Copy the Code

701

Threads

110K

Posts

910K

Credits

Credits
94172
QQ

Show all posts

kuing Posted at 2022-1-9 20:46:03
回复 7# abababa

哦,还真的行

手机版Mobile version|Leisure Math Forum

2025-4-20 22:02 GMT+8

Powered by Discuz!

× Quick Reply To Top Return to the list