I am making a multi-language document. With the big help of Mr. Steven B. Segletes, I am able to deal with several languages mixed document, which can only output in wanted one or several laguages. See the thread Parse command argument separated by comma
I also aliased \mulan to new commands such as \mulanp and \mulanr so that the \mulan command can be simplified when the text is seperated by \par or /.
Now I am defining an aliasing command to make \mulan also works in table.
(I have no idea about how to define a variable number argument command, so I just fix the number of arguments to three)
When I compile the following minimal example, it works as expected.
But when I comment a meaningless statement before the table, it gives an error message,
!Missing \endcsname inserted.
Could you help out? Thanks in advance.
%
% Command \mulan usage example
% Compiled by XeLatex
\documentclass{article}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Table packages
\usepackage{longtable} %long table across multi pages
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \mulan comand defintion to deal with multiple language
\newif\ifen %English
\newif\iffr %French
\newif\ifru %Russian
\newif\ifjp %Japanese
\newif\ifcn %Chinese
\newif\ifkr %Korean
%
\def\en#1{\ifen\callsep #1\fi\langcmd}
\def\fr#1{\iffr\callsep #1\fi\langcmd}
\def\ru#1{\ifru\callsep #1\fi\langcmd}
\def\jp#1{\ifjp\callsep #1\fi\langcmd}
\def\cn#1{\ifcn\callsep #1\fi\langcmd}
\def\kr#1{\ifkr\callsep #1\fi\langcmd}
%specify the multi languge sequence variable globaly
\def\mulanseq#1{\gdef\my@mulanseq{#1}}
%\gdef\my@mulanseq{en,jp,cn}
\newcounter{mulan@args}
%\newcommand\mulan[2][en,jp,cn]{%
\newcommand\mulan[2][en,jp,cn]{%
\gdef\thesep{#2}%
\setcounter{mulan@args}{0}%
\commaparse#1,\relax%
\stepcounter{mulan@args}%
\expandafter\def\csname arg\romannumeral\value{mulan@args}\endcsname{relax}%
\setcounter{mulan@args}{0}%
\langcmd%
}
\def\commaparse#1,#2\relax{%
\stepcounter{mulan@args}%
\expandafter\def\csname arg\romannumeral\value{mulan@args}\endcsname{#1}%
\if\relax#2\else\commaparse#2\relax\fi%
}
\newcommand\langcmd{%
\stepcounter{mulan@args}%
\csname\csname arg\romannumeral\value{mulan@args}\endcsname\endcsname%
}
\newcommand\callsep{\ifnum\value{mulan@args}>1\thesep\fi}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Convient alias command for \mulan
\def\mulanp{\expandafter\mulan{\par}}
\def\mulanr{\expandafter\mulan{ \space {\textbf{/}}\space}}
% multiline in tab cell !!! problem yet !!!
\newcommand\mulanT[4][l]{
\begin{tabular}{#1}
\mulan{\\}{#2}{#3}{#4} %
\end{tabular}
}
%
\newcommand\mulanTL{\mulanT[l]}
\newcommand\mulanTC{\mulanT[c]}
\newcommand\mulanTR{\mulanT[r]}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%%%---------------------
\entrue \jptrue \cntrue
%%%---------This command has not been finished yet------
%\mulanseq{en,jp,cn}
\title{\mulanp{English Document}{Japanese Document}{Chinese Document}}
\author{\mulanr{English name}{Japanese name}{Chinese name}}
\maketitle
\tableofcontents
\abstract
\section{\mulanr{English title}{Japanese title}{Chinese title}}
%%% !!! if the following statement is commented, there will be an error occured.
%\mulan{}{}{}{} % I just make it do nothing
\begin{longtable}{ccc}
\hline
\mulanT{English item}{Japanese item}{Chinese item} & Price(USD) & \mulanT{Englishi-Repark}{Japanese-Repark}{Chinese-Remark}\\
\hline
\mulanT{IamEnglish}{IamJapanese}{IamChinese} & 15.0 & \mulanT{This is remark in English and is very long.}{This is remark in Japanese and is very long.}{This is remark in Chinese and is very long.} \\
\hline
\end{longtable}
\end{document}
\mulanrmacro call in\section{\mulanr{Title}...is the cause, try to use\section{\protect\mulanr{.....}}– Feb 13 '15 at 07:32\protect command, it does not work yet. – Jilong Yin Feb 13 '15 at 08:19@sign in command names appearing in your definitions, you need to wrap that portion of the preamble with\makeatletter ... \makeatother. – barbara beeton Feb 13 '15 at 13:47