2

I am trying to compile an old document, which uses in many occasions tikzpicture passed as an argument to a user defined command. While I understand this might not be an ideal design, it is not in my power to change it.

The problem is that the active char - causes clash between tikz and czech babel. This can be solved via babel tikzlibrary. However, as already discussed in Babel, active chars, ifthenelse and tikz the workaround does not work when the tikzpicutre is used as an argument of a command. The post above provides a solution for french Babel, however, here, the problem is slightly different and the proposed fix does not apply here.

MWE:

\documentclass{standalone}

%\usepackage[english]{babel} \usepackage[czech]{babel}

\usepackage{tikz} \usetikzlibrary{babel}

\newcommand{\foo}[1]{#1}

\begin{document} \foo{ \begin{tikzpicture} \node[draw, rotate=-90] at (0,0) {test}; \end{tikzpicture} } \end{document}

Error:

Missing number, treated as zero.
Ondrian
  • 1,536
  • \shorthandoff{-} after begin document should work. – Ulrike Fischer Jan 04 '23 at 16:38
  • Will this have any unintended consequences with respect to babel? – Ondrian Jan 04 '23 at 17:13
  • depends on if you use the shorthand or not, but you can always reactivate it with \shorthandon{-}. – Ulrike Fischer Jan 04 '23 at 17:59
  • I am not sure. I don't activate nor deactivate it manually within the document. I rely on babel to do the hyphenation (I assume this is related) even defining my own rules. Is there a way to use shorthandoff/on{-} within the tikzpicture or the custom command? My naive attempts on this fail. – Ondrian Jan 05 '23 at 11:25
  • If you don't use the - shorthands in your documents then you can just \shorthandoff{-} as @UlrikeFischer said. If you do, it gets more complicated. (\foo fixes the catcodes of its argument so TikZ (or the babel library) can't do their magic anymore.) You coud define \foo similar to how I defined the box macro in a somewhat related answer. (For example: \newcommand*\foo{\shorthandoff{-}\fooInternal}\newcommand*\fooInternal[1]{#1\shorthandon{-}}) – Qrrbrbirlbel Jan 09 '23 at 13:07
  • What is \foo really doing? Maybe there's a better way to do it. – Qrrbrbirlbel Jan 09 '23 at 13:08

0 Answers0