LaTeX 的 newtheorem 命令中自动进行 QED
正如标题所示,我需要在自定义新定理末尾自动定义 QED 符号(最好是颜色框)。
任何建议将不胜感激。
As the title says I need to define a QED symbol automatically (preferable a colorbox) at the end of my custom newtheorem.
Any suggestions would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
建议:不要这样做。 QED 符号的放置以一种非直接的方式取决于您环境中的文本内容。例如,如果您的定理以显示数学结束,Andrea 的代码将会失败。有时您可能需要手动放置它,如果您总是这样做,您就不太可能忽视事情。
如果没有放置 QED 符号,最好有一个抱怨的环境。您可以通过定义一个 qedused 标志(例如
\newififqedused
)来做到这一点,当您进入环境时该标志将被取消设置(如 Andrea 所说,使用\newenvironment
定义一个包装器),设置在 QED 符号周围的包装中,并在退出环境时进行测试。如果退出时该标志仍未设置,请发出\PackageWarning
或\PackageError
。如果您确实想尝试获得一个尽力做正确事情的 qed 环境,无论环境中有什么,您都需要查看
\lastbox
的内容以尝试确定 QED 符号应该放在哪里。如果它是一个 hbox,那就没问题,只需按照 Andreas 的解决方案放置 QED 即可。如果它是一个 mbox,那么我认为制作一个包含此 mbox 后跟 QED 符号的 hbox 应该可行 - 我不确定,我通常不会搞乱数学的排版。如果它是一个 vbox,你需要查看 vbox 的结构内部以找到它应该去的地方,这听起来很难 - 我不知道如何在纯 Tex 中做到这一点。在 Luatex 中,我认为 Hans Hagen 的技巧LuaTEX 方式:\framed 可能适用于这。
Advice: don't do it. The placing of the QED symbol depends in a non-straightforward way on the contents of your text in your environment. For instance, Andrea's code will fail if your theorem ends with display math. You will probably need to place it by hand sometimes, and you are less likely to overlook things if you always do this.
Much better would be to have an environment that complains if the QED symbol has not been placed. You can do this by defining a qedused flag, say by
\newififqedused
, that is unset when you enter the environment (define a wrapper using\newenvironment
as Andrea said), set in a wrapper around the QED symbol, and tested when you exit the environment. If the flag is still unset on exit, issue a\PackageWarning
or\PackageError
.If you really want to try to get a qed environment that tries hard to do the right thing, regardless of what is in the environment, you'll need to look into the contents of
\lastbox
to try to determine where the QED symbol should go. If it is an hbox, you are fine, just place the QED as per Andreas' solution. If it is an mbox, then I think making an hbox containing this mbox followed by the QED symbol should work - I'm not sure, I don't usually mess about with the typesetting of maths.If it is a vbox, you need to look inside the structure of the vbox to find where it should go, which sounds hard - I can't think how to do that in pure Tex. In Luatex, I think that Hans Hagen's trick in The LuaTEX way: \framed might be adapted for this.
我不确定你的意思。如果您使用 amsthm 包,您可以使用命令 \qed 将 QED 放置在您想要的任何位置。
您可以通过更改命令 \qedsymbol 来自定义 \qed。 您可以这样做
因此,如果您希望 QED 符号与证明中出现的符号相同, 。如果不是,你可以简单地做
当然你可以用你想要的任何东西改变 \heartsuit 。
I'm not sure what you mean. If you use the package amsthm you have the command \qed to put a QED wherever you want.
You can customize the \qed by changing the command \qedsymbol. So you would do something like
This if you want the QED symbol to be the same that appears in proofs. If not you can do simply
Of course you can change \heartsuit with whatever you want.
另一种方法是使用带有 thmarks 选项的 ntheorem 包。即
\usepackage[thmarks]{ntheorem}
。然后,您可以调整设置以获得您想要的结果......
An alternative is to use the ntheorem package with the options thmarks. that is
\usepackage[thmarks]{ntheorem}
.You can then play with the settings to get what you want exactly...