我敢打赌有很多循环使用外部处理,但我希望得到一个序言黑客,它将 pdflatex 输出三个输出 - 根据所选语言添加后缀 - 以下 MWE:
(我使用带有 AUCTeX 的 emacs,也许从那里定制命令更容易?)
% The following selects one langage. %
% What I _want_, is to automatically generate %
% from filename.tex three versions:
% one English output to filename_english.pdf %
% and one in "norsk" and one in "nynorsk" named accordingly
\newcommand{\mylanguage}% To select language,
% uncomment precisely _one_ of the following:
% {english}%
{norsk}%
% {nynorsk}%
\documentclass[a4paper,12pt,oneside,\mylanguage]{scrartcl}
\usepackage[english,nynorsk,norsk]{babel}
\usepackage[latin1]{inputenc}
\usepackage{ifthen}
{\protect\ifthenelse{\equal{\mylanguage}{english}}{\selectlanguage{english}}
{\ifthenelse{\equal{\mylanguage}{norsk}}{\selectlanguage{norsk}}
{\ifthenelse{\equal{\mylanguage}{nynorsk}}{\selectlanguage{nynorsk}}{}}}}
\newcommand{\ebn}[3]{\protect
\ifthenelse{\equal{\mylanguage}{english}}{#1}
{\ifthenelse{\equal{\mylanguage}{norsk}}{#2}
{\ifthenelse{\equal{\mylanguage}{nynorsk}}{#3}}}{}}
\newcommand{\en}[2]{\ebn{#1}{#2}{#2}}
% lots of other preamble comments go in here.
\begin{document}
\hfill \emph{\ebn{English}{Bokmål}{Nynorsk}}
\ebn{Show that if}{Vis at hvis}{Vis at viss} $n^2$ \en{is odd,
then}{er odde, er} $n$ \ebn{also is}{det også}{det òg}.
\end{document}
答案1
准备一个 shell 脚本,例如
pdflatex -jobname multinils-english "\def\mylanguage{english}\input{multinils}"
pdflatex -jobname multinils-norsk "\def\mylanguage{norsk}\input{multinils}"
pdflatex -jobname multinils-nynorsk "\def\mylanguage{nynorsk}\input{multinils}"
其中multinils.tex
代表你的 LaTeX 文件的名称。
\documentclass[a4paper,12pt,oneside,\mylanguage]{scrartcl}
\usepackage[english,nynorsk,norsk]{babel}
\usepackage[latin1]{inputenc}
\usepackage{ifthen}
{\protect\ifthenelse{\equal{\mylanguage}{english}}{\selectlanguage{english}}
{\ifthenelse{\equal{\mylanguage}{norsk}}{\selectlanguage{norsk}}
{\ifthenelse{\equal{\mylanguage}{nynorsk}}{\selectlanguage{nynorsk}}{}}}}
\newcommand{\ebn}[3]{\protect
\ifthenelse{\equal{\mylanguage}{english}}{#1}
{\ifthenelse{\equal{\mylanguage}{norsk}}{#2}
{\ifthenelse{\equal{\mylanguage}{nynorsk}}{#3}}}{}}
\newcommand{\en}[2]{\ebn{#1}{#2}{#2}}
% lots of other preamble comments go in here.
\begin{document}
\hfill \emph{\ebn{English}{Bokmål}{Nynorsk}}
\ebn{Show that if}{Vis at hvis}{Vis at viss} $n^2$ \en{is odd,
then}{er odde, er} $n$ \ebn{also is}{det også}{det òg}.
\end{document}
运行脚本将生成三个请求的 PDF 文件。