
Não estou muito familiarizado com o pacote tikz. Lendo aqui e ali na internet, consegui fazer isso
\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}
com estas definições para os nós:
\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},
}
Agora minha pergunta é: no meu nó, tenho uma equação. Gostaria que ela fosse numerada como todas as outras equações do meu látex, ou pelo menos gostaria de poder me referir a ela. Agora eu usei \label{test}
, mas quando me refiro \ref{label}
parece tomar a seção como referência.
Você sabe como se referir corretamente a uma equação construída dentro de um nó, em um gráfico?
Responder1
Como foi construída uma solução nos comentários, mas nunca postada como resposta, aqui está a solução, para quem tiver esse problema no futuro. O crédito vai para os usuários nos comentários a esta pergunta.
Se você deseja que um número de equação seja referenciado, use os ambientes equation
ou align
, mas por padrão isso não funciona dentro de um nó TikZ. Assim, você pode envolvê-lo em uma minipágina: \begin{minipage}{0.9\textwidth}
... \end{minipage}
, que permite o uso de align
. Agora, a referência cruzada funciona normalmente e até funciona com arquivos hyperref
.
Além disso, um pequeno detalhe: se você estiver usando apenas parênteses de tamanho normal, é melhor usar (
and )
em vez de \left(
and \right)
, porque o espaçamento é um pouco melhor. Veresta postagempara mais detalhes.
Aqui está o código que faz isso funcionar.
\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}
E aqui está uma foto da saída do PDF.