BibTeX, biblatex and bibernatbib and subfiles packages

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

natbib and subfiles packages

Post by nich »

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

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

natbib and subfiles packages

Post by frabjous »

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:

Code: Select all

\usepackage{comment}
\excludecomment{thebibliography}
GregNash
Posts: 1
Joined: Sat Jan 22, 2011 11:56 pm

natbib and subfiles packages

Post by GregNash »

Packages cannot be declared in subfiles. My current solution is to add

Code: Select all

%\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

natbib and subfiles packages

Post by crowding »

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.

In your main file:

Code: Select all

\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}
In your chapter files:

Code: Select all

\documentclass[main]{subfiles}
\begin{document}
...
\biblio
\end{document}
AlexIgamberdiev
Posts: 1
Joined: Sun Aug 09, 2015 5:28 pm

Re: natbib and subfiles packages

Post by AlexIgamberdiev »

Awesome, it works perfectly, thank you!
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

natbib and subfiles packages

Post by Stefan Kottwitz »

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
LaTeX.org admin
Post Reply