3

I want to draw a function using pkz-fct and to save the picture with a "savebox" here is a minimal example :

\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}

I don't know where exactly the problem is, but the document doesn't compile if i use simultaneously babel + (domain in tkzFct) inside a savebox environment.

Can anybody help ? (the error is the same when using a tabular environment instead of savebox)

Thanks in advance.

Here is part of log :

! 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.
  • Probably your problem is that [french]{babel} makes : active. There are different solutions to this problem. One is to use \usetikzlibrary{babel}, the other is to put \shorthandoff{:;!?} inside tikzpicture. You can search for "babel+tikz+problem". – Kpym Jun 27 '15 at 13:24
  • Take a look at: tex.stackexchange.com/questions/86023/… – Ignasi Jun 27 '15 at 16:38
  • First, thank you for your quick reply. Unfortunately, both solutions doesn't work. I have already tried playing with catcodes ... with no success. May be the problem is that tkz-Fct uses gnuplot ? – mikaël Jun 27 '15 at 18:46
  • You are right, the problem seems to be only with savebox + tkz-fct + babel + domain ... sorry I have no other ideas. – Kpym Jun 27 '15 at 19:33
  • I get no error with TeX Live 2012, 2013, 2014 and 2015. Can you tell what TeX distribution you are using? – egreg Jun 27 '15 at 19:56
1

The problem seems to be the tikzpicture inside an argument. It works if you use a lrbox environment instead the \savebox command.

\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}

Another possibility is using \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}
| improve this answer | |
  • Great. Now it works fine. Thank you for the fix. – mikaël Jun 27 '15 at 21:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.