我正在写我的硕士论文,并采用 APA 格式引用。下面是它现在的样子:
虽然总体上看起来不错,但我想修改年份并将其放在括号中。此外,删除作者后面的逗号,但保留年份后面的逗号,以便最终版本如下所示:
Ruoff 等人(1953),页16
因为我复制了代码以使其接近最终版本,所以我不知道如何进一步修改它以使其达到想要的形式。
我在序言中给出的代码如下:
\documentclass[12pt]{report}
\usepackage{natbib}
\makeatletter
\newcommand*{\ibid}{Ibid.}
\let\@predcite\@empty
\let\@currcite\@empty
\def\citef{\kernel@ifnextchar[\citef@{\citef@[]}}
\def\citef@[#1]{\kernel@ifnextchar[{\citef@@[{#1}]}{\citef@@[][{#1}]}}
\def\citef@@[#1][#2]#3{%
\def\@currcite{#3}%
\unskip
\ifx\@currcite\@predcite
\footnote{#1 \ifx\tempa\@empty\unskip\fi%
\ibid\ifx\tempb\@empty\else\NAT@cmt #2\fi}%
\else%
\footnote{\citealp[#1][#2]{#3}}%
\fi
\gdef\@predcite{#3}%
}
\makeatother
\bibliographystyle{apalike}
此外,我在文中引用了这样的内容(这是针对上图所示的例子):
\citef[p. 16]{ruoff53}
提前感谢您的建议。非常感谢您的帮助!
编辑:
根据 Bernard 的提示,我现在得到了以下代码:
您能给我进一步的提示吗?我将正文内容修改为以下内容,但看起来有点乱……
\documentclass[12pt]{report}
\setcounter{tocdepth}{4}
\setcounter{secnumdepth}{4}
\usepackage[utf8]{inputenc}
\usepackage{natbib}
\usepackage[american]{babel}
\usepackage{csquotes}
\usepackage[style=apa,backend=biber]{biblatex}
\DeclareLanguageMapping{american}{american-apa}
\addbibresource{biblio.bib}
\usepackage{rotating}
\makeatletter
\newcommand*{\ibid}{Ibid.}
\let\@predcite\@empty
\let\@currcite\@empty
\def\citef{\kernel@ifnextchar[\citef@{\citef@[]}}
\def\citef@[#1]{\kernel@ifnextchar[{\citef@@[{#1}]}{\citef@@[][{#1}]}}
\def\citef@@[#1][#2]#3{%
\def\@currcite{#3}%
\unskip
\ifx\@currcite\@predcite
\footnote{#1 \ifx\tempa\@empty\unskip\fi%
\ibid\ifx\tempb\@empty\else\NAT@cmt #2\fi}%
\else%
\footnote{\citealp[#1][#2]{#3}}%
\fi
\gdef\@predcite{#3}%
}
\makeatother
\begin{document}
\chapter{Introduction}
\input{ma_chapters/introduction}
.
.
.
.
\bibliographystyle{apalike}
\bibliography{biblio}
答案1
apalike
假设您对参考书目样式、natbib
引文管理包和 BibTeX 总体满意,您可以创建一个新的宏来实现您想要的引文标注格式。
\newcommand\mycite[2][]{\citeauthor{#2}\ (\citeyear{#2})\ifx#1\undefined\else, #1\fi}
如果未指定第一个可选参数,则之后不会打印任何内容\citeyear{#2}
;实际上,如果没有提供可选参数,\mycite
则行为就像\citet
会一样。
\documentclass[12pt]{report}
\usepackage{filecontents}
\begin{filecontents}{biblio.bib}
@article{ruoff,
author = "A. Ruoff and B. Woof and C. Zoot",
title = "Thoughts",
journal= "Circularity Today",
year = 1953,
}
\end{filecontents}
\usepackage{natbib}
\bibliographystyle{apalike}
\newcommand\mycite[2][]{%
\citeauthor{#2}\ (\citeyear{#2})\ifx#1\undefined\else, #1\fi}
\begin{document}
\mycite[p.~16]{ruoff} % with optional argument
\mycite{ruoff} % without optional argument -- no comma is printed
\citet{ruoff} % compare with output of "\citet"
\bibliography{biblio}
\end{document}
附录:要将这些引用标注放在脚注中,您可以使用宏,例如\myfootcite
,定义如下:
\newcommand\myfootcite[2][]{\footnote{\mycite[#1]{#2}.}}
如果您不想在脚注材料末尾使用句号(“句号”),只需省略之后.
的{#2}
。
第二附录,以满足 OP 对引用宏的请求,该引用宏打印出“同上。”如果最新条目与前面的引用命令中的条目相同:
与之前的解决方案相比,只需添加一个测试,以判断当前引用的键是否与上一个引用中使用的键相同。以下代码提供了两个用户宏:\tcite
,用于文内引用,\fcite
,用于脚注内引用。
\documentclass[12pt]{report}
\usepackage[textheight=2in]{geometry} %% just for this example
\usepackage{filecontents}
\begin{filecontents}{biblio.bib}
@article{ruoff,
author = "A. Ruoff and B. Woof and C. Zoot",
title = "Thoughts",
journal= "Circularity Today",
year = 1953,
}
@article{abc,
author = "Anna Andersen and Bertha Branson and Carla Carlsson",
title = "Further Thoughts",
journal= "Circularity Today",
year = 2053,
}
\end{filecontents}
\usepackage{natbib}
\bibliographystyle{apalike}
\def\prevcite{} % initialize \prevcite
%% macro for in-text citation
\newcommand\tcite[2][]{%
\def\newcite{#2}
\ifx\prevcite\newcite
Ibid.%
\else%
\gdef\prevcite{#2}% update \prevcite
\citeauthor{#2}\ (\citeyear{#2})%
\fi
\ifx#1\undefined\else, #1\fi}
%% macro for in-footnote citation
\newcommand\fcite[2][]{\footnote{\tcite[#1]{#2}}}
\begin{document}
bla bla\fcite{ruoff}
more bla bla\fcite[p.~75]{ruoff}
still more bla bla\fcite[p.~101]{abc}
further bla bla\fcite{abc}
final bla bla\fcite[p.~999]{abc}
\bibliography{biblio}
\end{document}
答案2
一种处理事情的方式biblatex-apa
。您可以使用以下选项模拟 natbib 命令natbib
:
\documentclass[12pt]{report}
\usepackage[utf8]{inputenc}
\usepackage[american]{babel}
\usepackage{csquotes}
\usepackage[style=apa, backend=biber, natbib]{biblatex}
\DeclareLanguageMapping{american}{american-apa}
\addbibresource{biblio.bib}
\usepackage{filecontents}
\begin{filecontents}{biblio.bib}
@article{ruoff,
author = "A. Ruoff and B. Woof and C. Zoot",
title = "Thoughts",
journal= "Circularity Today",
year = 1953,
}
\end{filecontents}
\renewcommand*{\nameyeardelim}{\addspace}
%
\usepackage{xpatch}
\makeatletter
\newbibmacro*{cite}{%
\iffieldequals{namehash}{\cbx@lasthash}
% Multiple cites in one command
{\setunit{\compcitedelim}%
\usebibmacro{cite:plabelyear+extrayear}}%
% \bibcloseparen%
% Single cite
{\ifthenelse{\ifnameundef{labelname}\OR\iffieldequalstr{entrytype}{patent}}
% No author/editor
{\usebibmacro{cite:noname}%
\setunit{\ifbool{cbx:np}%
{\nameyeardelim}%
{\global\booltrue{cbx:parens}\addspace\bibopenparen}}%
\usebibmacro{cite:plabelyear+extrayear}%
\bibcloseparen%
\savefield{namehash}{\cbx@lasthash}}
% Normal cite
{\ifnameundef{shortauthor}
{\printnames[labelname][-\value{listtotal}]{labelname}}%
{\cbx@apa@ifnamesaved
{\printnames{shortauthor}}
{\printnames[labelname][-\value{listtotal}]{author}\addspace\printnames[sabrackets]{shortauthor}}}%
\setunit{\ifbool{cbx:np}%
{\nameyeardelim}%
{\global\booltrue{cbx:parens}\addspace\bibopenparen}}%
\usebibmacro{cite:plabelyear+extrayear}%
\bibcloseparen%
\savefield{namehash}{\cbx@lasthash}}}%
\setunit{\multicitedelim}}
\makeatother
\begin{document}
\chapter{Introduction}
\cite[p.~16]{ruoff} % with optional argument
\textcite{ruoff} % without optional argument -- no comma is printed
\citet{ruoff} % compare with output of "\citet"
\printbibliography
\end{document}