我想使用 pkz-fct 绘制一个函数,并使用“savebox”保存图片,这是一个最简单的例子:
\documentclass[a4paper,10pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{xcolor}
\usepackage{tkz-fct}
\usepackage{graphicx}
\usepackage[frenchb]{babel}
\begin{document}
Test :
\newsavebox{\imgA}
\savebox{\imgA}{\begin{tikzpicture}
\tkzInit[xmin=-1.,xmax=3.,ymin=-3, ymax=1.5]
\tkzSetUpPoint[shape=circle, size = 3, color=black, fill=lightgray]
\tkzGrid[sub]
\tkzAxeXY
% \tkzFct[line width=1pt, color=blue, domain=-2:4]{(-2.)*(x-1.)**2-1.} % not working with Babel
\tkzFct[line width=1pt, color=blue]{(-2.)*(x-1.)**2-1.} % working with Babel
\tkzText[draw,fill = brown!20](2,1){$\Delta<0$}
\end{tikzpicture}}
\usebox{\imgA}
\end{document}
我不知道问题到底出在哪里,但如果我同时使用,文档就不会编译巴别塔+(tkzFct 中的域名)在里面savebox 环境。
有人可以帮忙吗?(使用表格环境而不是保存箱时错误是相同的)
提前致谢。
以下是日志的一部分:
! Argument of \pgfkeys@code has an extra }.
<inserted text>
\par
l.28 \end{tikzpicture}}
Runaway argument?
\tkz@bb ]function{((-2.)*(x-1.)**2-1.)/\tkz@init@ystep };\end {scope}\ETC.
! Paragraph ended before \pgfkeys@code was complete.
<to be read again>
\par
l.28 \end{tikzpicture}}
! Extra }, or forgotten \endgroup.
<recently read> }
l.28 \end{tikzpicture}}
! Missing \endgroup inserted.
<inserted text>
\endgroup
l.30 \end{document}
! Missing \endgroup inserted.
<inserted text>
\endgroup
l.30 \end{document}
! Missing \endgroup inserted.
<inserted text>
\endgroup
l.30 \end{document}
! Missing } inserted.
<inserted text>
}
l.30 \end{document}
! Missing \endgroup inserted.
<inserted text>
\endgroup
l.30 \end{document}
! Missing \endgroup inserted.
<inserted text>
\endgroup
l.30 \end{document}
! Missing \endgroup inserted.
<inserted text>
\endgroup
l.30 \end{document}
! Missing } inserted.
<inserted text>
}
l.30 \end{document}
! Missing \endgroup inserted.
<inserted text>
\endgroup
l.30 \end{document}
! Missing \endgroup inserted.
<inserted text>
\endgroup
l.30 \end{document}
! Missing \endgroup inserted.
<inserted text>
\endgroup
l.30 \end{document}
! Missing \endgroup inserted.
<inserted text>
\endgroup
l.30 \end{document}
! Missing } inserted.
<inserted text>
}
l.30 \end{document}
[1{/home/test/texlive/2014/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
(./test.aux) )
(\end occurred when \ifcsname on line 28 was incomplete)
(\end occurred when \ifx on line 28 was incomplete)
(\end occurred when \ifx on line 28 was incomplete)
(see the transcript file for additional information){/home/test/texlive/2014/
texmf-dist/fonts/enc/dvips/cm-super/cm-super-t1.enc}</home/test/texlive/2014/
texmf-dist/fonts/type1/public/cm-super/sfrm1000.pfb>
Output written on test.pdf (1 page, 11207 bytes).
Transcript written on test.log.
答案1
问题似乎出在tikzpicture
参数内部。如果您使用lrbox
环境而不是\savebox
命令,它就会起作用。
\documentclass[a4paper,10pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[frenchb]{babel}
\usepackage{tkz-fct}% loads graphicx, xcolor
\begin{document}
Test :
\newsavebox\imgA
\begin{lrbox}{\imgA}
\begin{tikzpicture}
\tkzInit[xmin=-1.,xmax=3.,ymin=-3, ymax=1.5]
\tkzSetUpPoint[shape=circle, size = 3, color=black, fill=lightgray]
\tkzGrid[sub]
\tkzAxeXY
\tkzFct[line width=1pt, color=blue, domain=-2:4]{(-2.)*(x-1.)**2-1.}
\tkzText[draw,fill = brown!20](2,1){$\Delta<0$}
\end{tikzpicture}
\end{lrbox}
\usebox{\imgA}
\end{document}
另一种可能性是使用\shorthandoff{:}\savebox{imgA}{...}\shorthandon{:}
\documentclass[a4paper,10pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[frenchb]{babel}
\usepackage{tkz-fct}
\begin{document}
Test :
\newsavebox{\imgA}
\shorthandoff{:}
\savebox{\imgA}{%
\begin{tikzpicture}
\tkzInit[xmin=-1.,xmax=3.,ymin=-3, ymax=1.5]
\tkzSetUpPoint[shape=circle, size = 3, color=black, fill=lightgray]
\tkzGrid[sub]
\tkzAxeXY
\tkzFct[line width=1pt, color=blue, domain=-2:4]{(-2.)*(x-1.)**2-1.}
\tkzText[draw,fill = brown!20](2,1){$\Delta<0$}
\end{tikzpicture}%
}
\shorthandon{:}
\usebox{\imgA}
\end{document}