有没有更好的方法在方程式之间放置箭头?
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node at (-4,0) {$ (\underbrace{A_0})^2 - \underbrace{\sigma_0^2}\, < K$};
\node at (-4,-1.5) {$= U_1 - L_2$};
\draw[thick, ->] (-5,-0.4) -- (-4.4,-1);
\draw[thick, ->] (-3.7,-0.4) -- (-3.5,-1);
\end{tikzpicture}
\end{document}
顺便说一句,方程式没有任何意义,只是为了演示。
答案1
另一种方法,受到tikzmark 包:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{tikz}
% see tikz documentation section III.17.13 "Referencing Nodes Outside the Current Picture"
\makeatletter
\newcommand{\tikzmarkMath}[2]{%
\tikz[%
remember picture,
baseline = (#1.base),
inner sep = 0pt,
outer sep = 0pt, % could be adapted instead of shorten
] \node (#1) {$\m@th\displaystyle #2$};%
}
\makeatother
\begin{document}
\begin{gather}
% note the \vphantom to align the underbraces
\big(\,\tikzmarkMath{A0}{\underbrace{A_0\vphantom{\sigma_0^2}}}\,\big)^2
- \tikzmarkMath{s0}{\underbrace{\sigma_0^2}}\rlap{\ensuremath{\, < K}} \\[2em]
= \tikzmarkMath{U1}{U_1}
- \tikzmarkMath{L2}{L_2}
\end{gather}
%WARNING: do not forget the [overlay, remember picture]
\begin{tikzpicture}[overlay, remember picture, shorten >=5pt, shorten <=0pt]
\draw[thick, ->] (A0.south) -- (U1);
\draw[thick, ->] (s0.south) -- (L2);
\end{tikzpicture}
\end{document}
答案2
一个解决方案tikz
就是使用数组。
\documentclass{article}
\usepackage[utf8]{inputenc}
\begin{document}
\[
\arraycolsep=2pt
\begin{array}{cccccc}
& \underbrace{(A_0)^2} & - & \underbrace{\sigma_0^2} & < & K\\
& \downarrow && \downarrow &&\\
= & U_1 & - & U_2 &&
\end{array}
\]
\end{document}
如果你喜欢\downarrow
更长的箭头,有信息在这里。
答案3
像这样?
不清楚您认为的“更好的方法”是什么。更好的代码?更好的结果?我都试过了(根据我的喜好,问题是基于意见的)
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}
\matrix (m) [matrix of math nodes,
row sep=11mm]
{
& \underbrace{(A_0)^2} & - & \underbrace{\sigma_0^2} & < K \\
= & U_1 & - & U_2 & \\
};
\draw[thick, ->] (m-1-2) -- (m-2-2);
\draw[thick, ->] (m-1-4) -- (m-2-4);
\end{tikzpicture}
\end{document}
答案4
阅读 OP 的评论,似乎 OP 想要能够对各个行进行编号或标记。在或array
中matrix
,行没有编号/标记,但在align
环境中,将箭头和后续术语置于中心位置\underbrace
很棘手。(请注意,这会导致第二行出现一些不自然的间距;据我所知,这是理想的。)
这是一种解决方案,它设置两个长度:\lena
和\lenb
,分别用于第一和第二个下支撑,然后使用\makebox
和规定的宽度将后续部分居中。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{calc} % needed for \widthof command
\newlength{\lena}
\newlength{\lenb}
\begin{document}
\setlength{\lena}{\widthof{$\underbrace{(A_0)^2}$}}
\setlength{\lenb}{\widthof{$\underbrace{\sigma_0^2}$}}
\begin{align}
&\mathrel{\phantom{=}}{\underbrace{(A_0)^2}}-\underbrace{\sigma_0^2}<K\label{thisone}\\
&\mathrel{\phantom{=}}\makebox[\lena]{$\downarrow$}\mathbin{\phantom{-}}\makebox[\lenb]{$\downarrow$}\nonumber\\
&=\makebox[\lena]{$U_1$}-\makebox[\lenb]{$U_2$}\label{thatone}
\end{align}
Lines \ref{thisone} and \ref{thatone} can be referenced.
\end{document}
正如另一个答案所提到的,有关更长的向下箭头的信息在这里。