When I use scale
in tikzpictures (without transform shape
), the text size in nodes is not changed (which is good and well). Suppose now that I want to put some node in a scaled graph using a distance proportional to the node font; I naively supposed that I could use ex
coords, but see below...
I also printed the values of the coordinates, and \pgf@yy
which should give the unit vector, but there is something I miss here...
Is there a way to express a distance which is proportional to the (default) font size, independently from the scale?
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\newdimen\mydimA\newdimen\mydimB
\makeatletter
\newcommand{\showat}[1]{%
\pgfextracty\mydimA{\pgfpointanchor{A}{center}}
\pgfextracty\mydimB{\pgfpointanchor{B}{center}}
\node[red, font=\tiny, align=left] at(#1) {Before \the\mydimA \\ After \the\mydimB \\
Scale y \the\pgf@yy};
}
\makeatother
\begin{document}
\begin{tikzpicture}[baseline]
\draw (0,0) --(1,0) coordinate(A) -- (2,0);
\path (A) ++(0,1ex) coordinate(B);
\node [anchor=base] at (B) {$R_g$};
\showat{1,-1}
\end{tikzpicture}
\begin{tikzpicture}[baseline, scale=2]
\draw (0,0) --(0.5,0) coordinate(A) -- (1,0);
\path (A) ++(0,1ex) coordinate(B);
\node [anchor=base] at (B) {$R_g$};
\showat{0.5,-0.5}
\end{tikzpicture}
\begin{tikzpicture}[baseline, scale=0.01]
\draw (0,0) --(100,0) coordinate(A) -- (200,0);
\path (A) ++(0,1ex) coordinate(B);
\node [anchor=base] at (B) {$R_g$};
\showat{100,-100}
\end{tikzpicture}
\end{document}
cm
orex
, it's allsp
.ex
(relative to the node font).