# frenchb in babel produces compilation error with \NewDocumentCommand

Not sure if this is a LaTeX3 issue or not, but in the code below the presence of frenchb in the babel parameters causes a compilation error. The MWE below has been boiled down from a large chunk of code to narrow down the error and it is for this reason that, on its own, it may look somewhat contrived.

\documentclass{minimal}
%-----------------------------
%RN. Sunday 23 August 2015
%   ISSUE:
% Let it be debatable whether my two \NewDocumentCommands are all
% that clever, or even make sense, the fact is they work. If frenchb
% is included as a parameter in babel, the code will throw a
% compilation error "! Undefined control sequence" referring to the
% MyParameters macro.
% Effect first observed in my 'Timelines', a gizmo that that draws
% charts displaying event lifetimes as horizontal bars and requires
% left and right edges to be set.
%-----------------------------
%\usepackage[frenchb,greek,russian,ngerman,english]{babel}
\usepackage[greek,russian,ngerman,english]{babel}

\usepackage{xparse}
\usepackage{tikz}
\usetikzlibrary{math}

\ExplSyntaxOn
\NewDocumentCommand\MyParameters{mm}
{
\tikzmath
{
\firstparam=#1;
\secondparam=#2;
}
}
\NewDocumentCommand\MyDrawing{mm}
{
\tikzmath
{
\x=\firstparam + #1;
\y=\secondparam * #2;
}
\draw[red] (\x,\y)--(\x +7,\y+4);
\draw[blue] (1,5)--(\x,\y);
}
\ExplSyntaxOff

\begin{document}

\MyParameters{1}{2}
\begin{tikzpicture}
\MyDrawing{3}{4}
\end{tikzpicture}

\end{document}

• Might be an idea to quote error as well, not all of us is at our desktops Aug 23, 2015 at 10:16
• Note I retagged to babel as expl3 is not relevant here, you would see the same if you used \newcommand or even \def Aug 23, 2015 at 10:51
• @daleif Apologies. I'll pay more attention to that aspect from here on. Aug 23, 2015 at 12:36

babel french makes ; active for special spacing, you need to turn that off (since it was off at the point you made the definition)

\documentclass{minimal}
%-----------------------------
%RN. Sunday 23 August 2015
%   ISSUE:
% Let it be debatable whether my two \NewDocumentCommands are all
% that clever, or even make sense, the fact is they work. If frenchb
% is included as a parameter in babel, the code will throw a
% compilation error "! Undefined control sequence" referring to the
% MyParameters macro.
% Effect first observed in my 'Timelines', a gizmo that that draws
% charts displaying event lifetimes as horizontal bars and requires
% left and right edges to be set.
%-----------------------------
\usepackage[frenchb,greek,russian,ngerman,english]{babel}
%\usepackage[greek,russian,ngerman,english]{babel}

\usepackage{xparse}
\usepackage{tikz}
\usetikzlibrary{math}

\ExplSyntaxOn
\NewDocumentCommand\MyParameters{mm}
{
\tikzmath
{
\firstparam=#1;
\secondparam=#2;
}
}
\NewDocumentCommand\MyDrawing{mm}
{
\tikzmath
{
\x=\firstparam + #1;
\y=\secondparam * #2;
}
\draw[red] (\x,\y)--(\x +7,\y+4);
\draw[blue] (1,5)--(\x,\y);
}
\ExplSyntaxOff

\begin{document}
\shorthandoff{;}
\MyParameters{1}{2}
\begin{tikzpicture}
\MyDrawing{3}{4}
\end{tikzpicture}

\end{document}

• And back on after the picture. Aug 23, 2015 at 10:50
• @Johannes_B there is only \end{document} after the picture:-) Aug 23, 2015 at 10:52
• Sure, i bet there is some text in the original document though. :-p Aug 23, 2015 at 10:54
• @David Carlisle @Johannes_B \shorthandoff and on is doing the trick. An undergraduate couldn't guess that in a million years! That's what Tex Exchange is for. Aug 23, 2015 at 12:30
• Naturally, the compiler complains if it sees \shorthandoff and on and frenchb happens not to be loaded into babel. How would I go about making the compilation conditional on the presence/absence of frenchb? Aug 23, 2015 at 23:56