我想问您是否有更好的方法来编写此代码\begin{matrix*}\xrightarrow[something]{something}\vspace{-2mm}\\\xrightarrow[something]{}\end{matrix*}
,以及是否有办法创建排列在一列中的n
箭头(\xrightarrow
s、\xleftarrow
s、 s 或任何可扩展的箭头)。\xleftrightarrow
抱歉,我忘了说我想选择如何对齐箭头的参数([r]
、[l]
、[c]
)。另外,我希望箭头的长度相同,我想知道是否有办法自定义箭头的长度和参数的对齐方式。
我声明我知道这个extarrows
包裹。
答案1
我不会说这更好,但肯定更加灵活。
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{matrix}
\newlength{\mathbase}% distance from center to baseline
\setlength{\mathbase}{\dimexpr 0.5\dp\strutbox-0.5\ht\strutbox}
\begin{document}
\begin{equation*} x=
\begin{matrix}
\xrightarrow[something]{something}\vspace{-2mm}\\
\xrightarrow[something]{}
\end{matrix}
\end{equation*}
\begin{equation*} x=
\begin{tikzpicture}[baseline=(base), font=\scriptsize, inner xsep=1pt]
\matrix (A) [matrix of math nodes] {something \\ something \\ something \\};
\coordinate[yshift=\mathbase] (base) at (A.center);
\path (A-1-1) -- (A-2-1) coordinate[midway] (A12);% between rows 1 and 2
\path (A-2-1) -- (A-3-1) coordinate[midway] (A23);% between rows 2 and 3
\draw[->] (A.west |- A12) -- (A.east |- A12);
\draw[->] (A.west |- A23) -- (A.east |- A23);
\end{tikzpicture}
\end{equation*}
\end{document}
这样可以吗?
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{matrix}
\newlength{\mathbase}% distance from center to baseline
\setlength{\mathbase}{\dimexpr 0.5\dp\strutbox-0.5\ht\strutbox}
\newcommand{\twoarrows}[3]{\begin{tikzpicture}[baseline=(base), font=\scriptsize, inner xsep=1pt]
\matrix (A) [matrix of math nodes] {{#1}\\{#2}\\{#3}\\};
\coordinate[yshift=\mathbase] (base) at (A.center);
\path (A-1-1) -- (A-2-1) coordinate[midway] (A12);% between rows 1 and 2
\path (A-2-1) -- (A-3-1) coordinate[midway] (A23);% between rows 2 and 3
\draw[->] (A.west |- A12) -- (A.east |- A12);
\draw[->] (A.west |- A23) -- (A.east |- A23);
\end{tikzpicture}}
\begin{document}
\begin{equation*}
x= \twoarrows{first}{second}{third}
\end{equation*}
\end{document}