我正在尝试使用该包创建自定义定理格式thmtools
。但是,我在 QED 符号的对齐方面遇到了问题。当我用普通文本结束定理时,它会将 QED 符号放在行末,而当我以方程式结束并使用时\qedhere
,它会将 QED 符号放在方程式的旁边。但是,我想要相反的结果:让 QED 位于带有方程式的行末,并紧挨着普通文本的句号。
您可以在下面看到我的 MWE:
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{ifthen}
\usepackage{calc}
\declaretheoremstyle[
spaceabove=10pt,
headpunct={},
headformat=\ifthenelse{ \equal{\NOTE}{} }%
{% yes
$\underset{%
\raisebox{2pt}[0pt][0pt]{%
\rule{\widthof{\text{\NAME\ \NUMBER}}+6ex}{.1ex}}%
}{%
\text{\NAME\ \NUMBER}\hfill%
}$%
}{% no
$\underset{%
\raisebox{5.5pt}[0pt][0pt]{%
\rule{\widthof{\text{\NAME\ \NUMBER\hspace{1ex}$|$\hspace{1ex}\NOTE}}+6ex}{.1ex}}%
}{%
\text{\NAME\ \NUMBER\hspace{1ex}$\bm{|}$\hspace{1ex}\NOTE}\hfill%
}$%
}\newline,
spacebelow=10pt,
qed=\qedsymbol
]{thmdefault}
\declaretheorem[style=thmdefault]{Theorem}
\begin{document}
Here is some text.
\begin{Theorem}[Important Theorem]
This is a theorem. Notice that this QED symbol is right next to my equation. I would like it at the end of that line. $$a^2 + b^2 = c^2\qedhere$$
\end{Theorem}
Here is some more text.
\begin{Theorem}[Another Theorem]
This is another theorem. Notice that the QED symbol is placed at the end of the line. I would like it right next to this period.
\end{Theorem}
And here is a little more text.
\end{document}
(我包含了较大的headformat
选项,因为如果没有它,QED 的行为就不会相同。)
这似乎是一个非常简单的问题并且有一个简单的解决方案(我才刚刚开始学习 LaTeX),但经过几天的搜索,我似乎找不到解决方案。
答案1
您需要使用\[
...\]
进行显示数学运算它会设置\qedhere
在您想要的位置。对于与文本相关的调整,我们重新定义\qed
为不包括\hfill
:
\documentclass{article}
\usepackage{amsmath,amsthm,bm,thmtools}
\usepackage{ifthen}
\usepackage{calc}
\declaretheoremstyle[
spaceabove=10pt,
headpunct={},
headformat=\ifthenelse{ \equal{\NOTE}{} }%
{% yes
$\underset{%
\raisebox{2pt}[0pt][0pt]{%
\rule{\widthof{\text{\NAME\ \NUMBER}}+6ex}{.1ex}}%
}{%
\text{\NAME\ \NUMBER}\hfill%
}$%
}{% no
$\underset{%
\raisebox{5.5pt}[0pt][0pt]{%
\rule{\widthof{\text{\NAME\ \NUMBER\hspace{1ex}$|$\hspace{1ex}\NOTE}}+6ex}{.1ex}}%
}{%
\text{\NAME\ \NUMBER\hspace{1ex}$\bm{|}$\hspace{1ex}\NOTE}\hfill%
}$%
}\newline,
spacebelow=10pt,
qed=\qedsymbol
]{thmdefault}
\declaretheorem[style=thmdefault]{Theorem}
% Update \qed to remove \hfill
\DeclareRobustCommand{\qed}{%
\ifmmode
\mathqed
\else
\leavevmode\unskip
\penalty 9999
\hbox{}\nobreak\quad\hbox{\qedsymbol}
\fi
}
\begin{document}
Here is some text.
\begin{Theorem}[Important Theorem]
This is a theorem. Notice that this QED symbol is right next to my equation.
I would like it at the end of that line.
\[
a^2 + b^2 = c^2\qedhere
\]
\end{Theorem}
Here is some more text.
\begin{Theorem}[Another Theorem]
This is another theorem. Notice that the QED symbol is placed at the end of the line.
I would like it right next to this period.
\end{Theorem}
And here is a little more text.
\end{document}