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 want it can also works in table use. I know I can not insert a multiline sentence in a tab cell.
So I hope the contents explained by \mulan
command can be treated as a sub-tabular. Just like the following,
\mulanTL{A}{B}{C}
will give output
\begin{tabular}{l}
A \\
B \\
C\\
\end{tabular}
I don't know how to define it. I tried a lot bu failed. The following is my minimal example. Though I am not sure you can compile it correctly because it includes CJK characters.
%
% Command \mulan usage example
% Compiled by XeLatex
\documentclass{article}
% CJK character support
\usepackage{fontspec,xltxtra,xunicode}
\usepackage[slantfont,boldfont,CJKnumber]{xeCJK}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Table packages
\usepackage{longtable} %long table across multi pages
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%CJK settings
\setCJKfamilyfont{zhrm}{SimSun} %Chinese
\setCJKfamilyfont{jarm}{NSimSun} %Japanese
\setCJKfamilyfont{korm}{Batang} %Korean
\newcommand\Chinese{\CJKfamily{zhrm}\CJKnospace}
\newcommand\Japanese{\CJKfamily{jarm}\CJKnospace}
\newcommand\Korean{\CJKfamily{korm}\CJKspace}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \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 {\Japanese #1}\fi\langcmd}
\def\cn#1{\ifcn\callsep {\Chinese #1}\fi\langcmd}
\def\kr#1{\ifkr\callsep {\Korean #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{\mulanTL}{\begin{tabular}{l}\expandafter\mulan{\\} \end{tabular} }
\newcommand{\mulanTL}{\expandafter\mulan{ \space {\textbf{/}}\space}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%%%---------------------
\entrue \jptrue \cntrue
%%%---------This command has not been finished yet------
%\mulanseq{en,jp,cn}
\title{\mulanp{Multilingual Document}{多言語文書}{多语言文档}}
\author{\mulanr{Jerome}{竹本 松一}{竹本先生}}
\maketitle
\tableofcontents
\abstract
\section{\mulanr{Title}{標題}{标题}}
\mulanp{This is the text.}{これは正文です。}{这是正文。}
\mulanr{This is an example of table.}{これは表の例}{这是一个表格的例子}
\mulanTL{Japanese traditional craft, it can be seen even nowadays}{日本の伝統的な芸術}{日本传统艺术}
\begin{longtable}{ccc}
\hline
\mulanr{Item}{項目}{项目} & Price(USD) & \mulanr{Repark}{注釈}{备注}\\
\hline
\mulanr{Japanese Paper}{和紙}{日本纸} & 15.0 & \mulanTL{Japanese traditional craft, it can be seen even nowadays}{日本の伝統的な芸術}{日本传统艺术} \\
\hline
\end{longtable}
\end{document}
If the number of arguments is fixed to, e.g. 3. I can make the command as follows,
\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]}
Is there any means to deal with the case with variable number of arguments?
if it requires the editing of the definiton of command \mulan
, that will also be O.K.
Thanks in advance.
\mulanTL
variable? Or will it always be 3?