# Using \cite with biber inside tikzpictures

I'm using biber and want to cite references inside a tikzpicture. I followed this answer that described how to do it with bibtex and it works nicely, but when switching to use biber, it doesn't work anymore:

\documentclass{article}
\usepackage{tikz}

\usepackage[backend=biber]{biblatex}

\begin{document}

\begin{tikzpicture}[show/.style={circle,draw}]
\node[show]    (newpaper)    at    (0,2)
[label=right:{This 2011 paper ...}]
{\cite{newpaper}};
\node[show]    (oldpaper)   at     (0,0)
[label=right:{This paper came out in 1900 ...}]
{\cite{oldpaper}};
\draw[->]    (oldpaper) -- (newpaper);
\end{tikzpicture}

%\bibliographystyle{amsplain}
\begin{thebibliography}{10}
\bibitem{newpaper}C. Charles, \emph{New Stuff}, 2011.
\bibitem{oldpaper}H. Huckley, \emph{Old Stuff}, 1900.
\end{thebibliography}
\end{document}


Does anyone know of a solution without me having to switch to use bibtex?

UPDATE:

As noted by several below, my original code I posted was an easy fix. The actual bug I found was a result of my larger LaTeX code and I found the issue. Here's the updated code that has the issue:

\documentclass{article}
\usepackage{tikz}

\usetikzlibrary{external}
\tikzexternalize[prefix=fig/]

\usepackage[backend=biber]{biblatex}

\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
author={B. Becker},
date={2012}
}

@book{newpaper,
author={C. Charles},
title={New Stuff},
date={2011}
}

@book{oldpaper,
author={H. Huckley},
title={Old Stuff},
date={1900}
}

\end{filecontents}

\begin{document}

%\tikzexternaldisable
\begin{tikzpicture}[show/.style={circle,draw}]
\node[show]    (newpaper)    at    (0,2)
[label=right:{This 2011 paper ...}]
{\cite{newpaper}};
\node[show]    (oldpaper)   at     (0,0)
[label=right:{This paper came out in 1900 ...}]
{\cite{oldpaper}};
\draw[->]    (oldpaper) -- (newpaper);
\end{tikzpicture}
%\tikzexternalenable

\printbibliography

\end{document}


The problem is with the \tikzexternalize[prefix=fig/] command. I got around this issue by adding \tikzexternaldisable before the tikzpicture and \tikzexternalenable after the tikzpicture.

• At first glance, it seems to me it may well be working and the problem has nothing to do with the tikz drawings, but with the fact that you are supplying bibtex entries. Did you try to put these references in a .bib file and inputing it with addbibresource? – gusbrs Jul 12 '17 at 19:02
• You say you're using biblatex but your bibliography is done by hand? If' you're really doing things by hand, then don't use biblatex. If you're really using biblatex delete your hand-done bibliography and replace it with \printbibliography , tell biblatex where to find your .bib file (using \addbibresource) and let biblatex do the work. See biblatex in a nutshell (for beginners). – Alan Munn Jul 12 '17 at 19:03
• The answer you link to is a bit misleading, since it uses a manually created bibliography just for the example. Nobody would likely ever do exactly that in practice. – Alan Munn Jul 12 '17 at 19:07
• Thanks everyone, I actually was using a separate bib file, but to illustrate the problem I took that example from the link I gave. It turns out my problem has to do with tikzexternalize. I updated my post to note this and I included one possible solution... I'm not sure if it's the correct one. – t2k32316 Jul 12 '17 at 20:10
• Well, you updated your question in a direction which seems different from the original one. Anyway, in your update, what's the point of loading \usetikzlibrary{external} if you are "getting around it" with \tikzexternaldisable in the only tikz drawing you have? – gusbrs Jul 12 '17 at 20:16

As suggested in the comments, you should move to biblatex's way of dealing with the bibliography, rather than doing it by hand. E.g.:

\documentclass{article}
\usepackage{tikz}

\usepackage[backend=biber]{biblatex}

\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
author={B. Becker},
date={2012}
}

@book{newpaper,
author={C. Charles},
title={New Stuff},
date={2011}
}

@book{oldpaper,
author={H. Huckley},
title={Old Stuff},
date={1900}
}

\end{filecontents}

\begin{document}

\begin{tikzpicture}[show/.style={circle,draw}]
\node[show]    (newpaper)    at    (0,2)
[label=right:{This 2011 paper ...}]
{\cite{newpaper}};
\node[show]    (oldpaper)   at     (0,0)
[label=right:{This paper came out in 1900 ...}]
{\cite{oldpaper}};
\draw[->]    (oldpaper) -- (newpaper);
\end{tikzpicture}

\printbibliography

\end{document}


Which produces:

Edit: As it turned out, the issue is essentially one of the correct use of biblatex/biber, and has little to do with TikZ, so a list of starters with biblatex could be handy:

• +1 And just to be clear to the OP, including the .bib file in your document with {filecontents} is not the way you would do it on a daily basis, but is included for the purposes of making a self-contained example. In normal practice you would have a separate .bib file which you maintain separately, ideally using an external tool like JabRef (multiplatform) or BibDesk (Mac). – Alan Munn Jul 12 '17 at 19:32
• Indeed, well remembered. I tried to keep it simple in the hope the link you supplied will get the OP started. – gusbrs Jul 12 '17 at 19:34
• @AlanMunn, I complemented the answer in the spirit of your comment. – gusbrs Jul 12 '17 at 19:50