Skip to content

Conversation

@schtandard
Copy link

Rather than just a TeX group. This prevents changes to global variables like \pgflinewidth from leaking out of the axis environment.

Currently, an axis environment changes \pgflinewidth (and possibly other values) outside of the environment, leading to unexpected results with code that relies on that value being correct. For example, circuitikz uses this length to determine the component stroke width. After an axis (right resistor), this does not work correctly.

\documentclass{article}

\usepackage{tikz}
\usepackage{circuitikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}

\begin{document}

\begin{tikzpicture} [line width=2pt]
  \showthe\pgflinewidth
  \draw (-2,0) to [R] ++(2,0);
  \begin{axis} [anchor=north, yshift=-1cm]
    \addplot+ {x^2};
  \end{axis}
  \showthe\pgflinewidth
  \draw (0,0) to [R] ++(2,0);
\end{tikzpicture}

\end{document}

image

Using a pgfscope rather than a TeX group solves this problem.

Rather than just a TeX group. This prevents changes to global variables
like \pgflinewidth from leaking out of the axis environment.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant