Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Does it exist some tikz register (let say \zoomfactor) that provides the curent scale factor. For example can I do something like :

\begin{tikzpicture}[scale=2]
    \begin{scope}[scale=1.5]
        \draw (0,0) circle (\zoomfactor);
    \end{scope}
\end{tikzpicture}

and to obtain circle of size 3=2*1.5 ?

share|improve this question
add comment

1 Answer

up vote 8 down vote accepted

You can get the current transformation entries to extract the scale but if there are different x and y scalings(or combinations e.g. full matrix) in action, this would fail and retrieve only the x scaling. Also it uses 1cm as the unit vector.

\documentclass{article}
\usepackage{tikz}

\newcommand{\getzoomfactor}{%
\pgfgettransformentries{\myxscale}{\@tempa}{\@tempa}{\myyscale}{\@tempa}{\@tempa}
\gdef\zoomfactor{\myxscale*1cm}
}

\begin{document}

\begin{tikzpicture}[scale=2]
    \begin{scope}[scale=1.5]
        \getzoomfactor
        \draw (0,0) circle (\zoomfactor);
                \node {\zoomfactor};
    \end{scope}
\end{tikzpicture}

\end{document}

enter image description here

share|improve this answer
    
Thanks, \myxscale is what I was searching for. In your example you can put \myxscale in place of \zoomfactor and it works withouyt assuming 1cm as the unit vector. –  Kpym Dec 13 '12 at 18:00
    
@Kpym If you mix numbers without units with numbers with units you'll always get trouble. So some care is needed. –  percusse Dec 13 '12 at 19:34
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.