1

Setup

I am using Rubber to compile my LaTeX document. In my root folder I have main.tex, mybib.bib (both coming from here) and Makefile.

main.tex

\documentclass[11pt]{article}
\usepackage{cite}

\begin{document}

\title{My Article}
\author{Nobody Jr.}
\date{Today}
\maketitle

Blablabla said Nobody ~\cite{Nobody06}.

\bibliography{mybib}{}
\bibliographystyle{plain}
\end{document}

mybib.bib

@misc{ Nobody06,
       author = "Nobody Jr",
       title = "My Article",
       year = "2006" }

Makefile

.PHONY: clean

LATEX_SRC=$(wildcard *.tex)
REFS=$(wildcard *.bib)

all: main.pdf

%.pdf: %.tex $(LATEX_SRC) $(REFS)
    mkdir -p build
    rubber --into build --short --pdf $<
    rubber-info --into build --check $<

clean:
    rm -rf build

Running make will complain that

running: bibtex main.aux...
[biblio] There were errors running bibtex.
build/main.aux:3: [bibtex] I couldn't open database file mybib.bib

Workaround

Replacing \bibliography{mybib}{} with \bibliography{../mybib}{} in main.tex is a valid workaround.

Question

Now, how do I get Rubber to tell BibTeX the correct folder? Both main.tex and myref.bib are arguments to rubber, so I'm not sure how BibTeX is not seeing the latter. My main.aux contains the line \bibdata{mybib}, which is causing the problem, and that's why adding the ../ to main.tex was giving a working solution, but I rather have a better understanding about how to use Rubber than patching its behaviour myself, since I believe I might be misusing it.

  • 2
    I don't use rubber but I doubt this is really rubber's problem. BibTeX is run on the generated .aux file and so looks for mybib.bib from the location of that .aux. Usually, you'd put your .bib file into your personal TEXMF tree rather than the working directory, which isn't very convenient for general usage, so this wouldn't be a problem. – cfr Jul 20 '16 at 0:40
  • 1
    I don't use rubber but the problem is your build directory: you are calling bibtex there and the aux is telling bibtex, that the bib is in the current directory. You can either call bibtex from the location of the bib with bibtex build/main.aux, or copy all files (including the tex and the bib) to the build directory before the compilation (imho the better way, compilations steps are easier to handle in the long run if everything is in the same folder). – Ulrike Fischer Jul 20 '16 at 9:43
  • @cfr: I was not aware one usually puts the bibliography in any special directory. Nevertheless, this is not an option, if your documents lives in a repository and it's expected to be self contained. @UlrikeFischer: as I said, I'm not running bibtex, rubber is. That's why I posted this question, i.e. how do I get rubber to call bibtex from the root directory? I'm not looking for "fixes", since I've already found one. I'm trying to understand why others don't have a similar issue, and what's their workflow and setup. Btw, thank you both for commenting. – Atcold Jul 20 '16 at 17:01
  • It seems to me that @UlrikeFischer and I have already suggested several ways in which others might not have this problem i.e. we've described common workflows and configurations which would work. – cfr Jul 20 '16 at 21:27
  • @cfr: Yes, I am thankful you both did. As I said, I was not aware of the personal TEXMF tree. And I know that removing the --into build option (i.e. having all files in the same directory) actually does not throw this issue. I wrote this question to understand whether I am misusing rubber, which is very likely, since I'm a newbie. I did not intend to sound arrogant; my apologies. – Atcold Jul 22 '16 at 14:00
1

Adding this line to the main LaTeX file does solve the issue.

% rubber: bibtex.path ../

Now BibTeX will know about the file structure of the project.

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.