## LaTeX forum ⇒ BibTeX, biblatex and biber ⇒ natbib and subfiles packages Topic is solved

Information and discussion about BiBTeX - the bibliography tool for LaTeX documents.
nich
Posts: 14
Joined: Fri Aug 13, 2010 8:22 am

### natbib and subfiles packages

Anyone know how I can get these two to work together.

Obviously I only want one reference list in my final document so I cant include an instruction to crease a bibliography in every subfile. But when I do not include the commands to crease a bibliography in each subfile I cant get the in text citations to show when I compile individual subfiles.

Thanks

Tags:

frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am
I don't have a lot of experience with the subfiles package, but one option that occurs to me would be to go ahead and include the bibliography in each subdocument, but use the comment package to suppress its output:

\usepackage{comment}\excludecomment{thebibliography}

GregNash
Posts: 1
Joined: Sat Jan 22, 2011 11:56 pm
Packages cannot be declared in subfiles. My current solution is to add
%\bibliographystyle{plain}%\bibliography{../References}

at the end of each subfile and to uncomment them when I'm compiling the individual subfiles.

Note that I use "../References" instead of "References" because my References.bib file is located in the parent directory.

crowding
Posts: 1
Joined: Wed Apr 20, 2011 3:46 am
Here via google, just worked out the answer to this one. Define something like \biblio to produce a bibliography in the individual files, but undefine it in the body of your main file.

\documentclass[...]{...}\usepackage{natbib}\usepackage{subfiles}...\def\biblio{\bibliographystyle{plainnat}\bibliography{bibliography}}\begin{document}\def\biblio{}...\subfile{chapter_1}\subfile{chapter_2}...\bibliographystyle{plainnat}\bibliography{bibliography}\end{document}

\documentclass[main]{subfiles}\begin{document}...\biblio\end{document}

AlexIgamberdiev
Posts: 1
Joined: Sun Aug 09, 2015 5:28 pm
Awesome, it works perfectly, thank you!

Stefan Kottwitz
Posts: 9550
Joined: Mon Mar 10, 2008 9:44 pm
Hi Alex,

welcome to the forum!

It's great to read, that it worked for you. Just to mention that, perhaps the challenge could be tackled with the modern biblatex package too.

Stefan