对齐:自动将方程式中带有大对象的数字向上移动

对齐:自动将方程式中带有大对象的数字向上移动

如果这是重复的,我提前道歉,但我无法在现有帖子中找到我要找的内容。align如果当前行没有空格,则具有将方程编号向下移动的好功能,例如

\documentclass[fleqn]{article}
\usepackage{amsmath}
\usepackage{tikzducks}
\begin{document}
This is the standard output:
\begin{align}
 \vcenter{\hbox{\tikz[scale=2,remember picture]{%
 \duck[graduate=gray!20!black,tassel=red!70!black];
 \coordinate (B1) at (1,0.1);
 }}}~=~\int\!\mathrm{d}^4x\,
 \int\!\mathrm{d}^4y\,\int\!\mathrm{d}^4z\,
 \frac{1}{(x^2-m^2)\,(y^2-m^2)}
\end{align}
\tikz[overlay,remember picture]{\draw[gray](B1)--++(9.3cm,0);}
I want to move the equation number up, but not by hand:
\begin{align}
 \vcenter{\hbox{\tikz[scale=2,remember picture]{%
 \duck[graduate=gray!20!black,tassel=red!70!black];
 \coordinate (B2) at (1,0.1);
 }}}~=~\int\!\mathrm{d}^4x\,
 \int\!\mathrm{d}^4y\,\int\!\mathrm{d}^4z\,
 \frac{1}{(x^2-m^2)\,(y^2-m^2)}\notag\\[-0.6cm] % <-adjusted by hand
\end{align}
\tikz[overlay,remember picture]{\draw[gray](B2)--++(9.3cm,0);}
\end{document}

enter image description here

对于那些不喜欢鸭子的人来说,可以把它们看作是费曼图的占位符。(灰线只是为了引导你的视线。)正如你所见,方程编号不适合当前行,因此align将其移到下一行。但是,第一个方程浪费了一些垂直空间。我当然可以手动修复这个问题,如第二个方程所示,或者也可以为此编写一个复杂的宏。问题是是否有一种简单的方法可以将数字向上移动,就像在方程 (2) 中一样,而无需手动调整。

答案1

改变amsmath做法会更加困难,而且会破坏更多的东西,而不仅仅是这条线:P

您可以使用 ,而不必手动调整高度\strut。摘自 TeXbook:

Plain TeX 定义\strut为一个宽度为零的不可见框,它刚好延伸到基线的上方和下方,因此如果每行都包含一个支柱,则根本不需要行间粘连。

因此,这正是您想要增加方程式数字的量。您只需将 替换为\\[-0.6cm]\\[-\dimexpr2\ht\strutbox\relax]\strutbox放置 时放置的框\strut)。请注意,您需要返回 的两倍高度\strutbox来抵消\\

enter image description here

\documentclass[fleqn]{article}
\usepackage{amsmath}
\usepackage{tikzducks}
\begin{document}
\pagenumbering{gobble}
This is the standard output:
\begin{align}
 \vcenter{\hbox{\tikz[scale=2,remember picture]{%
 \duck[graduate=gray!20!black,tassel=red!70!black];
 \coordinate (B1) at (1,0.1);
 }}}~=~\int\!\mathrm{d}^4x\,
 \int\!\mathrm{d}^4y\,\int\!\mathrm{d}^4z\,
 \frac{1}{(x^2-m^2)\,(y^2-m^2)}
\end{align}
\tikz[overlay,remember picture]{\draw[gray](B1)--++(9.3cm,0);}
I want to move the equation number up, but not by hand:
\begin{align}
 \vcenter{\hbox{\tikz[scale=2,remember picture]{%
 \duck[graduate=gray!20!black,tassel=red!70!black];
 \coordinate (B2) at (1,0.1);
 }}}~=~\int\!\mathrm{d}^4x\,
 \int\!\mathrm{d}^4y\,\int\!\mathrm{d}^4z\,
 \frac{1}{(x^2-m^2)\,(y^2-m^2)}\notag\\[-\dimexpr2\ht\strutbox\relax] % <- not anymore!
\end{align}
\tikz[overlay,remember picture]{\draw[gray](B2)--++(9.3cm,0);}
\Large
The font size can even change!
\begin{align}
 \vcenter{\hbox{\tikz[scale=1.5,remember picture]{%
 \duck[graduate=gray!20!black,tassel=red!70!black];
 \coordinate (B3) at (1,0.1);
 }}}~=~\int\!\mathrm{d}^4x\,
 \int\!\mathrm{d}^4y\,\int\!\mathrm{d}^4z\,
 \frac{1}{(x^2-m^2)\,(y^2-m^2)}\notag\\[-\dimexpr2\ht\strutbox\relax] % <- not anymore!
\end{align}
\tikz[overlay,remember picture]{\draw[gray](B3)--++(9.3cm,0);}

\end{document}

答案2

\raisetag(要小心使用,因为它也会将下面的文本上移)。

\documentclass[fleqn]{article}
\usepackage{amsmath}
\usepackage{tikzducks}

\begin{document}
This is the standard output:
\begin{equation}
\begin{gathered}
  \qquad % just to make it bigger and move down the number
  \begin{tikzpicture}[scale=2]
    \duck[graduate=gray!20!black,tassel=red!70!black];
    \coordinate (B1) at (1,0.1);
  \end{tikzpicture}
  \qquad % just to make it bigger and move down the number
\end{gathered}
=\int\! d^4x
 \int\! d^4y
 \int\! d^4z\,
 \frac{1}{(x^2-m^2)\,(y^2-m^2)}
\end{equation}
Some text following
some text following
some text following
some text following
some text following
\begin{equation}
\begin{gathered}
  \qquad % just to make it bigger and move down the number
  \begin{tikzpicture}[scale=2]
    \duck[graduate=gray!20!black,tassel=red!70!black];
    \coordinate (B1) at (1,0.1);
  \end{tikzpicture}
  \qquad % just to make it bigger and move down the number
\end{gathered}
=\int\! d^4x
 \int\! d^4y
 \int\! d^4z\,
 \frac{1}{(x^2-m^2)\,(y^2-m^2)}
\raisetag{\baselineskip}
\end{equation}
Some text following
some text following
some text following
some text following
some text following

\end{document}

注意gathered不要笨拙\vcenter{\hbox{...}}

enter image description here

~=~,拜托,这是错的。而且,抱歉,我受不了直立的“d”。

相关内容