答案1
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\begin{document}
\[
\tikzmarknode{N1}{1}\cdot
\tikzmarknode{N2}{\Delta}=\Sigma
\tikzmarknode{N3}{\vphantom{L}u}\cdot
\tikzmarknode{N4}{dL}
\]
\begin{tikzpicture}[overlay,remember picture,shorten <=2pt]
\draw (N1) |-++ (3,.5) node[right] {virtual loadings};
\draw (N3) --++ (0,.5);
\draw (N2) |-++ (3,-.5) node[right] {real displacements};
\draw (N4) --++ (0,-.5);
\end{tikzpicture}
\end{document}
请注意,\vphantom{L}
此处的 intonode
N3
只是为了避免方程式中的高度不一致,这会导致之后必须手动设置绘制线条。有了它,您就不必在零件中考虑它了tikzpicture
。
编辑
更合理的解决方案是声明图例的节点并绘制到节点的第二条路径。它避免了任何\vphantom
进入方程式的情况。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\begin{document}
\[
\tikzmarknode{N1}{1}\cdot
\tikzmarknode{N2}{\Delta}=\Sigma
\tikzmarknode{N3}{u}\cdot
\tikzmarknode{N4}{dL}
\]
\begin{tikzpicture}[overlay,remember picture,shorten <=2pt]
\draw (N1) |-++ (3,.5) node[right] (V) {virtual loadings};
\draw (N3) |- (V);
\draw (N2) |-++ (3,-.5) node[right] (R) {real displacements};
\draw (N4) |- (R);
\end{tikzpicture}
\end{document}