babel 中的 frenchb 使用 \NewDocumentCommand 产生编译错误

babel 中的 frenchb 使用 \NewDocumentCommand 产生编译错误

不确定这是否是个问题,但在下面的代码中,参数中LaTeX3的存在会导致编译错误。下面的 MWE 是从一大段代码中提炼出来的,以缩小错误范围,正因为如此,它本身看起来可能有些做作。frenchbbabel

\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}

答案1

babel french 使;特殊间距处于活动状态,您需要将其关闭(因为在您进行定义时它已关闭)

\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}

相关内容