dimensiones del nodo tikz

dimensiones del nodo tikz

¿Cómo puedo obtener tikzlas dimensiones de los nodos, como el alto y el ancho? Estoy interesado en utilizar estos parámetros para calcular con precisión la ubicación de los objetos, por ejemplo, <a.height>en el siguiente ejemplo:

\documentclass{article}
\thispagestyle{empty}
\usepackage{graphicx}
\usepackage{tikz}
\begin{document}
\begin{figure}
  \begin{tikzpicture}
    \node(a) {
      \includegraphics[width=0.8\textwidth]{example-image-a}
    };
    \node(b) at (0, <a.height>*3/4){label};
  \end{tikzpicture}
\end{figure}
\end{document}

Respuesta1

Dos ejemplos donde se obtiene el resultado deseado sin conocer las dimensiones del nodo. El segundo usa calctikzlibrary.

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
  \begin{tikzpicture}
    \node(a) {
      \includegraphics[width=0.8\textwidth]{example-image-a}
    };
    \path (a.center)--(a.north) node[pos=.75, right] {label without calc};
    \node[left] at ($(a.center)!.75!(a.north)$) {label with calc};
  \end{tikzpicture}
\end{document}

ingrese la descripción de la imagen aquí

Actualizar:

Supongamos que queremos la etiqueta label without calc2 cm a la derecha y 1 cm arriba de su posición real en el ejemplo anterior: \path (a.center)--(a.north) node[pos=.75, right] {label without calc}. Podemos usar positioningla biblioteca para mover el nodo en relación con el punto correspondiente en la ruta. En este caso podemos decir above right=1cm and 2cmpero esto usará south westun ancla para la ubicación y queremos west, luego agregamos la opción anchor=westposterior above right:

\documentclass[border=2mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc, positioning}
\begin{document}
  \begin{tikzpicture}
    \node[inner sep=0pt] (a) {
      \includegraphics[width=0.8\textwidth]{example-image-a}
    };
    \path (a.center)--(a.north) node[draw, pos=.75, above right=1cm and 2cm, anchor=west, red] (b) {label without calc};
    \node[left] (c) at ($(a.center)!.75!(a.north)$) {label with calc};

    %Some auxiliary elements.
    \draw[red,<->] (a.center)--(c.east) node[midway, right] {75\%};
    \draw[red,<->] (c.east)--(a.north) node[midway,right] {25\%};
    \fill[red] (c.east) circle (1pt);
    \draw[red,<->] (c.east)-|(b.west)  node[pos=0.25,below] {2 cm} node[pos=0.75,left] {1 cm};
  \end{tikzpicture}
\end{document}

ingrese la descripción de la imagen aquí

información relacionada