我目前找不到 stackexchange 答案,但我之前复制了一些代码,这些代码允许我使用箭头分支将一个方程式转换为两个方程式,如下所示:
可以使用以下代码重现:
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usepackage{tikzsymbols}
\usetikzlibrary{positioning,calc}
\begin{document}
\begin{subequations}
\label{eq1}
\noindent
\begin{tikzpicture}[node distance=-.4cm and 1.5cm]
\node (A)
{$ \overset{t_{B}}{\text{A}} $};
\node[above right=of A] (B)
{$ \overset{t_{B}}{\text{B}} $
};
\node[below right=of A] (C)
{$ \overset{t_{C}}{\text{C}}$};
\draw[-stealth, line width=1mm] (A.0) -- ( $ (A.0)!0.15!(B.west|-A.0) $ ) |- (B.west) node[auto,pos=0.75] {\scalebox{1}{$h$}};
\draw[-stealth, line width=1mm] (A.0) -- ( $ (A.0)!0.15!(C.west|-A.0) $ ) |- (C.west) node[auto,pos=0.75] {\scalebox{1}{$g$}} ;
\end{tikzpicture}
\end{subequations}
\end{document}
但正如您从图片中看到的那样,方程的重叠似乎使方程线相对于箭头中心向下移动。我希望箭头指向方程的中间,但目前它似乎偏移了。(在这个极简主义的例子中,它看起来并不那么糟糕,但如果这些分支是较长的方程,很明显这非常偏移并且看起来非常偏离。)
因为这段代码实际上是一些复制粘贴的代码的黑客攻击,所以我不太明白它做得如何,无法根据我的用例(将节点稍微向下移动)对其进行修改。
有什么想法可以做什么吗?
答案1
偏移的原因在于您\overset
在方程中使用了。如果没有,\overset
箭头将指向方程的中心。有一个解决方案:
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usepackage{tikzsymbols}
\usetikzlibrary{positioning,calc}
\begin{document}
\begin{subequations}
\label{eq1}
\noindent
\begin{tikzpicture}[node distance=-.4cm and 1.5cm]
\node (A)
{$ \overset{t_{B}}{\text{A}}-M\cdot C^2 $};
\node[above right=of A] (B)
{$ \overset{t_{B}}{\text{B}}-M\cdot C^2 $
};
\node[below right=of A] (C)
{$ \overset{t_{C}}{\text{C}}-M\cdot C^2$};
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% shift down the arrows pointing location %
% by 3.5pt %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\coordinate (AR) at ($(A.east)-(0pt,3.5pt)$);
\coordinate (BL) at ($(B.west)-(0pt,3.5pt)$);
\coordinate (CL) at ($(C.west)-(0pt,3.5pt)$);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\draw[-stealth, line width=1mm] (AR) -- ( $ (AR)!0.15!(BL|-AR) $ ) |- (BL) node[auto,pos=0.75] {\scalebox{1}{$h$}};
\draw[-stealth, line width=1mm] (AR) -- ( $ (AR)!0.15!(CL|-AR) $ ) |- (CL) node[auto,pos=0.75] {\scalebox{1}{$g$}} ;
\end{tikzpicture}
\end{subequations}
\end{document}