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.
\shorthandoff{-}after begin document should work. – Ulrike Fischer Jan 04 '23 at 16:38babel? – Ondrian Jan 04 '23 at 17:13\shorthandon{-}. – Ulrike Fischer Jan 04 '23 at 17:59shorthandoff/on{-}within the tikzpicture or the custom command? My naive attempts on this fail. – Ondrian Jan 05 '23 at 11:25-shorthands in your documents then you can just\shorthandoff{-}as @UlrikeFischer said. If you do, it gets more complicated. (\foofixes the catcodes of its argument so TikZ (or thebabellibrary) can't do their magic anymore.) You coud define\foosimilar 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\fooreally doing? Maybe there's a better way to do it. – Qrrbrbirlbel Jan 09 '23 at 13:08