This question is related to:
tikz: Scaling the unscalable — issues with a TikZ graph
I'm using the suggested modification from the linked answer to scale tikz graphs. However, I'm also including plots created with pgfplots. Adding \usepackage{pgfplots} to the given example produces the following error when including the second graph:
Undefined control sequence. \ScaleFactor ->\tikzscale@scale Here's the modified MWE:
\documentclass{article} \usepackage{tikz} \usepackage{pgfplots} \usepackage{tikzscale} \usepackage{filecontents} \let\OrgPgfTransformScale\pgftransformscale \renewcommand*{\pgftransformscale}[1]{% \gdef\ScaleFactor{#1}% \OrgPgfTransformScale{#1}% } \def\ScaleFactor{1} \begin{document} \begin{filecontents*}{test.tikz} \begin{tikzpicture}[ node distance=3cm*\ScaleFactor, main node/.style={ circle, draw, } ] \typeout{* Scale factor: \ScaleFactor} % nodes \node[main node] (A) {A}; \node[main node] (B) [right of=A] {B}; % lines \path[every node/.style={font=\sffamily\large}] (A) edge [bend right] node[below] {0.0} (B) (B) edge [bend right] node [below] {0.0} (A); \end{tikzpicture} \end{filecontents*} \begin{figure} \centering \includegraphics[width=\textwidth]{test.tikz} \caption{This figure has standard width} \end{figure} \begin{figure} \centering \includegraphics[width=0.5\textwidth]{test.tikz} \caption{This figure has half width} \end{figure} \end{document} Is there a way to use this \ScaleFactor mechanism for multiple graphs while using pgfplots at the same time?
\gdef\ScaleFactorby\xdef\ScaleFactor.