请帮我对齐整个等式并删除多余的空格\underbrace
。我用了\mathclap
,\makebox[]
但它看起来仍然很丑。谢谢帮助!
\begin{equation} \label{eq1}
\begin{split}
d^{connection}_{j} & = \sqrt{\smash[b]{{{\bigg(x_0 \pm \sqrt {\smash[b]{r^2-\underbrace{\strut y_0^2}_
{%}
\textstyle
\begin{array}{c}
y_j^2
\end{array}}
-y_j^2+2\underbrace{\strut y_0}_
{%}
\textstyle
\begin{array}{c}
y_j
\end{array}}y_j}} - \underbrace{\strut x_j}_
{%}
\textstyle
\begin{array}{c}
x_j \pm d_j^{\text{while waiting 0}}
\end{array}}
\bigg)^2}}}}
\end{split}
\end{equation}
答案1
您可能想考虑以不同的方式来表达您的表达。
\documentclass{article}
\usepackage{mathtools}
\newcommand*\smashedunderbrace[2][]{\mathpalette\dosmashedunderbrace{{#2}{#1}}}
\newcommand*\dosmashedunderbrace[2]{\dosmashedunderbraceindeed{#1}#2}
\newcommand*\dosmashedunderbraceindeed[3]{%
\smash[b]{%
\ooalign{
$#1#2$\cr
\hidewidth$#1\underbrace{\phantom{#2}}_{#3}$\hidewidth\cr
}%
}%
}
\begin{document}
\begin{equation}
\label{eq1}
d^{\text{connection}}_{j} = \sqrt{
\biggl(
x_0 + \sqrt{r^2 - \smashedunderbrace[y_j^2]{y_0^2} - y_j^2 + 2 \smashedunderbrace[y_j]{y_0} y_j}
- \smashedunderbrace[\qquad x_j \pm d_j^{\text{while waiting 0}}]{x_j}
\;\biggr)^2
}
\end{equation}
\end{document}
答案2
我建议你放弃\sqrt
术语,改用(...)^{1/2}
符号。这样,包装器array
和指令都不再\smash[b]
需要,因此可以省略,从而大大简化代码。请使用^{}
术语来确保各种下标都以相同的深度排版。
\documentclass{article}
\usepackage{mathtools} % for '\mathclap' directive; loads 'amsmath' automatically
\begin{document}
\begin{equation} \label{eq1}
d^{\,\text{connection}}_{j} = \bigl\{\bigl[x_0 \pm
( r^2-\underbrace{y_0^2}_{y_j^2} {}-y_j^2
+2\underbrace{y_0^{}}_{y_j^{\vphantom{2}}} y_j^{} )^{1/2}
- \underbrace{x_j}_{\mathclap{x_j^{}\pm d_j^{\,\text{while waiting 0}}}}
\,\bigr]^2
\bigr\}^{1/2}
\end{equation}
\end{document}