Tikz 环境中的方程

Tikz 环境中的方程

我一直试图在 tikz 中写下这个等式,但没有成功。在此处输入图片描述

有任何想法吗?

答案1

您可以复制我之前的答案并稍加修改即可获得

\documentclass{article}
\usepackage{amsmath,amssymb,braket,tikz}
\usetikzlibrary{tikzmark,calc}
\begin{document}
\begin{equation}
 \Braket{a_{\tikzmark{1-1}i\tikzmark{1-2}}|\Phi}
 ~=~
 \sum\limits_{j=1}^n\Braket{
 a_{\tikzmark{2-1}i\tikzmark{2-2}}\,\hat{x}\,
 a_{\tikzmark{3-1}j\tikzmark{3-2}}}\Braket{
 a_{\tikzmark{4-1}j\tikzmark{4-2}}|
 \Psi}\;.
\end{equation}
\begin{tikzpicture}[overlay,remember picture]
\foreach \X in {1,2}
{ \draw[latex-,shorten <=1pt] ($(pic cs:\X-1)!0.5!(pic cs:\X-2)$) 
 -- ++ (0,-1) node[below]{$\scriptstyle i$};}
\draw[latex-latex,shorten <=1pt,shorten >=1pt] 
 ($(pic cs:3-1)!0.5!(pic cs:3-2)$) 
 -- ++ (0,-.5) -| ($(pic cs:4-1)!0.5!(pic cs:4-2)$)
 node[pos=0.25,below]{$\scriptstyle jj$}; 
\end{tikzpicture}
\end{document}

在此处输入图片描述

根本就不需要任何新东西。

附录:如果您在多个方程式中使用这些技巧,那么您需要像 nox 指出的那样,使 tikzmarks 的名称独一无二。例如,我可以通过在tikzmarks前面添加A和来将其与我之前的答案结合起来。B

\documentclass{article}
\usepackage{amsmath,amssymb,braket,tikz}
\usetikzlibrary{tikzmark,calc}
\begin{document}
\begin{equation}
 \phi_{\tikzmark{A1-1}1\tikzmark{A1-2}}
 ~=~x_{\tikzmark{A2-1}1\tikzmark{A2-2}1\tikzmark{A2-3}}\,
 \psi_{\tikzmark{A3-1}1\tikzmark{A3-2}}+
 x_{\tikzmark{A4-1}1\tikzmark{A4-2}2\tikzmark{A4-3}}\,
 \psi_{\tikzmark{A5-1}2\tikzmark{A5-2}}\;.
\end{equation}
\begin{tikzpicture}[overlay,remember picture]
\foreach \X in {1,2,4}
{ \draw[latex-,shorten <=1pt] ($(pic cs:A\X-1)!0.5!(pic cs:A\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:A\X-2)!0.5!(pic cs:A\X-3)$) 
 -- ++ (0,-.5) -| ($(pic cs:A\Y-1)!0.5!(pic cs:A\Y-2)$) 
 node[below,pos=0.25]{$\scriptstyle\Z\Z$};}
\end{tikzpicture}
\bigskip\bigskip
\begin{equation}
 \Braket{a_{\tikzmark{B1-1}i\tikzmark{B1-2}}|\Phi}
 ~=~
 \sum\limits_{j=1}^n\Braket{
 a_{\tikzmark{B2-1}i\tikzmark{B2-2}}\,\hat{x}\,
 a_{\tikzmark{B3-1}j\tikzmark{B3-2}}}\Braket{
 a_{\tikzmark{B4-1}j\tikzmark{B4-2}}|
 \Psi}\;.
\end{equation}
\begin{tikzpicture}[overlay,remember picture]
\foreach \X in {1,2}
{ \draw[latex-,shorten <=1pt] ($(pic cs:B\X-1)!0.5!(pic cs:B\X-2)$) 
 -- ++ (0,-1) node[below]{$\scriptstyle i$};}
\draw[latex-latex,shorten <=1pt,shorten >=1pt] 
 ($(pic cs:B3-1)!0.5!(pic cs:B3-2)$) 
 -- ++ (0,-.5) -| ($(pic cs:B4-1)!0.5!(pic cs:B4-2)$)
 node[pos=0.25,below]{$\scriptstyle jj$}; 
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容