我想使用 XelaTeX 编译一个独立的 tikz 图形并将其包含在更大的文档中。MWE 显示了效果。当我这样做时,Y 轴标签消失了。X 轴标签仍然存在。如果我添加ylabel shift
(在图片代码中标记为“此行”),输出图像会发生变化,就像标签移动了一样,但仍然看不到。
如果我使用 TikzEdt 查看图片,它有一个标签。
主要的:
%magic comment
% !TeX program = txs:///xelatex | txs:///view-pdf
\documentclass{article} %[smallcondensed]{svjour3}
\usepackage[subpreambles=true]{standalone}
\newcommand{\fileNameOfTIKZ}{filename}
\newlength\figureheight %for variable size tikz
\newlength\figurewidth
\begin{document}
\begin{figure}[hptb!]
\renewcommand{\fileNameOfTIKZ}{pic}
\setlength\figureheight{100pt}
\setlength\figurewidth{\textwidth}
\includestandalone[width=\textwidth]{\fileNameOfTIKZ}
\caption{A graph without a y-label.}
\label{img}
\end{figure}
\end{document}
示例图片:
\documentclass[tikz]{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{plotmarks}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{patterns}
\begin{document}
\setlength\figureheight{100pt}
\setlength\figurewidth{\textwidth}
\begin{tikzpicture}
\pgfplotsset{compat=newest}
\begin{axis}[%
width=\figurewidth,
height=0.696\figureheight,
at={(0\figurewidth,0\figureheight)},
scale only axis,
unbounded coords=jump,
xmin=0,
xmax=800,
xtick={\empty},
xlabel={Time},
ymin=-5,
ymax=2.2797697532885,
ytick={\empty},
ylabel={Performance},
%this line%ylabel shift = -10 pt,
title style={font=\bfseries},
legend style={at={(0.97,0.03)},anchor=south east,legend cell align=left,align=left,draw=white!15!black}]
\addplot [color=red,dashdotted,line width=1.0pt]
table[row sep=crcr]{%
1 -inf\\
2 -0.366512920581664\\
3 0.0940478276166989\\
};
\addlegendentry{Line 1};
\addplot [color=black!30!green,solid,line width=1.0pt]
table[row sep=crcr]{%
1 -5\\
2 -4.30685281944005\\
3 -3.90138771133189\\
};
\addlegendentry{Line 2};
\end{axis}
\end{tikzpicture}%
\end{document}