在序言中的文件末尾添加內容

在序言中的文件末尾添加內容

我創建了大量的 LaTeX 文檔,並將所有聲明放入我一開始header.tex使用的a 中。\input{header.tex}不過,我已將其遷移到 aheader.sty並立即使用\usepackage{header}

不管怎樣,我的文件總是包含相同的最後幾行,其中包括參考書目。我header.sty也想把它移到我的。有沒有辦法以某種方式將文件結尾內容加入到序言中?

我想到的程式碼是:

\IfFileExists{\bibliographyfile}{
    \printbibliography
}{}

\bibliographyfile已經在序言中定義了。

答案1

我想,請求的方式如下,自動載入header.sty文件中的所有內容。

\DefaultBibliographyStyle隨意更改。

\documentclass[12pt]{scrbook}
\usepackage{blindtext} % Not needed really


%%%% Content for `header.sty`
\newcommand*{\bibliographyfile}{biblio}%
\newcommand*{\DefaultBibliographyStyle}{alpha}%
\newcommand*{\DefaultBibFileExtension}{.bib}%

\AtEndDocument{%
\bibliographystyle{\DefaultBibliographyStyle}
\bibliography{\bibliographyfile}%
%
\IfFileExists{\bibliographyfile\DefaultBibFileExtension}{%
  \printbibliography%
}{}{}%
}%

%%%%%%%%%%% End stop copying it to the 'header.sty' file.


\begin{document}

\chapter{First}
\blindtext

\cite{Lam94} and \cite{GSM97} wrote fine books about \LaTeXe and other things.\par

\blindtext[5]

\end{document}

相關內容