GeneralBibliography & Subfiles

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
RensR
Posts: 10
Joined: Wed Jan 14, 2015 2:55 pm

Bibliography & Subfiles

Post by RensR »

Hi,

I am trying to incorporate a bilbiography with the use of subfiles, but I don't get it to work the way I want to.
A summary of what I want is to work in subfiles, where I can use the \cite{} command to cite a reference from Bibliography.bib. However, I don't get it to work properly. I am probably forgetting something very obvious, but I don't seem to see what. What I have is (in short)

Report.tex

Code: Select all

\documentclass{report}
\usepackage{a whole lot of them, including the subfiles package}

\begin{document}
\a custom title page

\abstract, table of contents, this works fine as it should

\subfile{Theory/Theory.tex}
\subfile{Results/Results.tex}

\bibliographystyle{ieeetr}
\bibliography{References/Bibliography.bib}

\appendix
\subfile{Appendix/AppendixA.tex}

\end{document}
And in, for example Theory/Theory.tex:

Code: Select all

\documentclass[../Report.tex]{subfiles}
\graphicspath{Theory/}
\begin{document}
\chapter{Theory}
\section{Theory section 1}
This is a test to see if this citation works \cite{Brink}.
\end{document} 
And then in References/Bibliography.bib:

Code: Select all

\begin{thebibliography}{10}
\bibitem{Brink}
    Derperdiederp Brink,
    \emph{Electric thingies},
    Master Thesis, University of something, 2012.
\end{thebibliography}
Does anyone know what I am missing? I tried to find it using google, but could not find a solution that was specific enough to work for me.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Bibliography & Subfiles

Post by Johannes_B »

I think you are making two mistakes.
1) If you have done the bibliography by hand, neither bibliographystyle nor bibliography do anything useful. You have to simply input you bibliography like any other tex-document.
2) Doing it by hand. Why don't you use a proper tool that saves you some serious time in the long run? I suggest to have a look at biblatex and biber.

Code: Select all

\begin{filecontents}{\jobname-A.tex}
	\documentclass[../Report.tex]{subfiles}
	\begin{document}
	\chapter{Theory}
	\section{Theory section 1}
	This is a test to see if this citation
	works \cite{Brink}.
	\end{document} 
\end{filecontents}
\begin{filecontents}{\jobname-B.tex}
	\begin{thebibliography}{10}
		\bibitem{Brink}
			Derperdiederp Brink, \emph{Electric thingies},
			Master Thesis, University of something, 2012.
	\end{thebibliography}
\end{filecontents}
\documentclass{report}
\usepackage{subfiles}

\begin{document}
\subfile{\jobname-A.tex}
\input{\jobname-B}

\end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
RensR
Posts: 10
Joined: Wed Jan 14, 2015 2:55 pm

Re: Bibliography & Subfiles

Post by RensR »

I still don't get it. I want this:
A main file, in which I include the packages, a cover page, an abstract and a table of content. Then only things like (but give me the best option) \include or \subfile or anything.

Then I want a bunch of secondary files, which I can run individually to produce a pdf and where the quotations actually work.

The bibliography file (I don't care what style it is, as long as it works properly) should a) put all the used literature in the correct order (so when I run main.tex, it should automatically look at the order in the subfiles) and b) leave out any literature I did not use.

I hope anyone can give me a clear explanation of what to put in which file. Please say what goes where, or I won't get it I think.
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Re: Bibliography & Subfiles

Post by Johannes_B »

In your very first example above, you are doing the bibliography by hand. All items you include, will be typeset. I asked why, at this is hard to maintain.
The better and more comfortable appraoch is to have a database with all the bibliographic data.

Your subfiles business should work as expected, it does in my example above. To keep it simple for helpers, i merged it all into one single file.

Please copy it to a new directory and run the code. Various files should be created. Please have a look at them, it is basically the same you posted before.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
RensR
Posts: 10
Joined: Wed Jan 14, 2015 2:55 pm

Bibliography & Subfiles

Post by RensR »

Okay, I think I get it. In the main file (report.tex) I put this then:

Code: Select all

\documentclass{report}
\usepackage{subfiles}

\begin{document}
\subfile{\jobname-A.tex}
\input{\jobname-B}

\end{document}
with all other packages and subfiles I need.
The jobname-A.tex could then be, for example Theory.tex which would look like

Code: Select all

\begin{filecontents}{\jobname-A.tex}
        \documentclass[../Report.tex]{subfiles}
        \begin{document}
        \chapter{Theory}
        \section{Theory section 1}
        This is a test to see if this citation
        works \cite{Brink}.
        \end{document} 
\end{filecontents}
And then the bibliography is called jobname-B.tex and looks like

Code: Select all

\begin{filecontents}{\jobname-B.tex}
        \begin{thebibliography}{10}
                \bibitem{Brink}
                        Derperdiederp Brink, \emph{Electric thingies},
                        Master Thesis, University of something, 2012.
        \end{thebibliography}
\end{filecontents}
Is this right?
Then I want to ask, you are saying I am doing the bibliography by hand and should rather use something like BibTex. When I click the link, I just get a number of files, in which I honestly don't know where to look. I am not an expert on LaTeX, as you probably know by now, but please make clear what I have to put in my tex files to make this work. It will probably take me hours if not days of frustration to sort this out otherwise...
Last edited by Stefan Kottwitz on Wed Feb 25, 2015 2:55 pm, edited 1 time in total.
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Bibliography & Subfiles

Post by Johannes_B »

Hi,

sorry, i didn't make myself clear. The filecontents-environment is just for example. Please don't use that in your working files.

In LaTeX for complete novices, Nicola Talbot describes the handmade solution to bibliographies, in the later work, Using LaTeX to Write a PhD Thesis, she describes the automatic approach using a database. You can find many more stuff for novices and experienced users in their.

Please read the linked basics on bibliographies first. I don't want to copy everything in here ;-)
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
RensR
Posts: 10
Joined: Wed Jan 14, 2015 2:55 pm

Re: Bibliography & Subfiles

Post by RensR »

Thank you, the explanation on the website you gave is very clear and the bibliography now works the way I wanted it to work. The JabRef programm is really nice.
Post Reply