![缩放包含两个相邻轴环境的图形到文本宽度时出现错误‘tikzscale’包](https://linux22.com/image/477476/%E7%BC%A9%E6%94%BE%E5%8C%85%E5%90%AB%E4%B8%A4%E4%B8%AA%E7%9B%B8%E9%82%BB%E8%BD%B4%E7%8E%AF%E5%A2%83%E7%9A%84%E5%9B%BE%E5%BD%A2%E5%88%B0%E6%96%87%E6%9C%AC%E5%AE%BD%E5%BA%A6%E6%97%B6%E5%87%BA%E7%8E%B0%E9%94%99%E8%AF%AF%E2%80%98tikzscale%E2%80%99%E5%8C%85.png)
我有一个figure
环境,我用它描绘了两个pgfplots
axis
并排的环境。我想缩放图形,以便它使用完整的\textwidth
。我尝试通过tikzscale
包来实现这一点。然而,我得到了错误
! Package pgfplots Error: Error: Plot width `-144.19234pt' is too small. This cannot be implemented while maintaining constant size for labels. Sorry, label sizes are only approximate. You will need to adjust your width..
同时还有足够的空间来扩大规模。
最小工作示例如下。
\documentclass{article}
\usepackage{currfile}
\usepackage{float} % Improved interface for floating objects.
\usepackage{lipsum} % For test purposes.
\usepackage{pgfplots}
\usepackage{showframe}
\usepackage{tikzscale}
% TikZ libraries.
\usetikzlibrary{calc}
\usetikzlibrary{external}
\tikzset{external/system call={lualatex -shell-escape -halt-on-error -interaction=batchmode -jobname "\image" "\texsource"}}
\tikzexternalize
\usetikzlibrary{plotmarks}
\begin{document}
\lipsum[1]
\begin{figure}[H]
\begin{center}
\tikzset{external/remake next}
\tikzsetnextfilename{\currfiledir tikzpicture}
\includegraphics[width=\textwidth]{\currfiledir tikzpicture.tikz}
\end{center}
\caption{Test caption.}
\end{figure}
\lipsum[2]
\end{document}
的内容tikzpicture.tikz
表示为
\begin{tikzpicture}
\begin{loglogaxis}
[
name=plot_left,
xlabel=$x$,
ylabel=$y$
]
\addplot {x};
\end{loglogaxis}
\begin{loglogaxis}
[
name=plot_right,
at={($(plot_left.outer east)+(5mm,0)$)},
anchor=outer west,
legend style=
{
at={(1,1)},
anchor=north west,
draw=none,
fill=none
},
legend cell align=left,
xlabel=$x$,
ylabel=$y$
]
\addplot {x};
\legend
{
$l_1$
}
\end{loglogaxis}
\draw[dashed,line width=0pt] (plot_left.outer south west) rectangle (plot_left.outer north east);
\draw[dashed,line width=0pt] (plot_right.outer south west) rectangle (plot_right.outer north east);
\end{tikzpicture}
我该如何解决这个错误?