\underbrace 與中心環境中的註釋

\underbrace 與中心環境中的註釋

這是我的程式碼的一小段:

\begin{center}
$\small \displaystyle \underbrace{(- \frac{1}{2})^0}_{\text{1st term, j = 0}} +
\underbrace{(- \frac{1}{2})^1}_{\text{2nd term, j = 1}} + \underbrace{(- \frac{1}{2})^2}_
{\text{3rd term, j = 2}} + ~...+ \underbrace{(- \frac{1}{2})^k}_{\text{kth term, 2nd to \linebreak last term, j = k}} + \underbrace{(- \frac{1}{2})^{k+1}}_{\text{(k+1)th term,
 last in the sum}}$  
\end{center}

這是輸出

在此輸入影像描述

我希望將其寫在一行上,但將最後兩個術語下面的註釋分成兩部分。我該怎麼做?

答案1

這與 Sigur 的答案僅略有不同,但我認為值得進行一些小的調整。

\documentclass{article}
\usepackage{mathtools}
\begin{document}
\begingroup
\small
\[
 \displaystyle
 \underbrace{\left(-\frac{1}{2}\right)^0}_{\substack{\text{1st term,}\\ j = 0}}
 + \underbrace{\left(-\frac{1}{2}\right)^1}_{\substack{\text{2nd term,}\\ j = 1}}
 + \underbrace{\left(-\frac{1}{2}\right)^2}
   _{\substack{\text{3rd term,}\\ j = 2}}
 + \ \cdots\ 
 + \underbrace{\left(-\frac{1}{2}\right)^k}
   _{\substack{\text{\ \ $k$th term,\ \ }\\ \mathclap{\text{2nd to last term,}}\\ j = k}}
 + \underbrace{\left(-\frac{1}{2}\right)^{k+1\mkern-20mu}}
   _{\substack{\text{$(k{+}1)$th term,}\\ \text{ last in the sum }}}
\]
\endgroup

\end{document}

範例程式碼的輸出

以下是差異:

  • 為了縮小倒數第二個項(從而減少最後一個加號周圍的空間),使用\mathclap(需要 mathtools)「壓縮」子堆疊中最寬的行,並將空格添加到第一行進行調整,以便最後兩個術語不重疊。 (實際上,縮短這個短語可能是更好的方法,但這可能並不總是可行。)

  • 最後一項的上標末尾添加了負空格,使其懸掛在大括號上方,從而使大括號的大小更接近其他大括號。

  • \text最後一項的子堆疊第二行增加了空間(在 內),以進一步改善最後兩項之間的間距。

  • 在最後一項符號的第一行中,將大括號放在 周圍,{+} 以便其中的間距k+1在視覺上與上標中的間距相當。 (可能應該是$(k+1)st,但我們不要狡辯。)

egreg 在 Sigur 的答案中使用宏觀細化是一個好主意,這裡也適用。

答案2

正如@egreg所建議的,使用\substack{}您可以插入多行。此外,字體大小也會自動調整。

\ \請注意周圍有一些額外的空格\cdots(@Thruston 要求)。

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\[   
\underbrace{\left( -\frac{1}{2}\right)^0}_{\substack{
\text{1st term,}\\ j = 0}} + 
\underbrace{\left( -\frac{1}{2}\right)^1}_{\substack{\text{2nd term,}\\ j = 1}} + 
\underbrace{\left( -\frac{1}{2}\right)^2}_{\substack{\text{3rd term,}\\ j = 2}} 
+ \ \cdots \ + 
\underbrace{\left( -\frac{1}{2}\right)^k}_{\substack{\text{$k$th term,}\\ \text{2nd to last term,}\\ j = k} } + 
\underbrace{\left( -\frac{1}{2}\right)^{k+1}}_{\substack{\text{$(k+1)$th term,}\\ \text{last in the sum}} }
\]
\end{document}

在此輸入影像描述

使用更少的擊鍵並最大限度地減少錯誤機會的改進:

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\[
% Define a shortcut macro just for this display;
% use \left and \right instead of \Bigl and \Bigr
% if you feel these are too small
\newcommand{\myterm}[2]{%
  \underbrace{\Bigl(-\frac{1}{2}\Bigr)^{#1}}_{\substack{#2}}%
}
\myterm{0}{\text{1st term,} \\ j=0}+
\myterm{1}{\text{2nd term,} \\ j=1}+
\myterm{2}{\text{3rd term,} \\ j=2}+
\;\cdots\;+ % some space around the dots
\myterm{k}{\text{$k$th term,} \\ \text{2nd to last,} \\ j=k}+
\myterm{k+1}{\text{$(k+1)$th term,} \\ \text{last in the sum}}
\]
\end{document}

在此輸入影像描述

相關內容