3

I've defined a custom length for drawing dots in tikzpicture:

\documentclass{article}
\usepackage{tikz}
\newcommand*{\point}{1.5pt}

\begin{document}
\begin{tikzpicture}
    \filldraw (1,1) circle[radius=\point];
\end{tikzpicture}
\end{document}

But sometimes in more complex drawings, I would scale the whole picture down with a global (optional) scale=0.7 right after \begin{tikzpicture}.

\documentclass{article}
\usepackage{tikz}
\newcommand*{\point}{1.5pt}

\begin{document}
\begin{tikzpicture}[scale=0.7] % Scaled!
    \filldraw (1,1) circle[radius=\point];
\end{tikzpicture}
\end{document}

The problem is, that since the length is not predefined like \pgflinewidth, the radius of the point will also scale down. Is there a way to make it independet from scaling like \pgflinewidth?

Edit: To clarify my goal: I want to leave the radius of the circle under scaling untouched, but the midpoint should obviously scale. The MWE in that sense isn't optimal, since the circle sits at the origin (changed it).

2 Answers 2

4

You could locally reset the transformation matrix with option reset cm (or shift only if you want to retain shifting part):

Correction: reset cm resets even the center of circle to the origin, which is wrong. Applying shift only to circle[...] seems to work.

Using pic works for more general drawings. pics, like nodes, only apply the shifting part by default.

\documentclass{article}
\usepackage{tikz}
\newcommand*{\point}{1.5pt}

\begin{document}
\parindent=0pt
Before: \\
\begin{tikzpicture}[scale=0.7] % Scaled!
    \draw[help lines] (0,0) grid (3,3);
    \filldraw (0,0) circle[radius=\point]
              (1,1) circle[radius=\point];
\end{tikzpicture}

Using \verb|circle[shift only ...]|: \\
\begin{tikzpicture}[scale=0.7] % Scaled!
    \draw[help lines] (0,0) grid (3,3);
    \filldraw (0,0) circle[shift only, radius=\point]
              (1,1) circle[shift only, radius=\point];
\end{tikzpicture}

Using \verb|pic|: \\
\tikzset{
  dot/.pic={
    \filldraw circle[radius=\point];
  }
}
\begin{tikzpicture}[scale=0.7] % Scaled!
    \draw[help lines] (0,0) grid (3,3);
    \draw (0,0) pic {dot}
          (1,1) pic {dot};
\end{tikzpicture}
\end{document}

enter image description here

The ultimate solution is to extend tikz, pgf, and perhaps the underlying pgfmath so that they all recognize some sort of absolute dimension and follow some absoluteness composition rules.

9
  • Or \pgftransformresetnontranslations and use \begin{scope}[ shift = { (1, 2) } ] outside the \drawfill to move your circle.
    – Symbol 1
    Dec 28, 2021 at 11:55
  • I've read in the manual (p. 379): This will destroy not only the transformations applied in the current scope, but also all transformations inherited from surrounding scopes. Does that mean, that the scaling afterwards is reset too?
    – Gargantuar
    Dec 28, 2021 at 14:08
  • @Gargantuar Each path command (here \filldraw) starts a new group, so the effect of \filldraw[reset cm] is local. Dec 28, 2021 at 15:19
  • 1
    @Symbol1 I've added shift only to answer, which seems to be equivalent to what you suggest, does it? Dec 28, 2021 at 15:24
  • 1
    @Symbol1 Yeah, it works indeed, sry about that. I've added shift only as an optional parameter to \filldraw, not circle. But tbh, I think the pic solution is the prettiest.
    – Gargantuar
    Dec 28, 2021 at 23:45
0

One possible solution is to divide your radius by your scale:

\documentclass{article}
\usepackage{tikz}
\newcommand*{\point}{1.5pt}

\begin{document}
\begin{tikzpicture}
    \filldraw circle[radius=\point];
\end{tikzpicture}

\newcommand{\scl}{0.7}
\begin{tikzpicture}[scale=\scl] % Scaled!
    \filldraw circle[radius=\point/\scl];
\end{tikzpicture}
\end{document}
1
  • 1
    I also already had the idea, but then I have to manually multiply by the scale, which could change across tikzpictures.
    – Gargantuar
    Dec 28, 2021 at 10:52

You must log in to answer this question.

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