答案1
钛钾Z 也可以使用表格内的节点来实现这一点,并且节点使用单独的tikzpicture
环境进行连接。
\documentclass{article}
\usepackage{tikz,bm}
\newcommand\C[1]{\tikz[remember picture]{\node(#1)[inner sep=0pt]{\sffamily#1};}}
\begin{document}
\begin{tabular}{@{}*7{c@{}}}
\C{A}&\C{B}&\C{C}& $\bm\sim$ &\C{X}&\C{Y}&\C{Z}
\end{tabular}
\begin{tikzpicture}[overlay,remember picture,>=latex,shorten >=1pt,shorten <=1pt,very thin]
\draw[->] (A) --++(0,-10pt) -| (X);
\draw[->] (B) --++(0,-12pt) -| (Y);
\draw[->] (C) --++(0,-14pt) -| (Z);
\end{tikzpicture}
\end{document}
答案2
下面是一个代码pst-node
:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{pst-node}
\usepackage{auto-pst-pdf} % load this package to compile with pdflatex -shell-escape (MacTeX, TX Live) or pdflatex --enable-write18 (MiKTeX)
\begin{document}
\Large\sffamily \bfseries
\begin{psmatrix}[colsep = 1pt, mnode = r, angle = -90, nodesep = 3pt]
A & B & C & $\boldsymbol{ ∼ }$& X & Y & Z
\psset{arrows = ->, arrowinset = 0.12, linewidth = 0.6pt, linejoin = 1}
\ncbar[arm = 8pt]{1,1}{1,5}
\ncbar[arm = 13pt]{1,2}{1,6}
\ncbar[arm = 18pt]{1,3}{1,7}
\end{psmatrix}
\end{document}
答案3
运行xelatex
\documentclass{article}
\usepackage{fontspec}
\usepackage{pst-node}
\newcommand\C[1]{\rnode{#1}{\textsf{#1}}}
\begin{document}
\C{A}\C{B}\C{C}\textasciitilde\C{X}\C{Y}\C{Z}
\psset{arrows=->,linewidth=0.4pt,angleA=-90,nodesep=2pt}
\ncbar[arm=5pt]{A}{X}
\ncbar[arm=8pt]{B}{Y}
\ncbar[arm=11pt]{C}{Z}
\end{document}
答案4
这个答案基本上是复制自Tjorbørn T. 的回答以及代码中指定的一些其他来源。一旦 Tjorbørn 上传了他的答案,我很乐意删除此帖子。Tjorbørn 版本的比命令\tikznode
更好,因为它保留了环境数学样式,例如索引保留在中。这是代码\rnode
pstricks
scriptstyle
\documentclass{article}
\usepackage{tikz}
\usepackage{refcount}
\usetikzlibrary{calc}
% from https://tex.stackexchange.com/questions/122415/mathchoice-and-tikzs-remember-picture
\makeatletter
\newcounter{tikznode}
\renewcommand*{\thetikznode}{tikznode@\the\value{tikznode}}
\newcommand*{\tikznodestyle}{%
\refused{\thetikznode}%
\ifcase\getrefbykeydefault{\thetikznode}{}{0} %
\displaystyle
\or\textstyle
\or\scriptstyle
\or\scriptscriptstyle
\fi
}
% from https://tex.stackexchange.com/questions/402462/tikz-equivalent-of-pstricks-command-ncbar-in-text
\newcommand{\tikznode}[2]{%
\ifmmode%
\stepcounter{tikznode}%
\mathchoice
{\def\@currentlabel{0}\label{\thetikznode}}%
{\def\@currentlabel{1}\label{\thetikznode}}%
{\def\@currentlabel{2}\label{\thetikznode}}%
{\def\@currentlabel{3}\label{\thetikznode}}%
\tikz[remember picture,baseline=(#1.base),inner sep=0pt] \node (#1) {$\tikznodestyle #2$};
\else
\tikz[remember picture,baseline=(#1.base),inner sep=0pt] \node (#1) {#2};%
\fi}
\makeatother
% from https://tex.stackexchange.com/questions/402429/how-to-connect-two-parts-using-arrows-or-lines-in-latex
\newcommand{\TikzNCbar}[4][10pt]{%
\tikz[overlay,remember picture]{\draw[#2] (#3) --++(0,-#1) -| (#4);}}
\begin{document}
blabla
$\displaystyle\tikznode{A}{A}\textstyle\tikznode{B}{B}_{\tikznode{C}{C}_{\tikznode{D}{D}}}$
blabla
\tikznode{X}{X}\tikznode{Y}{Y}\tikznode{Z}{Z}\tikznode{W}{W}
blabla
\TikzNCbar{-}{A}{X}
\TikzNCbar[12pt]{->}{B}{Y}
\TikzNCbar[14pt]{<-}{C}{Z}
\TikzNCbar[-14pt]{<->,red}{D}{W}
\end{document}
它产生的结果是:
显然,这也可以用于 Wick 收缩等等。
附录:随着tikzmark 库的更新版本这可以变得更简单。这会自动检查数学环境,这使我的原始答案看起来有点冗长,并免去了您输入等操作\scriptstyle
,而使用其他一些答案时您可能需要这样做。(您也不需要使用 来运行它xelatex
。)
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\newcommand{\TikzNCbar}[4][10pt]{%
\tikz[overlay,remember picture]{\draw[#2] (#3) --++(0,-#1) -| (#4);}}
\begin{document}
blabla
$\displaystyle\tikzmarknode{A}{A}\textstyle\tikzmarknode{B}{B}_{\tikzmarknode{C}{C}_{\tikzmarknode{D}{D}}}$
blabla
\tikzmarknode{X}{X}\tikzmarknode{Y}{Y}\tikzmarknode{Z}{Z}\tikzmarknode{W}{W}
blabla
\TikzNCbar{-}{A}{X}
\TikzNCbar[12pt]{-latex}{B}{Y}
\TikzNCbar[14pt]{latex-}{C}{Z}
\TikzNCbar[-14pt]{latex-latex,red}{D}{W}
\end{document}