
我對 tikz 包不是很熟悉。在互聯網上到處閱讀,我設法做到了這一點
\begin{tikzpicture}
[node distance=.8cm,
start chain=going below,]
\node[punktchain, join] (Telegrapher){Telegrapher's equations $\begin{aligned}
\frac{d}{d z} {\vec V} \left(z,s\right) &=-\vec Z'(s){\vec I}\left(z,s\right) \\
\frac{d}{d z} {\vec I} \left(z,s\right) &=-\vec Y'(s){\vec V} \left(z,s\right)\label{test}
\end{aligned}$};
\node[punktchain, join] (test) {test};
\end{tikzpicture}
節點的定義如下:
\usepackage{tikz}
\usetikzlibrary{calc,trees,positioning,arrows,chains,shapes.geometric,%
decorations.pathreplacing,decorations.pathmorphing,shapes,%
matrix,shapes.symbols}
\tikzset{
>=stealth',
punktchain/.style={
rectangle,
rounded corners,
% fill=black!10,
draw=black, very thick,
text width=25em,
minimum height=3em,
text centered,
on chain},
line/.style={draw, thick, <-},
element/.style={
tape,
top color=white,
bottom color=blue!50!black!60!,
minimum width=8em,
draw=blue!40!black!90, very thick,
text width=10em,
minimum height=3.5em,
text centered,
on chain},
every join/.style={->, thick,shorten >=1pt},
decoration={brace},
tuborg/.style={decorate},
tubnode/.style={midway, right=2pt},
}
現在我的問題是:在我的節點中,我有一個方程式。我希望它能像乳膠中的所有其他方程式一樣編號,或者至少我希望能夠引用它。現在我已經使用了 \label{test}
,但是當我引用\ref{label}
它時,似乎以該部分作為參考。
您知道如何在圖表中正確引用節點內建立的方程式嗎?
答案1
由於解決方案是在評論中構建的,但從未作為答案發布,因此這裡是解決方案,供將來遇到此問題的任何人使用。功勞歸於對此問題評論中的使用者。
如果您想要引用方程式編號,請使用equation
或align
環境,但預設情況下,這在 TikZ 節點內不起作用。因此,您可以將其包裝在 minipage: \begin{minipage}{0.9\textwidth}
...中\end{minipage}
,這允許使用align
.現在,交叉引用可以像往常一樣工作,甚至可以與hyperref
.
另外,還有一個小問題:如果您只使用常規大小的括號,最好使用(
and)
而不是\left(
and \right)
,因為間距更好一些。看這個帖子更多細節。
這是實現此功能的程式碼。
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{calc,trees,positioning,arrows,chains,shapes.geometric,%
decorations.pathreplacing,decorations.pathmorphing,shapes,%
matrix,shapes.symbols}
\tikzset{
% ... same settings as in the question post ...
}
\usepackage[colorlinks=true]{hyperref}
\begin{document}
\begin{tikzpicture}
[node distance=.8cm,
start chain=going below,]
\node[punktchain, join] (Telegrapher){Telegrapher's equations
% Here's the difference: a minipage and align environment
\begin{minipage}{0.9\textwidth}
\begin{align}
% now, we can use \label, \ref, and \eqref as usual
\frac{d}{d z} \vec V(z,s) &= -\vec Z'(s)\vec I(z,s) \label{test1}\\
\frac{d}{d z} \vec I(z,s) &= -\vec Y'(s)\vec V(z,s) \label{test2}
\end{align}
\end{minipage}};
% Reference from another node
\node[punktchain, join] (test) {Test: reference to equation~\eqref{test1}.};
\end{tikzpicture}
% References from outside the tikzpicture also work
Reference to equation~\eqref{test2}.
\end{document}
這是 PDF 輸出的圖片。