我正在使用 biber,想在 tikzpicture 中引用参考文献。我按照这个回答描述了如何使用 bibtex 来实现这一点,并且它运行良好,但是当切换到使用 biber 时,它不再起作用:
\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{newerpaper}B. Becker, \emph{Even Newer Stuff}, 2012.
\bibitem{newpaper}C. Charles, \emph{New Stuff}, 2011.
\bibitem{oldpaper}H. Huckley, \emph{Old Stuff}, 1900.
\end{thebibliography}
\end{document}
有谁知道有什么解决方案,而不需要我切换使用 bibtex?
更新:
正如下面几位作者所指出的,我发布的原始代码很容易修复。我发现的实际错误是由于我的 LaTeX 代码较大而导致的,我发现了这个问题。以下是存在问题的更新代码:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{external}
\tikzexternalize[prefix=fig/]
\usepackage[backend=biber]{biblatex}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{newerpaper,
author={B. Becker},
title={Even Newer Stuff},
date={2012}
}
@book{newpaper,
author={C. Charles},
title={New Stuff},
date={2011}
}
@book{oldpaper,
author={H. Huckley},
title={Old Stuff},
date={1900}
}
\end{filecontents}
\addbibresource{\jobname.bib}
\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}
问题出在命令上。我通过在 tikzpicture 之前和之后\tikzexternalize[prefix=fig/]
添加来解决这个问题。\tikzexternaldisable
\tikzexternalenable
答案1
正如评论中所建议的,您应该采用biblatex
的方式来处理参考书目,而不是手工处理。例如:
\documentclass{article}
\usepackage{tikz}
\usepackage[backend=biber]{biblatex}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{newerpaper,
author={B. Becker},
title={Even Newer Stuff},
date={2012}
}
@book{newpaper,
author={C. Charles},
title={New Stuff},
date={2011}
}
@book{oldpaper,
author={H. Huckley},
title={Old Stuff},
date={1900}
}
\end{filecontents}
\addbibresource{\jobname.bib}
\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}
其结果为:
编辑:事实证明,该问题本质上是biblatex
/的正确使用问题biber
,与 TikZ 关系不大,因此以下入门列表biblatex
可能会很方便:
- biblatex 简介(适合初学者)(Alan Munn 建议的链接)
- 如何切换到 biblatex
- bibtex 和 biblatex 有什么区别?
biblatex
的文档