我一直在使用 Ti钾Z 绘制此类方程
使用这个
\begin{equation}
\begin{tikzpicture}[
inner sep=0pt,
outer sep=0pt,
baseline=(hat.base),
]
\path[every node/.append style={anchor=base west}]
(0,0)
\foreach \name/\code in {
bra0/,
bra/Z,
sub/_1,
sub2/_2,
angle/%
} {
node (\name) {$\code$}
(\name.base east)
}
;
\path[
every node/.append style={
anchor=base,
font=\slshape\scriptsize,
},
]
(bra0.base) -- node[below=3\baselineskip] (geb_2) {12} (ket)
;
\begin{scope}[
>={Stealth[length=5pt]},
thick,
rounded corners=0pt,
shorten <=.3em,
shorten >=.3em,
]
\def\GebArrow#1#2#3{
\draw[<->]
(#2.north) ++(0, .3em) coordinate (tmp)
(#1) |- (tmp) -| (#3)
;%
}
\GebArrow{sub2}{geb_2}{sub}
\end{scope}
\end{tikzpicture}
\end{equation}
但我似乎找不到这个方程的解法
这看起来更容易,但我不知道如何制作不连接的简单箭头。
答案1
我不确定我是否理解了您的代码的作用。但是,使用该tikzmark
库重现您的手写公式确实非常简单。当此库包含时,它会更加简单\tikzmarknode
,并且当更新正式发布在 CTAN 上时,我很乐意更新我的代码。在此之前,您可以使用
\documentclass{article}
\usepackage{amsmath,amssymb,braket,tikz}
\usetikzlibrary{tikzmark,calc}
\begin{document}
\begin{equation}
\phi_{\tikzmark{1-1}1\tikzmark{1-2}}
~=~x_{\tikzmark{2-1}1\tikzmark{2-2}1\tikzmark{2-3}}\,
\psi_{\tikzmark{3-1}1\tikzmark{3-2}}+
x_{\tikzmark{4-1}1\tikzmark{4-2}2\tikzmark{4-3}}\,
\psi_{\tikzmark{5-1}2\tikzmark{5-2}}\;.
\end{equation}
\begin{tikzpicture}[overlay,remember picture]
\foreach \X in {1,2,4}
{ \draw[latex-,shorten <=1pt] ($(pic cs:\X-1)!0.5!(pic cs:\X-2)$)
-- ++ (0,-1) node[below]{$\scriptstyle1$};}
\foreach \X [evaluate=\X as \Y using {int(\X+1)},count=\Z]in {2,4}
{\draw[latex-latex,shorten <=1pt,shorten >=1pt]
($(pic cs:\X-2)!0.5!(pic cs:\X-3)$)
-- ++ (0,-.5) -| ($(pic cs:\Y-1)!0.5!(pic cs:\Y-2)$)
node[below,pos=0.25]{$\scriptstyle\Z\Z$};}
\end{tikzpicture}
\end{document}
以下是即将推出的版本tikzmark
。(我很抱歉没有阅读手册,这个新版本让事情真的非常简单。哇!)
\documentclass{article}
\usepackage{amsmath,tikz}
\usetikzlibrary{tikzmark}
\begin{document}
\begin{equation}
\phi_{\tikzmarknode{11}{1}}
~=~x_{\tikzmarknode{21}{1}\tikzmarknode{22}{1}}\,
\psi_{\tikzmarknode{31}{1}}+
x_{\tikzmarknode{41}{1}\tikzmarknode{42}{2}}\,
\psi_{\tikzmarknode{51}{2}}\;.
\begin{tikzpicture}[remember picture,overlay]
\foreach \X in {1,2,4}
{ \draw[latex-,shorten <=1pt] (\X1)
-- ++ (0,-1) node[below] (l\X) {$\scriptstyle1$};}
\foreach \X [evaluate=\X as \Y using {int(\X+1)},count=\Z]in {2,4}
{\draw[latex-latex,shorten <=1pt,shorten >=1pt]
(\X2) -- ++ (0,-.5) -| (\Y1)
node[below,pos=0.25]{$\scriptstyle\Z\Z$};}
\end{tikzpicture}
\end{equation}
\end{document}
答案2
另一个简短的代码是pstricks
:
\documentclass[11pt]{article}
\usepackage{amsmath}
\usepackage{pst-node, auto-pst-pdf}
\begin{document}
\[ \begin{postscript}
\everypsbox{\scriptstyle}
%% Some nodes
\phi_{\rnode[b]{F}{1}} = x_{\rnode[b]{a}{1}\rnode[b]{b}{1}}\varphi_{\rnode[b]{c}{1}} + x_{\rnode[b]{d}{1} \rnode[b]{e}{2}}\varphi_{\rnode[b]{g}{2}}
%% Remaining nodes and connections
\psset{angle=-90, linewidth=0.6pt, linejoin=1, arm=4.5mm, arrows=<->, arrowinset=0.1, nodesep=2pt, labelsep=1.5pt}
\foreach \s/\t in {F/G, a/A, d/D}{\uput{1cm}[d](\s){\rnode[t]{\t}{1}}\ncline[arrows=->]{\t}{\s}}
\ncbar{b}{c}\nbput{11}
\ncbar{e}{g}\nbput{22}
\end{postscript} \]%
\end{document}