1

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?

2
  • 1
    Welcome to TeX SX!, replace \gdef\ScaleFactor by \xdef\ScaleFactor. Commented Aug 27, 2015 at 16:05
  • Did the trick of Salim help you or do you need further assistance? Commented Dec 11, 2016 at 14:45

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.