Tell me more ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

How do you produce a document with citations (\citep, \citet) working properly in the paper but without a bibliography at the end?

I've come up with one solution that is bad because it breaks my makefile.

latex file.tex
bibtex file
# comment out \bibliography{} command
latex file.tex

Similarly, is there a way to produce the bibliography with no accompanying text? Again, I've come up with a solution: fill an otherwise blank .tex file with \nocite{} commands. However, this is a pain because I have to keep two files synced by hand (and regular expressions to search for \citep{author1, author2} can be a huge pain when there are pagebreaks...).

share|improve this question
1  
why are you commenting out the \bibliography{} command? presumably you do have a .bib file, otherwise it makes no sense to have any \cite instructions. once bibtex has created a .bbl file from the .bib file, it doesn't matter whether the cite entries are put into the .aux file again. – barbara beeton Oct 12 '11 at 17:40

migrated from stackoverflow.com Oct 12 '11 at 17:09

5 Answers

up vote 10 down vote accepted

Your second request is easy: use \nocite{*}. This will produce a full bibliography, regardless of which bibliography entries are actually cited.

share|improve this answer
That's simple and accurate... a great answer. – keflavich Oct 12 '11 at 21:19

You can define a savebox and put the \bibliography command inside the savebox.

Here is a small example:

\RequirePackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{test,
author={Name},
title={TITLE},
year={2011},
}
\end{filecontents}
\documentclass{article}
\usepackage{natbib}
\bibliographystyle{plainnat}
\begin{document}
\cite{test}

\newsavebox\mytempbib
\savebox\mytempbib{\parbox{\textwidth}{\bibliography{test}}}

\end{document}

NOTE: If you are using biblatex you don't need such hacks.

EDIT

In relation to my answer I have a small question. What do you think about a small package which allows the user to print the bibliography or not?

Here my first try:

%% Copyright (C) 2011 by Marco Daniel
\ProvidesPackage{nobibprint}[2011/10/12 v0.1 nobibprint]
\RequirePackage{etoolbox}
\RequirePackage{xkeyval}
\define@boolkey{nobibprint.sty}[nobib@]{hide}{}
\ExecuteOptionsX{hide=true}
\ProcessOptionsX
\newsavebox\nobib@tempbox
\ifnobib@hide
   \AtBeginDocument{%
     \let\nobib@bibliography@orig\bibliography
     \def\bibliography#1{%
        \savebox\nobib@tempbox{%
           \parbox{\linewidth}{%
              \nobib@bibliography@orig{#1}%
            }%
        }%
      }%
   }
\fi
\endinput

Now simple use:

\usepackage{nobibprint}

or:

\usepackage[hide=true]{nobibprint}%default

or

\usepackage[hide=false]{nobibprint}
share|improve this answer
I certainly like the idea of the package, and will give it a shot. I don't think I understand saveboxes; will have to look those up. – keflavich Oct 12 '11 at 21:20
Amazing, but I still had to add \bibliographystyle{} before \bibliography{}. Otherwise, this is magical. – crippledlambda Oct 15 '12 at 20:08

If you put the \bibliography command in a file, say bibcommand.tex and in the main file you say

\documentclass{book}
...
%\includeonly{}
...

\begin{document}
<the document>

\include{bibcommand}

\end{document}

then a normal compilation will include the bibliography, but commenting out \includeonly{} will omit it.

You can also add the \includeonly{} from the shell

latex "\includeonly{}\input{filename}"

(where your main file is filename.tex) and this may be included in a Makefile, I believe.

share|improve this answer
So \includeonly{} forces the later \include command to be ignored? And using "latex [some latexcommand] filename" prepends the latex command to the file? Both very useful features, thanks. – keflavich Oct 12 '11 at 21:15
@egreg this was very useful, thanks! – Sosi May 9 at 17:47
@Sosi I'd like to acknowledge who first taught me this trick, but it was something I read in comp.text.tex several years ago. – egreg May 9 at 18:03

Simply use biblatex and its natbib compatibility option.

\documentclass{article}

\usepackage[style=authoryear,natbib=true]{biblatex}

\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@misc{A01,
  author = {Author, A.},
  year = {2001},
  title = {Alpha},
}
\end{filecontents}

\addbibresource{\jobname.bib}

\begin{document}

Some text \citep{A01}.

% \printbibliography

\end{document}
share|improve this answer

Your makefile can empty the *.bbl file. If you want to use Konrad's suggestion to separately compile the bibliography, you can try the following (untested):

file.dvi: file.tex
        latex file
        bibtex file
        mv -f file.bbl references.bbl; touch file.bbl
        latex file
        latex references

where references.tex is the Latex file that invokes \nocite{*}.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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