我正在制作一份多语言文档。在 Steven B. Segletes 先生的大力帮助下,我能够处理多语言混合文档,该文档只能输出所需的一种或多种语言。请参阅主题 [解析以逗号分隔的命令参数]
我还将\mulan
新命令(例如\mulanp
和)别名为\mulanr
,以便\mulan
当文本由\par
或“/”分隔时可以简化命令。
现在我希望它也能在表格中使用。我知道我不能在标签单元格中插入多行句子。所以我希望\mulan
命令解释的内容可以被视为子表格。就像下面这样,
\mulanTL{A}{B}{C}
将给出输出
\begin{tabular}{l}
A \\
B \\
C\\
\end{tabular}
我不知道如何定义它。我尝试了很多次但都失败了。以下是我的最小示例。虽然我不确定您是否可以正确编译它,因为它包含 CJK 字符。
%
% 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}
如果参数的数量固定为 3,我可以执行以下命令,
\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]}
有没有什么办法可以处理参数数量可变的情况? 如果需要编辑命令的定义\mulan
,那也可以。 提前谢谢大家。