我可以在 LaTeX 中使用它嗎?

我可以在 LaTeX 中使用它嗎?

我剛剛用 LaTeX 編譯的文本製作了一個圖形,並在後面添加了箭頭:

在此輸入影像描述

是否可以像上面那樣用對角箭頭連接一些文本,全部用 LaTeX 程式碼編寫?

答案1

有了tikzmark它就相當簡單了。

\documentclass[fleqn]{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\DeclareMathOperator{\PR}{PR}
\DeclareMathOperator{\IPR}{IPR}
\begin{document}
\begin{align*}
 \PR_x&=\sum_i\tikzmarknode{TL}{\frac{1}{|\psi_i|^2}}\;,&
 \tikzmarknode{TR}{\IPR_x}&=\sum_i|\psi_i|^2\;,\\[1cm]
 \PR_k&=\sum_i\tikzmarknode{BL}{\frac{1}{|\widetilde{\psi}_i|^2}}\;,&
 \tikzmarknode{BR}{\IPR_k}&=\sum_i|\widetilde{\psi}_i|^2\;.
 \begin{tikzpicture}[overlay,remember picture]
  \draw[thick,latex-latex,shorten >=3pt,shorten <=3pt] 
    (TL.south east) -- (BR.west |-BL.north);
  \draw[thick,latex-latex,shorten >=3pt,shorten <=3pt] 
    (TR.west|-TL.south) -- (BL.north east);
 \end{tikzpicture}
\end{align*}
\end{document}

在此輸入影像描述

答案2

這是一份工作tikz-cd

\documentclass{article}
\usepackage{tikz-cd}
\usetikzlibrary{arrows.meta}
\tikzcdset{arrow style=tikz, diagrams={>=Latex}}
\begin{document}
\[
\begin{tikzcd}[every node/.style={inner sep=0pt}]
    \mathrm{PR}_x=\sum_i\frac{1}{|\psi_i|^4}\arrow[dr, <->, start anchor=south east, end anchor=north west] 
        & \mathrm{IPR}_x=\sum_i|\psi_i|^4\arrow[dl, <->, start anchor=south west, end anchor=north east]\\[1ex]
    \mathrm{PR}_k=\sum_j\frac{1}{|\tilde\psi_j|^4}
        & \mathrm{PR}_k=\sum_j|\tilde\psi_j|^4\\
\end{tikzcd}
\]
\end{document}

在此輸入影像描述

答案3

無座標 Ti 萬歲kZ!

\documentclass[tikz]{standalone}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[every node/.style={inner sep=0pt}]
\coordinate (o);
\node[above left=.5cm and .5cm of o] (a) {%
    $\mathrm{PR}_x=\sum_i\frac{1}{|\psi_i|^4}$
};
\node[above right=.5cm and .5cm of o] (b) {%
    $\mathrm{IPR}_x=\sum_i|\psi_i|^4$
};
\node[below left=.5cm and .5cm of o] (c) {%
    $\mathrm{PR}_k=\sum_j\frac{1}{|\tilde\psi_j|^4}$
};
\node[below right=.5cm and .5cm of o] (d) {%
    $\mathrm{IPR}_k=\sum_j|\tilde\psi_j|^4$ % Edited typo, thanks to marmot
};
\draw[latex-latex] (a.south east)--(d.north west); 
\draw[latex-latex] (b.south west)--(c.north east);
\end{tikzpicture}
\end{document}

在此輸入影像描述

相關內容