0

I am trying to add my bib files for my PhD dissertation and I am getting an error message that says I have an empty bibliography and citations are missing. I used the subfiles package to break up individual chapters and subchapters which is awesome! However, I would like to get the bibliography working so that my citations show up.

The current file structure for my project is as follows:

dissertation/
|-- Dissertation.tex
|-- Dissertation.cls
|-- makefile (Dissertation, release, clean)
|-- Release/
|   |-- Dissertation.pdf
|-- Chapter1/
|   |-- Intro1.tex
|   |-- Methods1.tex
|   |-- Results1.tex
|   |-- Discussion1.tex
|   |-- Conclusion1.tex
|   |-- Figures/
|       | -- Figure1.pdf
|       | -- Figure2.pdf
|       | -- Figure3.pdf
|   |-- bib_files/ 
|       | -- bib1.bib
|   |-- makefile (Chapter1, Intro1, Methods1, release, clean, etc.)
|   |-- Release/
|   |-- | -- Chapter1.pdf
|   |-- | -- Intro1.pdf
|   |-- | -- Methods1.pdf
|-- Chapter2/
|   |-- Intro2.tex
|   |-- Methods2.tex
|   |-- Results2.tex
|   |-- Discussion2.tex
|   |-- Conclusion2.tex
|   |-- bib_files/ 
|       | -- bib2.bib
|   |-- Figures/
|       | -- Figure1.pdf
|       | -- Figure2.pdf
|       | -- Figure3.pdf
|   |-- makefile (Chapter2, Intro2, Methods2, release, clean, etc.)
|   |-- Release/
|   |-- | -- Chapter2.pdf
|   |-- | -- Intro2.pdf
|   |-- | -- Methods2.pdf
|-- AppendixA/
|   |-- AppendixA.tex
|   |-- Code/
|       | -- code1.py
|       | -- code2.m
|       | -- code3.cc
|   |-- Data/
|       | -- Data1.csv
|       | -- Data2.csv
|       | -- Data3.csv

I have tried putting the following in my main.tex file:

% References
\addbibresource{./Chapter2/bib_files/bibliography.bib}
\addbibresource{./Chapter3/bib_files/bibliography.bib}
\addbibresource{./Chapter4/bib_files/bibliography.bib}

I have also tried putting these commands in the individual chapters and that didn't work either:

%%% -*-LaTeX-*-
\documentclass[../Dissertation]{subfiles}

\graphicspath{{Chapter2/Figures/}} % Graphics path for images
\addbibresource{./Chapter2/bib_files/bibliography.bib} % Chapter 2 references

\begin{document}
    
    % Needs to be capitalized (University Rules)
    \chapter{\uppercase{Chapter title here}}
    
    \hspace{\parindent}
    Experimental data measurement.
    
    \subfile{./Chapter2/0_Abstract}
    \subfile{./Chapter2/1_Introduction}
    \subfile{./Chapter2/2_Methods}
    \subfile{./Chapter2/3_Results}
    \subfile{./Chapter2/4_Discussion}
    \subfile{./Chapter2/5_Conclusion}
    \subfile{./Chapter2/6_Acknowledgment}
    
    % bibliography
    \printbibliography[segment=\therefsegment,heading=references]
    
\end{document}

However, each of these approaches was unsuccessful.

In my .cls file here is how I have defined the bibliography:

%----------------------------------------------------------------------%
%                               References
%----------------------------------------------------------------------%

\RequirePackage[defernums=true,
                hyperref,
                backref,
                backend=biber,
                style=ieee,
                natbib=true,
                refsegment=chapter,
                block=space
                ]{biblatex} % Use the bibtex backend, biber

\setlength\bibitemsep{1.5\itemsep} % Spacing between items in bilbiography

% Define typesetting of references heading
\defbibheading{references}[References]{% 
    \section{#1}% Add section so that the table of contents adds the chapter references
    \markboth{#1}{#1}%
    \singlespacing
}

%----------------------------------------------------------------------%
%                           Final Bibliography
%   Add type=book, article, online, thesis for specific references
%----------------------------------------------------------------------%

\def\finalBibliography{
    {\singlespacing
    \printbibliography[heading=bibintoc, title={\uppercase{Bibliography}}] % Whole
    }
}

At the very end of my main.tex I call my \finalBibliography to show all citations used.

I am also using Ubuntu to execute, compile, and output the final PDF here after a lot of help from previous posts with my final command being make file:

DISSERTATION = Dissertation
TEX = pdflatex -synctex=1 -interaction=nonstopmode --shell-escape 
BIBTOOLS = biber
OPEN = open -a Skim.app
RESOURCES = ${DISSERTATION}.pdf

# Executables
default:
    ${TEX} ${DISSERTATION}
    ${OPEN} ${DISSERTATION}

# Order of compiling (LaTeX --> biber -->  LaTeX --> LaTeX)
file:
    ${TEX} ${DISSERTATION}
    ${BIBTOOLS} ${DISSERTATION}
    ${TEX} ${DISSERTATION}
    ${TEX} ${DISSERTATION}

clean:  
    rm -rf auto *_minted-* *.log *.aux *.synctex.gz *.out *.toc *.run *.bcf *.lof *.lot *.tdo *.run.xml *.pdf
    
release:
    rm -rf Release
    mkdir Release
    cp *.pdf Release
    make clean

Here is the makefile for each individual chapter/section (Chapter2 specific):

CHAPTER = Chapter2
ABSTRACT = 0_Abstract
INTRODUCTION = 1_Introduction
METHODS = 2_Methods
RESULTS = 3_Results
DISCUSSION = 4_Discussion
CONCLUSION = 5_Conclusion
ACKNOWLEDGE = 6_Acknowledgment

# Tex commands
TEX = pdflatex -synctex=1 -interaction=nonstopmode --shell-escape 
BIBTOOLS = biber
OPEN = open -a Skim.app
RESOURCES = ${CHAPTER}.pdf

# Executables
default:
    ${TEX} ${CHAPTER}
    ${OPEN} ${CHAPTER}

clean:
    rm -rf auto *_minted-* *.log *.aux *.synctex.gz* *.out *.bcf *.run *run.xml *.pdf *.swo *.swp

release:
    rm -rf Release
    mkdir Release
    cp *.pdf Release
    make clean

chapter:
    ${TEX} ${CHAPTER}
    ${BIBTOOLS} ${CHAPTER}
    ${TEX} ${CHAPTER}
    ${TEX} ${CHAPTER}
    
file:   
    make chapter
    rm -rf Release
    mkdir Release
    cp ${RESOURCES} Release
    make clean

abstract:
    ${TEX} ${ABSTRACT}
    ${BIBTOOLS} ${ABSTRACT}
    ${TEX} ${ABSTRACT}
    ${TEX} ${ABSTRACT}

introduction:
    ${TEX} ${INTRODUCTION}
    ${BIBTOOLS} ${INTRODUCTION}
    ${TEX} ${INTRODUCTION}
    ${TEX} ${INTRODUCTION}
    
methods:
    ${TEX} ${METHODS}
    ${BIBTOOLS} ${METHODS}
    ${TEX} ${METHODS}
    ${TEX} ${METHODS}

results:
    ${TEX} ${RESULTS}
    ${BIBTOOLS} ${RESULTS}
    ${TEX} ${RESULTS}
    ${TEX} ${RESULTS}

discussion:
    ${TEX} ${DISCUSSION}
    ${BIBTOOLS} ${DISCUSSION}
    ${TEX} ${DISCUSSION}
    ${TEX} ${DISCUSSION}
    
conclusion:
    ${TEX} ${CONCLUSION}
    ${BIBTOOLS} ${CONCLUSION}
    ${TEX} ${CONCLUSION}
    ${TEX} ${CONCLUSION}

acknowledge:
    ${TEX} ${ACKNOWLEDGE}
    ${BIBTOOLS} ${ACKNOWLEDGE}
    ${TEX} ${ACKNOWLEDGE}
    ${TEX} ${ACKNOWLEDGE}

If you have any suggestions, that would be fantastic. The commands don't seem to execute the creation of the bibliography.

Here is a sample error output:

LaTeX Warning: Citation 'Kita_1992' on page 24 undefined on input line 146.


LaTeX Warning: Citation 'Kita_1990' on page 24 undefined on input line 152.

[24]) (./5_Conclusion.tex [25]) (./6_Acknowledgment.tex)

LaTeX Warning: Empty bibliography on input line 25.

[26] (./Chapter2.aux)

LaTeX Warning: There were undefined references.


Package biblatex Warning: Please (re)run Biber on the file:
(biblatex)                Chapter2
(biblatex)                and rerun LaTeX afterwards.

 )

After trying to only run the biber command to create the bibliography

BIBTOOLS = biber
bib:
    ${BIBTOOLS} ${DISSERTATION}

I am getting this error message and I'm not sure how to debug it:

biber Dissertation
INFO - This is Biber 2.14 (beta)
INFO - Logfile is 'Dissertation.blg'
ERROR - Cannot find 'Dissertation.bcf'!
INFO - ERRORS: 1
make: *** [Makefile:20: bib] Error 2
2
  • Leave the \addbibresource commands in the main preamble, but add \subfix around the path name, i.e., \addbibresource{\subfix{./Chapter2/bib_files/bibliography.bib}}. The preambles of the subfiles will only be processed when typesetting the subfile separately. – gernot Feb 27 at 21:36
  • I added the \subfix{...} inside of the \addbibresource and it still resulted in the same error message. – Christopher Creveling Feb 27 at 22:23
1

The exact location of your .bib files does not matter. Most sensible things that work in a 'normal' (non-subfiles) setup also work with subfiles, but you need to factor in the effect changes in working/compile directory have on relative paths.

You haven't shared a whole lot about your folder setup, so I will assume something that looks roughly like this

dissertation/
|-- main.tex
|-- chapter1/
|   |-- chap1.tex
|   \-- bib1.bib
|-- chapter2/
|   |-- chap2.tex
|   \-- bib2.bib

and that you compile your main file from dissertation as working directory and the chapters from their own directories (so cd chapter1, pdflatex chapter1, biber chapter1, pdflatex chapter1, pdflatex chapter1).

Then your main.tex should look roughly like this

\documentclass[british]{report}
\usepackage{subfiles}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{csquotes}

\usepackage[backend=biber, style=authoryear, refsegment=chapter,]{biblatex}

\addbibresource{\subfix{chapter1/bib1.bib}}
\addbibresource{\subfix{chapter2/bib2.bib}}

\begin{document}
\subfile{chapter1/chap1}
\subfile{chapter2/chap2}

\printbibliography[title={Complete \refname}]
\end{document}

and your subfiles like this

% chap1.tex
\documentclass[../main]{subfiles}

\begin{document}
\chapter{Lorem}
Lorem \autocite{sigfridsson}

\printbibliography[segment=\therefsegment, heading=subbibliography]
\end{document}

and

% chap2.tex
\documentclass[../main]{subfiles}

\begin{document}
\chapter{Dolor}
Dolor \autocite{nussbaum}

\printbibliography[segment=\therefsegment, heading=subbibliography]
\end{document}

The problem we have to work around is that file names are always resolved relative to where you invoke LaTeX/Biber. So when you compile main.tex in dissertation all file names are resolved relative to that directory, so the \addbibresource calls need to include the subdirectory names chapter1/ and chapter2/. But when you compile chap1.tex from chapter1, the relative path of the .bib file is not chapter1/bib1.bib, it is just bib1.bib. That's what \subfix does for us: It fixes the file path issue when the subfile is compiled on its own.


An alternative, but less elegant method would be to explicitly branch on whether or not we are typesetting the main or the subfile.

main.tex

\documentclass[british]{report}
\usepackage{subfiles}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{csquotes}

\usepackage[backend=biber, style=authoryear, refsegment=chapter,]{biblatex}

\ifSubfilesClassLoaded
  { }
  {
    \addbibresource{chapter1/bib1.bib}%
    \addbibresource{chapter2/bib2.bib}%
  }

\begin{document}
\subfile{chapter1/chap1}
\subfile{chapter2/chap2}

\printbibliography[title={Complete \refname}]
\end{document}

chapter1/chap1.tex

\documentclass[../main]{subfiles}

\addbibresource{bib1.bib}

\begin{document}
\chapter{Lorem}
Lorem \autocite{sigfridsson}

\printbibliography[segment=\therefsegment, heading=subbibliography]
\end{document}
7
  • I posted the file structure that I currently have as well as the two make files for the main (dissertation) and individual chapters. I think the only difference from the format that you posted is my bibliography bib files are in a separate folder titled "bib_files". Would I use the same format that you mentioned just adding the additional folder path? – Christopher Creveling Feb 28 at 20:12
  • @ChristopherCreveling As I say at the very beginning of the answer: The exact file path is irrelevant as long as the general approach is correct: Use \subfix to fix the relative file path. It works with \addbibresource{\subfix{chapter1/bib1.bib}} as in my example and should work the same with \addbibresource{\subfix{Chapter2/bib_files/bibliography.bib}}. Why don't you experiment a bit with \subfix and your file paths? – moewe Feb 28 at 20:59
  • That makes sense. I have updated my .tex files to reflect that change. I experimented with just trying to run the command biber Dissertation and that didn't seem to work which might be why I haven't been able to reference the .bib files mentioned above. I will add it to the end of the question. – Christopher Creveling Feb 28 at 21:22
  • @ChristopherCreveling As explained in tex.stackexchange.com/q/63852/35864 and alluded to in my answer to your other question (tex.stackexchange.com/q/584971/35864) you need to run a full compile cycle of LaTeX (i.e. pdfLaTeX, LuaLaTeX, XeLaTeX), Biber, LaTeX, LaTeX. Running just Biber on an empty directory is not going to be enough. – moewe Feb 28 at 21:26
  • Again, thank you for your help. After running each command separately I am able to get this to work with the citations in the proper order and referenced!, e.g. make file ---> make bib ---> make file ---> make file. I guess I'm not sure why my Makefile doesn't execute the order. It seems to stop after the first step. Maybe that should be my entire question instead? – Christopher Creveling Feb 28 at 21:52
0

Thank you for everyone's comments! Long story short everyone was right. However, what wasn't working was the Makefile to execute the commands.

Here was the previous Makefile:

# variables
FILE = Dissertation
TEX = pdflatex -synctex=1 -interaction=nonstopmode --shell-escape 
BIBTOOL = biber

tex:
    ${TEX} ${FILE}
bib:
    ${BIBTOOL} ${FILE}

I noticed that when I split up each command i.e. make tex followed by make bib then make tex and make tex it did work, but that was long and extensive to run.

After being pointed in the right direction the program latexmk is used to deal with compiling multiple times to ensure that the citations/figures/references, etc. are in the correct order. With that change to my Makefile, everything seems to be in good working order.

Here is the updated Makefile

# Linux Makefile to create a final pdf of the project

# Variables
FILE = PhD_Presentation

# PDF LaTeX specific
PDFLATEX = "pdflatex -interaction=nonstopmode -synctex=1 --shell-escape"

# You want latexmk to *always* run, because make does not have all the info.
# Also, include non-file targets in .PHONY so they are run regardless of any
# file of the given name existing.
.PHONY: ${FILE}.pdf all clean

# The first rule in a Makefile is the one executed by default ("make"). It
# should always be the "all" rule, so that "make" and "make all" are identical.
all: ${FILE}.pdf

# CUSTOM BUILD RULES

# In case you didn't know, '$@' is a variable holding the name of the target,
# and '$<' is a variable holding the (first) dependency of a rule.
# "raw2tex" and "dat2tex" are just placeholders for whatever custom steps
# you might have.

%.tex: %.raw
    ./raw2tex $< > $@

%.tex: %.dat
    ./dat2tex $< > $@

# MAIN LATEXMK RULE

# -pdf tells latexmk to generate PDF directly (instead of DVI).
# -pdflatex="" tells latexmk to call a specific backend with specific options.
# -use-make tells latexmk to call make for generating missing files.

# -interaction=nonstopmode keeps the pdflatex backend from stopping at a
# missing file reference and interactively asking you for an alternative.

# --shell-escape allows for *minted to run code highlighting

# -f forces latexmk to run until compiling has been complete regardless of
#  cross referencing (i.e. it continues to run until references are in the
#  correct location)

${FILE}.pdf: ${FILE}.tex
    latexmk -pdf -pdflatex=${PDFLATEX} -f -use-make ${FILE}.tex

# Clean up unnecessary files
clean:
    latexmk -C
    # specific to latexmk

clear:  
    rm -rf auto *_minted-* *.log *.aux *.synctex.gz *.out *.toc *.run *.bcf *.lof *.lot *.tdo *.run.xml *.pdf *.bbl *.blg *.nav *.snm

release:
    rm -rf Release
    mkdir Release
    cp *.pdf Release
    make clear
    make clean

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.