5

I'm using TeXLive 2014. Here's a MWE:

\documentclass{article}
\usepackage{tkz-fct}         % Must appear before {thmtools}

\usepackage{thmtools}
\declaretheorem{theorem}

\begin{document}
  \begin{tikzpicture}
    \tkzInit  % No need to even plot anything!
  \end{tikzpicture}

  \begin{theorem}[A Silly Theorem]
    Let $a = 1$. Then $a > 0$.
  \end{theorem}
\end{document}

The error message is:

! Extra \endcsname.
\kv@processor@default ...fincsname\@xa \endcsname
                                                  \csname iftrue\endcsname \...
l.12   \begin{theorem}[A Silly Theorem]

If the optional theorem name is removed, all is well. Adding \protect{} doesn't help.

Any idea how to remove this conflict?

Thanks!

0

1 Answer 1

8

Both packages use \@xa with very different meanings. For the Tkz suite, \@xa stands for a coordinate, while thmtools wants it to mean \expandafter.

In my opinion both are wrong in their assumption: Tkz should use a private name with a prefix, while thmtools should use \@xp like amsmath or have a prefix itself.

By changing all appearances of \@xa in the Tkz suite with a different name you should be able to get around the problem. The \@xa token appears only in tkz-tools-base.tex and tkz-fct.sty; I also changed the similarly named tokens, for uniformity.

\documentclass{article}
\usepackage{etoolbox}
\usepackage{tkz-fct}         % Must appear before {thmtools}

\usepackage{thmtools}
\declaretheorem{theorem}

\makeatletter
%%% patch tkz-tools-base.tex
\let\tkz@g@xa\tkz@init@xmin % don't undef \@xa or thmtools will be upset
\let\tkz@g@xb\tkz@init@xmax\undef\@xb
\let\tkz@g@ya\tkz@init@ymin\undef\@ya
\let\tkz@g@yb\tkz@init@ymax\undef\@yb
\patchcmd{\tkz@Init}
 {\global\let\@xa\tkz@init@xmin
  \global\let\@xb\tkz@init@xmax
  \global\let\@ya\tkz@init@ymin
  \global\let\@yb\tkz@init@ymax}
 {\global\let\tkz@g@xa\tkz@init@xmin
  \global\let\tkz@g@xb\tkz@init@xmax
  \global\let\tkz@g@ya\tkz@init@ymin
  \global\let\tkz@g@yb\tkz@init@ymax}
 {}{}
\patchcmd{\tkz@Grid}
 {(\@xa,\@ya)(\@xb,\@yb)}
 {(\tkz@g@xa,\tkz@g@ya)(\tkz@g@xb,\tkz@g@yb)}
 {}{}
%%% patch tkz-fct.sty
\patchcmd{\tkz@fct}
  {\@xa:\@xb}
  {\tkz@g@xa:\tkz@g@xb}
  {}{}
\makeatother

\begin{document}
  \begin{tikzpicture}
    \tkzInit  % No need to even plot anything!
  \end{tikzpicture}

  \begin{theorem}[A Silly Theorem]
    Let $a = 1$. Then $a > 0$.
  \end{theorem}
\end{document}

Probably the issue should be made known to the maintainers of the Tkz suite and of thmtools.

2
  • Many thanks! That black magic does the trick beautifully.
    – Dominique
    Nov 8, 2014 at 21:12
  • The package has been updated since the bug report.
    – egreg
    Apr 11, 2020 at 14:32

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.