该问题与以下内容相关:
我正在使用链接答案中建议的修改来缩放 tikz 图表。但是,我还包括使用创建的图表pgfplots
。\usepackage{pgfplots}
在包含第二张图时,添加到给定的示例会产生以下错误:
Undefined control sequence. \ScaleFactor ->\tikzscale@scale
以下是修改后的 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}
有没有办法可以同时\ScaleFactor
对多个图表使用此机制?pgfplots