12

I'm using several macro's to quickly draw points in a figure (I have to realy draw a lot). For example I use:

\newcommand{\punt}[3]{\draw[fill,scale=1]#1 coordinate(#2)circle(0.5pt)node[#3]{$#2$};}

to quickly draw a point and it's name, as well as give it the correct coordinate.

My problem is that as I'm drawing I might later decide to scale the entire picture (using scale). This results in larger dots that depict the points. I don't want this because I might scale one picture to 2 times it's size and another one to 0.5 it's size and this leads to a discrepancy in dot sizes throughout my document.

An even greater problem arises when I use xscale or yscale which leads to deformed circles.

Is there a way I can tell my macro to ignore all other scaling? As you can see I tried putting scale=1 in the draw options but this didn't help...

2 Answers 2

14

You can use the shift only key. From the manual:

This option does not take any parameter. Its effect is to cancel all current transformations except for the shifting. This means that the origin will remain where it is, but any rotation around the origin or scaling relative to the origin or skewing will no longer have an effect.

This option is useful in situations where a complicated transformation is used to “get to a position,” but you then wish to draw something “normal” at this position.

The following command first places a coordinate node at the desired location with scaling in effect and then places a circle around that node without scaling:

\newcommand{\punt}[3]{
    \draw #1 coordinate (#2);
    \fill[shift only] (#2) circle (0.5pt) node[#3] {$#2$};
}
1
  • I didn't know that key.. even though I have been going over and over the Tikz manual to find a solution. Always good to have the extra knowledge thanks!
    – romeovs
    Commented Jan 31, 2011 at 12:33
3

The following doesn't really answer the actual question, but it does solve your problem. (And I, for one, would be interested in knowing how to solve the actual question.)

\documentclass{minimal}

\usepackage{tikz}
\newcommand{\punt}[3]{\draw[fill,scale=1]#1 coordinate(#2) node[circle,fill,inner sep=1pt] {} node[#3]{$#2$};}

\begin{document}

\begin{tikzpicture}
\begin{scope}
\punt{(0,0)}{a}{above}
\end{scope}
\begin{scope}[scale=5]
\punt{(0,-1)}{a}{above}
\end{scope}
\begin{scope}[scale=2]
\punt{(0,-2)}{b}{below}
\end{scope}
\end{tikzpicture}
\end{document}

This works because the scaling doesn't apply to the shape of nodes, so by drawing the circle using the node syntax, the scaling doesn't get applied to the circle size.

1
  • yes this is what I did now.. it works perfectly!
    – romeovs
    Commented Jan 31, 2011 at 12:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .