我一直在编写一份用两种语言编写的文件。英语和拉丁语。英语文本和拉丁文本讲的是同一件事,占用的页数也相同。
但是,我想将其编译为“二合一”的形式,即在奇数页上打印英文文本,并使用印度阿拉伯数字计数、章节的英文标签、“参考书目”的英文名称等,而在偶数页上打印拉丁文版本。这意味着在偶数页上,我希望使用罗马数字计数、使用拉丁文标记“Capitulum”等。现在,我已准备好两种格式。一种格式使用印度阿拉伯语和英文名称、标签等的花式风格进行编译,另一种格式使用罗马数字和拉丁语进行编译。这样就完成了。我找不到如何告诉 latex 在奇数页上使用印度阿拉伯语格式并阅读英文文本,而在偶数页上使用拉丁文格式和拉丁文页面。
我在这个社区里搜索,发现了很多格式化偶数页和奇数页的好例子,但没有一个与我的问题相似。也许有人可以告诉我去哪里检查。
先感谢您。
答案1
您可以使用 为奇数页和偶数页定义不同的页面样式fancyhdr
。
\documentclass[latin,english]{book}
\usepackage{babel}
\usepackage{Libertinus}
\usepackage{fancyhdr}
\usepackage{microtype}
\pagestyle{fancy}
\fancyhead[L]{\textsc{Cicero}}
\fancyhead[RE]{\textit{On the Ends of Good and Evil Things}}
\fancyhead[RO]{\textit{\foreignlanguage{latin}{De Finibus Bonorum et Malorum}}}
\fancyfoot[CE]{\arabic{page}}
\fancyfoot[CO]{\roman{page}}
\title{\textsc{De Finibus Bonorum et Malorum}}
\author{Cicero}
\date{}
\begin{document}
\maketitle
But I must explain to you how all this mistaken idea of reprobating pleasure
and extolling pain arose. To do so, I will give you a complete account of the
system, and expound the actual teachings of the great explorer of the truth,
the master-builder of human happiness. No one rejects, dislikes or avoids
pleasure itself, because it is pleasure, but because those who do not know
how to pursue pleasure rationally encounter consequences that are extremely
painful. Nor again is there anyone \textbf{who loves or pursues or desires to obtain
pain of itself, because it is pain,} but occasionally circumstances occur in which
toil and pain can procure him some great pleasure. To take a trivial example,
which of us ever undertakes laborious physical exercise, except to obtain
some advantage from it? But who has any right to find fault with a man who
chooses to enjoy a pleasure that has no annoying consequences, or one who
avoids a pain that produces no resultant pleasure?] On the other hand, we
denounce with righteous indignation and dislike men who are so beguiled and
demoralized by the charms of pleasure of the moment, so blinded by desire,
that they cannot foresee the pain and trouble that are bound to ensue; and
equal blame belongs to those who fail in their duty through weakness of will,
which is the same as saying through shrinking from toil and pain. These cases
are perfectly simple and easy to distinguish. In a free hour, when our power of
choice is untrammeled and when nothing prevents our being able to do what we
like best, every pleasure is to be welcomed and every pain avoided. But in
certain circumstances and owing to the claims of duty or the obligations of
business it will frequently occur that pleasures have to be repudiated and
annoyances accepted. The wise man therefore always holds in these matters
to this principle of selection: he rejects pleasures to secure other greater
pleasures, or else he endures pains to avoid worse pains.
\clearpage
\begin{otherlanguage}{latin}
Sed ut perspiciatis, unde omnis iste natus error sit voluptatem accusantium
doloremque laudantium, totam rem aperiam eaque ipsa, quae ab illo inventore
veritatis et quasi architecto beatae vitae dicta sunt, explicabo. Nemo enim
ipsam voluptatem, quia voluptas sit, aspernatur aut odit aut fugit, sed quia
consequuntur magni dolores eos, qui ratione voluptatem sequi nesciunt,
neque porro quisquam est, \textbf{qui do lorem ipsum, quia dolor sit amet}
consectetur adipisci[ng] velit, sed quia non numquam [do] eius modi tempora
inci[di]dunt, ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim
ad minima veniam, quis nostrum[d] exercitationem ullam corporis suscipit
laboriosam, nisi ut aliquid ex ea commodi consequatur? [D]Quis autem vel eum
iure reprehenderit, qui in ea voluptate velit esse, quam nihil molestiae
consequatur, vel illum, qui dolorem eum fugiat, quo voluptas nulla pariatur?
At vero eos et accusamus et iusto odio dignissimos ducimus, qui blanditiis
praesentium voluptatum deleniti atque corrupti, quos dolores et quas molestias
excepturi sint, obcaecati cupiditate non provident, similique sunt in culpa, qui
officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum
quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum
soluta nobis est eligendi optio, cumque nihil impedit, quo minus id, quod
maxime placeat, facere possimus, omnis voluptas assumenda est, omnis dolor
repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum
necessitatibus saepe eveniet, ut et voluptates repudiandae sint et molestiae
non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut
reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus
asperiores repellat.
\end{otherlanguage}
\end{document}
因为一旦分页算法没有按照您的预期运行,就会出错,所以您可能需要在防止分页的环境中排版每一页,例如minipage
。
在\begin{otherlanguage}
环境中,babel
将为您翻译字幕,例如“章节”。
如果不能严格交替,您可以定义自己的englishpage
和latinpage
环境来改变语言,也可以覆盖\fancyhead
和fancyfoot
。
\documentclass[latin,english]{book}
\usepackage{babel}
\usepackage{Libertinus}
\usepackage{fancyhdr}
\usepackage{microtype}
\pagestyle{fancy}
\fancyhead[L]{\textsc{Cicero}}
\fancyhead[R]{\textit{On the Ends of Good and Evil Things}}
\fancyfoot[C]{\arabic{page}}
\title{\textsc{De Finibus Bonorum et Malorum}}
\author{Cicero}
\date{}
\newenvironment{englishpage}%
{\selectlanguage{english}%
\fancyhead[R]{\textit{On the Ends of Good and Evil Things}}%
\fancyfoot[C]{\arabic{page}}}
{\clearpage}
\newenvironment{latinpage}%
{\selectlanguage{latin}%
\fancyhead[R]{\textit{De Finibus Bonorum et Malorum}}%
\fancyfoot[C]{\Roman{page}}}
{\clearpage}
\begin{document}
\maketitle
\begin{englishpage}
But I must explain to you how all this mistaken idea of reprobating pleasure
and extolling pain arose. To do so, I will give you a complete account of the
system, and expound the actual teachings of the great explorer of the truth,
the master-builder of human happiness. No one rejects, dislikes or avoids
pleasure itself, because it is pleasure, but because those who do not know
how to pursue pleasure rationally encounter consequences that are extremely
painful. Nor again is there anyone \textbf{who loves or pursues or desires to obtain
pain of itself, because it is pain,} but occasionally circumstances occur in which
toil and pain can procure him some great pleasure. To take a trivial example,
which of us ever undertakes laborious physical exercise, except to obtain
some advantage from it? But who has any right to find fault with a man who
chooses to enjoy a pleasure that has no annoying consequences, or one who
avoids a pain that produces no resultant pleasure?] On the other hand, we
denounce with righteous indignation and dislike men who are so beguiled and
demoralized by the charms of pleasure of the moment, so blinded by desire,
that they cannot foresee the pain and trouble that are bound to ensue; and
equal blame belongs to those who fail in their duty through weakness of will,
which is the same as saying through shrinking from toil and pain. These cases
are perfectly simple and easy to distinguish. In a free hour, when our power of
choice is untrammeled and when nothing prevents our being able to do what we
like best, every pleasure is to be welcomed and every pain avoided. But in
certain circumstances and owing to the claims of duty or the obligations of
business it will frequently occur that pleasures have to be repudiated and
annoyances accepted. The wise man therefore always holds in these matters
to this principle of selection: he rejects pleasures to secure other greater
pleasures, or else he endures pains to avoid worse pains.
\end{englishpage}
\begin{latinpage}
Sed ut perspiciatis, unde omnis iste natus error sit voluptatem accusantium
doloremque laudantium, totam rem aperiam eaque ipsa, quae ab illo inventore
veritatis et quasi architecto beatae vitae dicta sunt, explicabo. Nemo enim
ipsam voluptatem, quia voluptas sit, aspernatur aut odit aut fugit, sed quia
consequuntur magni dolores eos, qui ratione voluptatem sequi nesciunt,
neque porro quisquam est, \textbf{qui do lorem ipsum, quia dolor sit amet}
consectetur adipisci[ng] velit, sed quia non numquam [do] eius modi tempora
inci[di]dunt, ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim
ad minima veniam, quis nostrum[d] exercitationem ullam corporis suscipit
laboriosam, nisi ut aliquid ex ea commodi consequatur? [D]Quis autem vel eum
iure reprehenderit, qui in ea voluptate velit esse, quam nihil molestiae
consequatur, vel illum, qui dolorem eum fugiat, quo voluptas nulla pariatur?
At vero eos et accusamus et iusto odio dignissimos ducimus, qui blanditiis
praesentium voluptatum deleniti atque corrupti, quos dolores et quas molestias
excepturi sint, obcaecati cupiditate non provident, similique sunt in culpa, qui
officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum
quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum
soluta nobis est eligendi optio, cumque nihil impedit, quo minus id, quod
maxime placeat, facere possimus, omnis voluptas assumenda est, omnis dolor
repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum
necessitatibus saepe eveniet, ut et voluptates repudiandae sint et molestiae
non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut
reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus
asperiores repellat.
\end{latinpage}
\end{document}