我使用 mdframed 来框选方程式以包含方程式编号,因为我非常喜欢它的外观。但是我注意到这会导致框选的方程式编号与未框选的方程式编号之间出现错位。有没有简单的解决方法,或者建议使用不同于 mdframed 的方法?
下面是我如何使用它的一个例子。
\documentclass{article}
\usepackage{amsmath}
\usepackage{mdframed}
\begin{document}
Here is an important equation I would like to highlight:
\begin{mdframed}
\begin{equation}
e^{i\pi}=-1
\end{equation}
\end{mdframed}
Here is an equation not important enough to deserve a highlight:
\begin{equation}
y=mx+c
\end{equation}
\end{document}
任何建议都值得感激。
答案1
最简单的方法是让框架延伸到右边距:
\documentclass{article}
\usepackage{amsmath}
\usepackage{mdframed}
\newlength{\mywidth}
\setlength{\mywidth}{\dimexpr\linewidth+\mdflength{innerrightmargin}+\mdflength{linewidth}}
\begin{document}
Here is an important equation I would like to highlight:
\begin{mdframed}[userdefinedwidth=\mywidth]
\begin{equation}
e^{i\pi}=-1
\end{equation}
\end{mdframed}
Here is an equation not important enough to deserve a highlight:
\begin{equation}
y=mx+c
\end{equation}
\end{document}
要采用另一种方式,您也许可以将所有显示都包含在内mdframed
,但只隐藏以下行:
\documentclass{article}
\usepackage{amsmath}
\usepackage{mdframed}
\newbool{equationframe}
\surroundwithmdframed[hidealllines=\ifbool{equationframe}{false}{true}]{equation}
\boolfalse{equationframe}
\begin{document}
Here is an important equation I would like to highlight but first
enough text to show the width of the line:
{\booltrue{equationframe}%
\begin{equation}
e^{i\pi}=-1
\end{equation}}
Here is an equation not important enough to deserve a highlight but
first enough text to show the width of the line:
\begin{equation}
y=mx+c
\end{equation}
\end{document}
在这里我添加了一个专用于方程框架的额外标志,以避免hidealllines
全局设置并因此影响其他 mdframed 环境。