3

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. 
%   COMMENTS: 
% 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}
3
  • 3
    Might be an idea to quote error as well, not all of us is at our desktops – daleif Aug 23 '15 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 – David Carlisle Aug 23 '15 at 10:51
  • @daleif Apologies. I'll pay more attention to that aspect from here on. – Reinhard Neuwirth Aug 23 '15 at 12:36
4

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. 
%   COMMENTS: 
% 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}
5
  • And back on after the picture. – Johannes_B Aug 23 '15 at 10:50
  • @Johannes_B there is only \end{document} after the picture:-) – David Carlisle Aug 23 '15 at 10:52
  • 1
    Sure, i bet there is some text in the original document though. :-p – Johannes_B Aug 23 '15 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. – Reinhard Neuwirth Aug 23 '15 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? – Reinhard Neuwirth Aug 23 '15 at 23:56

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.