我在处理 tikz 图片时遇到了问题。在 Ubuntu 17.04 上安装 TeX Live 2017 的新“原始”版本后出现了问题。在旧版本 2016 上一切正常,我没有遇到这个问题。2016 版本不是“原始”版本,它是从 Ubuntu 存储库安装的。
我有一个 tikz 图片脚本
单象限开关.tex
\documentclass[tikz]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}%[>=latex]
\draw[style=help lines] (0,0) (3,2);
\tikzset{font=\large}
\coordinate (vec3) at (0:5);
\coordinate (vec4) at (90:5);
\coordinate (vec5) at (270:5);
\coordinate (vec6) at (180:5);
\fill[lightgray!50!white] (0,0) rectangle (4,4);
\draw[->,very thick,black] (0,0) -- (vec3);
\draw[->,very thick,black] (0,0) -- (vec4);
\draw[->,very thick,black] (0,0) -- (vec5);
\draw[->,very thick,black] (0,0) -- (vec6);
\draw (5,-0.2) node [align=left, below] {Switch \\ off state \\ voltage};
\draw (-0.2,4.9) node [align=left, left] {Switch \\ on state \\ current};
\end{tikzpicture}
\end{document}
当我创建图片的 PDF 时,它工作正常。当我想使用命令 \includestandalone 将其包含到另一个文件中时,就会出现问题,如下所示
\includestandalone[width=0.45\textwidth]{Chapter2/Figs/tikz/single_quadrant_switch}
这是日志文件中的错误
(./Chapter2/Figs/tikz/single_quadrant_switch.tex (/usr/local/texlive/2017/texmf-dist/tex/latex/standalone/standalone.cfg
File: standalone.cfg 2015/07/15 v1.2 Default configuration file for 'standalone' class
Missing character: There is no a in font nullfont!
Missing character: There is no c in font nullfont!
Missing character: There is no t in font nullfont!
Missing character: There is no i in font nullfont!
Missing character: There is no v in font nullfont!
Missing character: There is no e in font nullfont!
Missing character: There is no , in font nullfont!
Missing character: There is no t in font nullfont!
Missing character: There is no i in font nullfont!
Missing character: There is no g in font nullfont!
Missing character: There is no h in font nullfont!
Missing character: There is no t in font nullfont!
Missing character: There is no p in font nullfont!
Missing character: There is no a in font nullfont!
Missing character: There is no g in font nullfont!
Missing character: There is no e in font nullfont!
Missing character: There is no p in font nullfont!
Missing character: There is no r in font nullfont!
Missing character: There is no e in font nullfont!
Missing character: There is no v in font nullfont!
Missing character: There is no i in font nullfont!
Missing character: There is no e in font nullfont!
Missing character: There is no w in font nullfont!
) (/usr/local/texlive/2017/texmf-dist/tex/latex/base/size10.clo
File: size10.clo 2014/09/29 v1.4h Standard LaTeX file (size option)
)
./Chapter2/Figs/tikz/single_quadrant_switch.tex:21: Missing number, treated as zero.
<to be read again>
=
l.21 \end{tikzpicture}
A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)
)
File: Chapter2/Figs/tikz/single_quadrant_switch.tex Graphic file (type tex)
./Chapter2/chapter2.tex:39: Package graphics Error: Division by 0.
See the graphics package documentation for explanation.
Type H <return> for immediate help.
...
l.39 ...Chapter2/Figs/tikz/single_quadrant_switch}
Your command was ignored.
Type I <command> <return> to replace it with another command,
or <return> to continue without it.
./Chapter2/chapter2.tex:39: Package graphics Error: Division by 0.
See the graphics package documentation for explanation.
Type H <return> for immediate help.
...
l.39 ...Chapter2/Figs/tikz/single_quadrant_switch}
Your command was ignored.
Type I <command> <return> to replace it with another command,
or <return> to continue without it.
./Chapter2/chapter2.tex:52: Extra }, or forgotten \endgroup.
\sf@endfloatbox ...gefalse \outer@nobreak \egroup
\color@endbox
l.52 \end{figure}
I've deleted a group-closing symbol because it seems to be
spurious, as in `$x}$'. But perhaps the } is legitimate and
you forgot something else, as in `\hbox{$x}'. In such cases
the way to recover is to insert both the forgotten and the
deleted material, e.g., by typing `I$}'.
./Chapter2/chapter2.tex:52: Too many }'s.
\color@endbox ->\color@endgroup \egroup
l.52 \end{figure}
You've closed more groups than you opened.
Such booboos are generally harmless, so keep going.
./Chapter2/chapter2.tex:52: LaTeX Error: \begin{document} ended by \end{figure}.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.52 \end{figure}
Your command was ignored.
Type I <command> <return> to replace it with another command,
or <return> to continue without it.
./Chapter2/chapter2.tex:52: Extra \endgroup.
<recently read> \endgroup
l.52 \end{figure}
Things are pretty mixed up, but I think the worst is over.
有趣的是,circuitikz 图片可以与 \includestandalone 命令配合使用。
这是 circuitikz 的代码,适用于 2017 版 TeX Live
二极管_四象限开关.tex
\documentclass[tikz]{standalone}
\usepackage{tikz}
\usepackage[americanresistors,americaninductors]{circuitikz}
\usetikzlibrary{arrows.meta}
\begin{document}
\tikzstyle{every path}=[line width=0.9pt]
\begin{circuitikz}[american voltages]
\draw(3,0) node [nigbt, scale=1.8, name=igbt1] {};
\draw(0,0) to[D, name=D1] (3,3){}
to[D, name=D2, invert] (6,0){}
to[D, name=D3, invert] (3,-3){}
to[D, name=D3] (0,0){};
\draw (igbt1.C) to[short, -*] (3,3);
\draw (igbt1.E) to[short, -*] (3,-3);
\draw (0,0) to[short, *-] ++(-1,0);
\draw (6,0) to[short, *-] ++(1,0);
\end{circuitikz}
\end{document}
我不确定是什么问题。
我添加了一个简单的例子来更好地说明问题
\documentclass{article}
\usepackage[siunitx]{circuitikz}
\usepackage[subpreambles=false, obeyclassoptions=true]{standalone}
\begin{document}
Simple example.
\begin{figure}[htbp!]
\includestandalone[width=0.45\textwidth]{Chapter2/Figs/tikz/single_quadrant_switch}
\includestandalone[width=0.45\textwidth]{Chapter2/Figs/tikz/diodes_four_quadrant_switch}
\end{figure}
\end{document}
我刚刚发现它与独立包中的参数 obeclassoptions 有关。当它设置为 true 时,我在新版本的 Tex Live 2017(不是旧版本)中收到错误。但是当我将其设置为 false 时,一切都正常。
答案1
请注意,类tikz
的选项与加载包的选项standalone
相同。但是,该选项会为每个提到的环境创建一个新页面。新页面需要一个新的框,因此需要一个新的组,如果分页符位置不正确,则会导致问题。multi=tikzpicture
tikz
multi
standalone
tikzpicture
如果您的独立文件或扩展环境中只有一个,circuitikz
请不要使用tikz
类选项,而只需tikz
自己加载包。
当您obeyclassoptions
使用standalone
包裹将尝试应用standalone
文件的所有类选项,因此将把内部包装tikzpicture
在circuitikz
一个盒子里,我猜这是问题的根源。