我正在 Overleaf 中撰写博士论文,在使用子文件命令时遇到了参考书目问题。理想情况下,我希望在论文末尾有一个参考书目,而不是每个章节都有不同的参考书目。我应该在主文件中输入什么命令才能有一个参考书目?如果这不可行,那么我应该如何修改每个单独参考书目的命令,以便在编译 main.tex 时,在每章后打印一个参考书目。目前,主文件中没有读取参考书目,而只在子文件中读取。
文件路径如下:
主文本
论文/序言.tex
论文/paper1.tex
论文/paper1refs.bib
论文/paper2.tex
论文/paper2refs.bib
每个文件的结构如下:
主文本
\documentclass[12pt]{report}
\input{papers/preamble.tex}
\begin{document}
\chapter{Chapter1}
\clearpage \newpage
\subfile{papers/paper1.tex}
\chapter{Chapter2}
\clearpage \newpage
\subfile{papers/paper2.tex}
\end{document}
序言.tex
\usepackage{apacite}
\usepackage{subfiles}
纸张1.tex
\documentclass[../main.tex]{subfiles}
\begin{document}
This is the cite I want \cite{cite1}.
\clearpage \newpage
\bibliographystyle{apacite}
\phantomsection
\bibliography{paper1refs}
\end{document}
论文参考文献
@article{cite1,
title = {Citation1},
shorttitle = {Citation1},
author = {Author1, Author1},
year = {2022},
journal = {Journal1},
langid = {english}
}
paper2.tex
\documentclass[../main.tex]{subfiles}
\begin{document}
This is the cite I want \cite{cite2}.
\clearpage \newpage
\bibliographystyle{apacite}
\phantomsection
\bibliography{paper2refs}
\end{document}
paper2refs.bib
@article{cite2,
title = {Citation2},
shorttitle = {Citation2},
author = {Author2, Author2},
year = {2021},
journal = {Journal2},
langid = {english}
}
答案1
\bibliography
在主要部分添加一个命令,引用这两个bib
文件。在子文件中,
\ifSubfilesClassLoaded
仅当论文单独生成时才用于生成参考书目。\bibliographystyle{apacite}
顺便说一句,在序言中仅添加一次就足够了。
% main.tex
\documentclass[12pt]{report}
\input{papers/preamble}
\begin{document}
\chapter{Chapter1}
\clearpage \newpage
\subfile{papers/paper1}
\chapter{Chapter2}
\clearpage \newpage
\subfile{papers/paper2}
\bibliography{papers/paper1refs,papers/paper2refs}% <<<<<<<<<<<<<<<<<
\end{document}
% papers/preamble.tex
\usepackage{apacite}
\bibliographystyle{apacite}% <<<<<<<<<<<<<<<<<<<
\usepackage{subfiles}
% papers/paper1.tex
\documentclass[../main]{subfiles}
\begin{document}
This is the cite I want \cite{cite1}.
\clearpage \newpage
\ifSubfilesClassLoaded{% <<<<<<<<<<<<<<<
\bibliography{paper1refs}% <<<<<<<<<<<<<<
}{}% <<<<<<<<<<<<<<<<<<<<
\end{document}
% papers/paper2.tex
\documentclass[../main]{subfiles}
\begin{document}
This is the cite I want \cite{cite2}.
\clearpage \newpage
\ifSubfilesClassLoaded{% <<<<<<<<<<<<<<<<<
\bibliography{paper2refs}% <<<<<<<<<<<<<<<
}{}% <<<<<<<<<<<<<<<<<<<<
\end{document}