去掉定理编号后面的点

文本排版 2020-02-04 17:42  浏览 :4998
经常看到有人询问要如何去掉定理编号后面的点。这里查到了两种方法,分享出来。注意这里只谈论 `amsthm` 的情况。 先明确概念。那个点叫 punctuation,在 `amsthm` 中用 `\thm@headpunct` 来标识它。 这里我们给出一个不做任何处理的例子。 ```tex \documentclass{article} \usepackage{amsthm} \newtheorem{thm}{Theorem}[section] \begin{document} \section{A section here} \begin{thm} A theorem here. \end{thm} \end{document} ``` 大家自行运行,可以看到 punctuation 存在。 接下来我们调整定理的 punctuation。由于默认的定理样式 `theoremstyle` 是 `plain`,因此我们需要改动 `\th@plain`。 ```tex \documentclass{article} \usepackage{amsthm} \newtheorem{thm}{Theorem}[section] %https://latex.org/forum/viewtopic.php?t=14755 \makeatletter \g@addto@macro\th@plain{\thm@headpunct{}} \makeatother \begin{document} \section{A section here} \begin{thm} A theorem here. \end{thm} \end{document} ``` 在上述代码中给出了参考链接,大家可以学习。 这样的做法需要用户自行了解定理样式,不太方便。因此我们可以调用 `xpatch` 来帮助我们解决这个问题。 ```tex \documentclass{article} \usepackage{amsthm} \newtheorem{thm}{Theorem}[section] %https://tex.stackexchange.com/questions/338209/remove-dot-after-theorem-with-amsthm-and-hyperref \usepackage{xpatch} \makeatletter \xpatchcmd{\@thm}{\thm@headpunct{.}}{\thm@headpunct{}}{}{} \makeatother \begin{document} \section{A section here} \begin{thm} A theorem here. \end{thm} \end{document} ``` 同样,我们也给出了相关链接。 希望本文能对用户提供一些帮助。
发布评论
登录后方可评论!点击登录
全部评论 (1)
誓死不做程序员
1楼 · 2022-05-05 10:30

感谢大佬,找了好久才找到,暴风感动!