I want to write a long document therefore I will split it in several files and use the package standalone
to import them. I also want to add epigraphs before the chapters names, thus I use the package epigraph
and the command \epigrahhead
as recommended in the documentation and in the following example.
But with this combination, the last epigraph printed is the one of the first chapter.
Here is an example:
\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}
So I wonder why there is this unexpected results ?
EDIT
Thanks to the answer given by egreg, it seems that commenting the first epigraph only implies a different behaviour:
\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.