我发现使用 LaTeX 模板有些困难,MasterDoctoralThesis
所以我开始创建一个新文档。我想在这里插入 APA 样式的引文。起初我无法使用此代码打印参考书目。LaTeX 显示“引文未定义”。有人能帮我解决错误并添加一行来指定 APA 样式的参考文献吗?提前谢谢!我对此非常紧张。
\documentclass[12pt]{report}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\graphicspath{ {Figures/} }
\usepackage{biblatex}
\addbibresource{references.bib}
\usepackage{float}
\usepackage{lipsum}
\usepackage{subfig}
\usepackage{adjustbox}
\usepackage{tabularx,booktabs}
\usepackage{mathtools}
\usepackage{array}
\usepackage{dcolumn}
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
%\newcolumntype{P}{>{\raggedright\arraybackslash}X}
\setlength\tabcolsep{2pt}
\captionsetup{
justification = centering
}
\usepackage{amsmath}
\usepackage{geometry}
\usepackage{booktabs}
\usepackage{xurl}
\usepackage{hyperref}
\DeclareMathOperator{\Pa}{Pa}
\newcolumntype{d}[1]{D{.}{.}{#1}}
\setlength\tabcolsep{2pt}
%
\title{
{Thesis Title}\\
{\large Institution Name}\\
{\includegraphics{university.jpg}}
}
\author{Author Name}
\date{Day Month Year}
\begin{document}
\chapter*{Abstract}
Blabla
\chapter*{Dedication}
Dedicated to my family and to my soulmate Davide.
\chapter*{Declaration}
\begin{itemize}
\item This work was done wholly or mainly while in candidature for a research degree at this University.
\item Where any part of this thesis has previously been submitted for a degree or any other qualification at this University or any other institution, this has been clearly stated.
\item Where I have consulted the published work of others, this is always clearly attributed.
\item Where I have quoted from the work of others, the source is always given. With the exception of such quotations, this thesis is entirely my own work.
\item I have acknowledged all main sources of help.
\item Where the thesis is based on work done by myself jointly with others, I have made clear exactly what was done by others and what I have contributed myself.\\
\end{itemize}
%\chapter*{Acknowledgements}
%I want to thank...
\tableofcontents
i'm trying to cite here but it doesn't works for me \cite{hoek1992modified}
\printbibliography
\end{document}
.bib
这是我的文件(称为)的一个示例references.bib
。
@inproceedings{hoek1992modified,
title={A modified Hoek--Brown failure criterion for jointed rock masses},
author={Hoek, E and Wood, D and Shah, S},
booktitle={Rock Characterization: ISRM Symposium, Eurock'92, Chester, UK, 14--17 September 1992},
pages={209--214},
year={1992},
organization={Thomas Telford Publishing}
答案1
好吧,假设您的 tex 代码名为mwe.tex
。然后我们在运行后根据您在问题中给出的代码获得pdflatex mwe
以下biber mwe
书目日志文件mwe.blg
:
[0] Config.pm:304> INFO - This is Biber 2.12
[0] Config.pm:307> INFO - Logfile is 'mwe.blg'
[35] biber-MSWIN64:315> INFO - ===
[66] Biber.pm:371> INFO - Reading 'mwe.bcf'
[171] Biber.pm:889> INFO - Found 1 citekeys in bib section 0
[188] Biber.pm:4093> INFO - Processing section 0
[207] Biber.pm:4254> INFO - Looking for bibtex format file 'mwe.bib' for section 0
[209] bibtex.pm:1523> INFO - LaTeX decoding ...
[213] bibtex.pm:1340> INFO - Found BibTeX data source 'mwe.bib'
[222] Utils.pm:209> ERROR - BibTeX subsystem: C:\Users\User\AppData\Local\Temp\43isMu1M0d\mwe.bib_4296.utf8, line 8, syntax error: at end of input, expected one of: name (entry type, key, field, or macro name) or end of entry ("}" or ")")
[222] Biber.pm:114> INFO - ERRORS: 1
如您所见,您给出的 bib 文件中存在错误。更确切地说,缺少}
bib 条目的结束符...hoek1992modified
因此,在添加缺失的括号后,我们得到了以下更正和最小化的 MWE(包filecontents
仅用于获取一个包含 TeX 和 bib 代码的 MWE;您需要不是使用它来工作!):
\begin{filecontents}{\jobname.bib}
@inproceedings{hoek1992modified,
title = {A modified Hoek--Brown failure criterion for jointed rock masses},
author = {Hoek, E and Wood, D and Shah, S},
booktitle = {Rock Characterization: ISRM Symposium, Eurock'92, Chester, UK, 14--17 September 1992},
pages = {209--214},
year = {1992},
organization = {Thomas Telford Publishing},
}
\end{filecontents}
\documentclass[12pt]{report}
\usepackage[utf8]{inputenc}
\usepackage{geometry}
\usepackage{biblatex}
\addbibresource{\jobname.bib}
\usepackage{xurl}
\usepackage{hyperref}
\begin{document}
i'm trying to cite here but it doesn't works for me \cite{hoek1992modified}
\printbibliography
\end{document}
及其产生的参考书目:
因此,请查看*.blg
您的文档文件并检查其中是否存在所提及的错误(我猜,有多个错误)。现在纠正 bib 文件中提到的所有错误...
请注意,扩展名是 Windows 的特殊扩展名,因此,如果您已经安装了编辑器,blg
请使用例如调用来打开文件...notepad++ mwe.blg
notepad++
要获得apa
样式,biblatex
您可以添加style=apa
选项biblatex
。请参阅以下 MWE(我使用 classarticle
仅在一页上包含引用和参考书目):
\begin{filecontents}{\jobname.bib}
@inproceedings{hoek1992modified,
title = {A modified Hoek--Brown failure criterion for jointed rock masses},
author = {Hoek, E and Wood, D and Shah, S},
booktitle = {Rock Characterization: ISRM Symposium, Eurock'92, Chester, UK, 14--17 September 1992},
pages = {209--214},
year = {1992},
organization = {Thomas Telford Publishing},
}
\end{filecontents}
\documentclass[12pt]{article}% report
\usepackage[utf8]{inputenc}
\usepackage{geometry}
\usepackage[%
style=apa, % <========================================================
backend=biber
]{biblatex}
\addbibresource{\jobname.bib}
\usepackage{xurl}
\usepackage{hyperref}
\begin{document}
i'm trying to cite here but it doesn't works for me \cite{hoek1992modified}
\printbibliography
\end{document}
及其结果: