21

A while ago I asked a meta question on how big a question can be. I was wondering in particular about breaking open REVTeX and reorganising the goo within to replace the natbib bits with bits that play more nicely with biblatex. This would surely be a large undertaking. Joseph Wright pointed out that

  • This is probably a bad idea (REVTeX produces a pretty funky bbl file and it's difficult to tell how important the internals of that are to the publisher).
  • A better question would be about getting biblatex to work when natbib is around too.

As the second point proposes a question of broader relevance than the one I originally intended to ask, and there is the possibility of a solution that would require much less effort than rewriting a class, I'm asking it here. Essentially I'd be using a solution just for my own notes, which often get remixed into papers in a REVTeX class, so for publication I'd have to default to the standard way. It's a start though! So:

Is it possible to load biblatex with a class that has already loaded natbib?

The first error can be produced with this MWE:

\documentclass[reprint,aps,pra]{revtex4-1}
\usepackage{biblatex}

\begin{document}
\title{MWE}
\author{Mark S.\ Everitt}
\pacs{}
\maketitle

\section{Introduction}
stuff

\end{document}

and the error is:

/usr/local/texlive/2011/texmf-dist/tex/latex/biblatex/biblatex.sty:382: LaTeX Error: Command \bibhang already defined.
           Or name \end... illegal, see p.192 of the manual.
2
  • I don't think that there's much to do about this, as RevTeX depends heavily on natbib features. There are 29 lines in revtex4-1.cls where a control sequence of the form \NAT@... appears and it seems quite complicated to correct things in such a way that biblatex can substitute natbib.
    – egreg
    Dec 4, 2011 at 16:40
  • @egreg: I think that you're as far as REVTeX goes. For other classes or packages that rely on natbib, it's going to have to be judged for each. I'm going to finally give up on this for now. :(
    – qubyte
    Dec 4, 2011 at 17:04

1 Answer 1

19

Working with the assumption here that we are simply trying to ignore natbib entirely, all that needs to happen is that the various name clashes need to be dealt with. Setting up a demo where natbib is deliberately loaded before biblatex, it seems that the macros \bibhang, \citename, \bibfont and \Citeauthor need to be undefined. At the same time, it's necessary to deal with \ver@natbib.sty, which is the internal macro LaTeX uses to track the fact that natibib has been loaded. It's this macro that biblatex uses in \@ifpackageloaded to issue a warning about natbib. Thus the following builds fine for me:

\begin{filecontents}{\jobname.bib}
@article{Test,
  journal = "J. Irrep. Res.",
  author  = "Other, A. N.",
  year    = "2011",
  title   = "Some things I did"
}
\end{filecontents}
\documentclass{article}
\usepackage{natbib}
% Start of 'ignore natbib' hack
\let\bibhang\relax
\let\citename\relax
\let\bibfont\relax
\let\Citeauthor\relax
\expandafter\let\csname ver@natbib.sty\endcsname\relax
% End of 'ignore natbib' hack
\usepackage{biblatex}
\addbibresource{\jobname.bib}
\begin{document}
\cite{Test}
\printbibliography
\end{document}

To get things working with REVTeX, I find that I also need to undefined \textcite. There is then a second issue, as REVTeX alters the definition of \MakeUppercase and \MakeLowercase. Thus I've copied the originals from latex.ltx and restored them:

\begin{filecontents}{\jobname.bib}
@article{Test,
  journal = "J. Irrep. Res.",
  author  = "Other, A. N.",
  year    = "2011",
  title   = "Some things I did"
}
\end{filecontents}
\documentclass{revtex4}
\let\bibhang\relax
\let\citename\relax
\let\bibfont\relax
\let\Citeauthor\relax
\let\textcite\relax
\makeatletter
\DeclareRobustCommand{\MakeUppercase}[1]{{%
      \def\i{I}\def\j{J}%
      \def\reserved@a##1##2{\let##1##2\reserved@a}%
      \expandafter\reserved@a\@uclclist\reserved@b{\reserved@b\@gobble}%
      \protected@edef\reserved@a{\uppercase{#1}}%
      \reserved@a
   }}
\DeclareRobustCommand{\MakeLowercase}[1]{{%
      \def\reserved@a##1##2{\let##2##1\reserved@a}%
      \expandafter\reserved@a\@uclclist\reserved@b{\reserved@b\@gobble}%
      \protected@edef\reserved@a{\lowercase{#1}}%
      \reserved@a
   }}
\makeatother
\expandafter\let\csname ver@natbib.sty\endcsname\relax
\usepackage{biblatex}
\addbibresource{\jobname.bib}
\begin{document}
\cite{Test}
\printbibliography
\end{document}

(The changes are actually to internal macros used by robust commands, so simply coping using \let before the document class line will not work here without some extra effort.)

For REVTeX 4.1, it seems you need

\renewcommand{\bibliography}[1]{}

after \begin{document} as REVTeX tries to use it at the end of the document, which gives an error with biblatex.

12
  • I've set this up as a minimal demo: the question seems to ask about the general case, and so I've gone for something less complex than REVTeX as a test case.
    – Joseph Wright
    Dec 4, 2011 at 15:20
  • This code works fine, but I still want to tackle REVTeX. I took your natbib hack and put it in between the documentclass and the usepackage. After a couple of extra undefines I hit a wall with the error Package biblatex Error: Patching \MakeUppercase failed. and a similar one for \MakeLowercase. Any ideas?
    – qubyte
    Dec 4, 2011 at 15:31
  • @MarkS.Everitt See my edit: I was just sorting that out!
    – Joseph Wright
    Dec 4, 2011 at 15:33
  • 3
    This all comes with a big health warning: I've no idea how it will work with the rest of REVTeX. It also reminds me I'm supposed to be sorting out some physics styles for biblatex!
    – Joseph Wright
    Dec 4, 2011 at 15:38
  • 1
    Just one more issue... You're using REVTeX4, and I'm using REVTeX4-1. There's unfortunately a fairly big difference.
    – qubyte
    Dec 4, 2011 at 15:40

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.