\documentclass{article}
\usepackage[round]{natbib}
\newcommand{\footcite}[1]{\footnote{\cite{#1}}}
\begin{document}
This is text with \cite{Goossens}.
And\footcite{mozart:KV183}.
\bibliographystyle{plainnat}
\bibliography{\jobname.bib}
\end{document}
我这样做是为了将参考书目放在每页的页脚中。但只显示作者的姓氏或 (?)。我做错了什么?
答案1
filecontents
只需将我的 mwe 中的部分添加到您的旧部分即可问题上面的代码:
\RequirePackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@Book{Goossens,
author = {Goossens, Michel and Mittelbach, Frank and
Samarin, Alexander},
title = {The LaTeX Companion},
edition = {1},
publisher = {Addison-Wesley},
location = {Reading, Mass.},
year = {1994},
}
@Book{adams,
title = {The Restaurant at the End of the Universe},
author = {Douglas Adams},
series = {The Hitchhiker's Guide to the Galaxy},
publisher = {Pan Macmillan},
year = {1980},
}
article{einstein,
author = {Albert Einstein},
title = {{Zur Elektrodynamik bewegter K{\"o}rper}. ({German})
[{On} the electrodynamics of moving bodies]},
journal = {Annalen der Physik},
volume = {322},
number = {10},
pages = {891--921},
year = {1905},
DOI = {http://dx.doi.org/10.1002/andp.19053221004},
}
@misc{mozart:KV183,
author = {Mozart, Wolfgang Amadeus},
title = {Sinfonie g-Moll},
year = {1773},
address = {Salzburg},
note = {New K{\"o}chelverzeichnis Nr. 183, old version Nr. 25;
Erster Satz: Allegro con brio, Zweiter Satz: Andante,
Dritter Satz: Menuetto, Vierter Satz: Allegro},
}
\end{filecontents*}
mwe.bib
如果您使用文件内的代码,则会创建一个文件。这就是您在给定代码中mwe.tex
有行的原因:更改为,并且使用的 bib 文件也是如此。\bibliography{\jobname.bib}
\jobname
mwe
mwe.bib
完整代码:
\RequirePackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@Book{Goossens,
author = {Goossens, Michel and Mittelbach, Frank and
Samarin, Alexander},
title = {The LaTeX Companion},
edition = {1},
publisher = {Addison-Wesley},
location = {Reading, Mass.},
year = {1994},
}
@Book{adams,
title = {The Restaurant at the End of the Universe},
author = {Douglas Adams},
series = {The Hitchhiker's Guide to the Galaxy},
publisher = {Pan Macmillan},
year = {1980},
}
article{einstein,
author = {Albert Einstein},
title = {{Zur Elektrodynamik bewegter K{\"o}rper}. ({German})
[{On} the electrodynamics of moving bodies]},
journal = {Annalen der Physik},
volume = {322},
number = {10},
pages = {891--921},
year = {1905},
DOI = {http://dx.doi.org/10.1002/andp.19053221004},
}
@misc{mozart:KV183,
author = {Mozart, Wolfgang Amadeus},
title = {Sinfonie g-Moll},
year = {1773},
address = {Salzburg},
note = {New K{\"o}chelverzeichnis Nr. 183, old version Nr. 25;
Erster Satz: Allegro con brio, Zweiter Satz: Andante,
Dritter Satz: Menuetto, Vierter Satz: Allegro},
}
\end{filecontents*}
\documentclass{article}
\usepackage[round]{natbib}
\newcommand{\footcite}[1]{\footnote{\cite{#1}}}
\begin{document}
This is text with \cite{Goossens}.
And\footcite{mozart:KV183}.
\bibliographystyle{plainnat}
\bibliography{\jobname} % <===================================
\end{document}
请注意,您必须删除倒数.bib
第三行的文件扩展名:更改\bibliography{\jobname.bib}
为\bibliography{\jobname}
。然后代码就会编译。不要忘记编译pdflatex
, bibtex
, pdflatex
, pdflatex
。
结果是: