
以下程式碼提供了此結果:
我想要一個適合文字的小“{”,而不是上下框。
任何想法?
\documentclass[preview]{standalone}
\usepackage{mathtools}
\usepackage{tikz}
\setlength{\textwidth}{15cm}
\makeatletter
\define@key{janbertdims}{align}{\def\janbert@align{\hspace{#1}}}
\define@key{janbertdims}{arrow}{\def\janbert@arrow{#1}}
\define@key{janbertdims}{color}{\def\janbert@color{#1}}
\setkeys{janbertdims}{
align=0cm,
arrow=\bigg\downarrow,
color=orange,
}
\newcommand\underbox[3][]{%
\begingroup
\setkeys{janbertdims}{#1}% the current values
\underset{\mathclap{\substack{\janbert@arrow \\[0.1cm]
\tikz\node[draw=\janbert@color, align=center, rounded corners]{#2}; \janbert@align }}}{#3}
\endgroup
}
\newcommand\overbox[3][]{%
\begingroup
\setkeys{janbertdims}{#1}% the current values
\overset{\mathclap{\substack{\tikz\node[draw=\janbert@color, align=center, rounded corners]{#2};
\janbert@align \\[0.1cm] \janbert@arrow
}}}{#3}
\endgroup
}
\makeatother
\begin{document}
$$
a_{n+2}=b_n a_n \underbox[align=2cm]{ $a_n=b_{n-2}a_{n-2}$}{=}
b_n b_{n-2} a_{n-2}\underbox[align=0.6cm,arrow={\Bigg\downarrow}]{$a_{n-2}=b_{n-4}a_{n-4}$}{=}
\dots
\overbox[align=4.25cm]{this process concludes when \\[0.1cm] $n-2k$ is $0$ ou $1$}{=}
\begin{cases}
b_n b_{n-2}\dots b_{2} b_0 a_0
\overbox{$a_0=0$}{=}0 & \text{if $n=2k$} \\
b_n b_{n-2} \dots b_3b_1 a_1
\underbox{$a_1=1$ }{=} b_n b_{n-2} \dots b_3b_1 & \text{if $n=2k+1$}
\end{cases}
$$
\end{document}
答案1
我建議您將環境中第一行的第一部分封裝在包裝器cases
中\smash[t]{...}
,並將第二行的第一部分封裝在\smash[b]{...}
包裝器中。這是有效的,因為環境左側的氣泡cases
超過了環境內部氣泡的高度和深度cases
。
我還將 4 個實例中的 3 個替換\dots
為\dotsb
.
哦,不要$$
在 LaTeX 文件中使用它來啟動和終止顯示數學模式。有關此主題的更多信息,請參閱帖子為什麼\[ ... \]
優於$$ ... $$
?
\documentclass[preview,,border=2pt]{standalone}
\usepackage{mathtools}
\usepackage{tikz}
\setlength{\textwidth}{15cm}
\makeatletter
\define@key{janbertdims}{align}{\def\janbert@align{\hspace{#1}}}
\define@key{janbertdims}{arrow}{\def\janbert@arrow{#1}}
\define@key{janbertdims}{color}{\def\janbert@color{#1}}
\setkeys{janbertdims}{
align=0cm,
arrow=\bigg\downarrow,
color=orange,
}
\newcommand\underbox[3][]{%
\begingroup
\setkeys{janbertdims}{#1}% the current values
\underset{\mathclap{\substack{\janbert@arrow \\[0.1cm]
\tikz\node[draw=\janbert@color, align=center, rounded corners]{#2}; \janbert@align }}}{#3}
\endgroup
}
\newcommand\overbox[3][]{%
\begingroup
\setkeys{janbertdims}{#1}% the current values
\overset{\mathclap{\substack{\tikz\node[draw=\janbert@color, align=center, rounded corners]{#2};
\janbert@align \\[0.1cm] \janbert@arrow
}}}{#3}
\endgroup
}
\makeatother
\begin{document}
\[
a_{n+2}=b_n a_n \underbox[align=2cm]{ $a_n=b_{n-2}a_{n-2}$}{=}
b_n b_{n-2} a_{n-2}\underbox[align=0.6cm,arrow={\Bigg\downarrow}]{$a_{n-2}=b_{n-4}a_{n-4}$}{=}
\dots
\overbox[align=4.25cm]{this process concludes when \\[0.1cm]
$n-2k$ is $0$ ou $1$}{=}
\begin{cases}
\smash[t]{b_n b_{n-2}\dotsb b_{2} b_0 a_0 \overbox{$a_0=0$}{=}0}
& \text{if $n=2k$} \\
\smash[b]{b_n b_{n-2} \dotsb b_3b_1 a_1 \underbox{$a_1=1$ }{=}
b_n b_{n-2} \dotsb b_3b_1}
& \text{if $n=2k+1$}
\end{cases}
\]
\end{document}