我想写一篇长文档,因此我将把它分成几个文件,然后使用包standalone
导入它们。我还想在章节名称前添加题词,因此我按照文档和以下内容中的建议使用包epigraph
和命令\epigrahhead
例子。
但在这种组合下,最后印刷的题词是第一章的题词。
以下是一个例子:
\documentclass[a4paper]{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{epigraph}
\usepackage{standalone}
\usepackage{filecontents}
\begin{filecontents}{chapter2.tex}
\documentclass[a4paper]{book}
\usepackage[T1]{fontenc}
\usepackage{epigraph}
\begin{document}
\chapter{Chapter title}
\epigraphhead[20]{
\epigraph{\itshape Computer programming is an art, because it applies
accumulated knowledge to the world, because it requires skill and ingenuity,
and especially because it produces objects of beauty.
}{Donald Knuth, \textit{"Computer Programming as an Art". Communications of the ACM, Volume 17, Issue 12, dl.acm.org., December 1974}}
}
\section{section title}
Text again.
\chapter{Last chapter}
\epigraphhead[20]{
\epigraph{Last epigraph}{ Probably someone}
}
\section{Last section}
Last text.
\end{document}
\end{filecontents}
\begin{document}
\chapter{CHAPTER}
\epigraphhead[20]{%
\epigraph{Poor cultural foundations were a significant
driver of the 2008–2009 financial crisis(in common
with many past crises). Behaviors that do not meet
banks’ desired values and conduct continue to be a
problem.}{Group of Thirty (2015), p. 18}
}
\section{SECTION}
Text.
\input{./chapter2.tex}
\end{document}
所以我想知道为什么会出现这种意外的结果?
编辑
感谢 egreg 给出的回答,看来评论第一个题词只意味着不同的行为:
\chapter{CHAPTER}
%\epigraphhead[20]{%
% \epigraph{Poor cultural foundations were a significant
% driver of the 2008–2009 financial crisis(in common
% with many past crises). Behaviors that do not meet
% banks’ desired values and conduct continue to be a
% problem.}{Group of Thirty (2015), p. 18}
%}
\section{SECTION}
Text.
答案1
问题是,当standalone
生效时,所排版的内容(例如当您\input{chapter2.tex}
)是成组进行的。
使用epigraph
,题词的文本被存储在临时控制序列 `@epitemp 中,并对页面样式进行一些调整。
对于非常短的最后一章,输入文件在章节页面发出之前就结束了,因此组结束,并且 的值\@epitemp
恢复到 之前的值\input
。因此,您会得到 之前的最后一段题词\input
。
加\clearpage
于短篇章末。
\begin{filecontents}{chapter2.tex}
\documentclass[a4paper]{book}
\usepackage[T1]{fontenc}
\usepackage{epigraph}
\begin{document}
\chapter{Chapter title}
%\epigraphhead[20]{
% \epigraph{\itshape Computer programming is an art, because it applies
% accumulated knowledge to the world, because it requires skill and ingenuity,
% and especially because it produces objects of beauty.
% }{Donald Knuth, \textit{``Computer Programming as an Art''.
% Communications of the ACM, Volume 17, Issue 12, dl.acm.org., December 1974}}
%}
\section{section title}
Text again.
\clearpage
\chapter{Last chapter}
\epigraphhead[20]{
\epigraph{Last epigraph}{Probably someone}
}
\section{Last section}
Last text.
\clearpage % <----- HERE
\end{document}
\end{filecontents}
\documentclass[a4paper]{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{epigraph}
\usepackage{standalone}
\begin{document}
\chapter{CHAPTER}
\epigraphhead[20]{%
\epigraph{Poor cultural foundations were a significant
driver of the 2008–2009 financial crisis(in common
with many past crises). Behaviors that do not meet
banks’ desired values and conduct continue to be a
problem.}{Group of Thirty (2015), p. 18}
}
\section{SECTION}
Text.
\input{./chapter2.tex}
\end{document}