
我目前找不到 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}