我正在尝试使用 bibtex+natbib 来处理我论文中的引文。有些引文符合风格\citet{author_year}
,并且工作正常。
但是,当我使用时\citet[pXX]{author_year}
,我得到的是 Author (Year, pXX) 而不是所需的 Author (Year), pXX
我如何才能通过页码等附加信息实现第二种引用所需的样式?
根据@Audrey 的第一个回答,我制作了这个 MWE:
%this documents is compiled with xetex
\documentclass[11pt,british,english,ngerman,footnotes=multiple]{scrreprt}
\usepackage{fontspec}
\usepackage[a4paper]{geometry}
\geometry{verbose,tmargin=2cm,bmargin=2cm,lmargin=3cm,rmargin=3cm}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\usepackage{array}
\usepackage{rotfloat}
\usepackage{booktabs}
\usepackage{footmisc}
\usepackage{graphicx}
\usepackage{setspace}
\usepackage[authoryear]{natbib}
\PassOptionsToPackage{normalem}{ulem}
\usepackage{ulem}
\onehalfspacing
\usepackage{babel}
%\usepackage{hyperref}
\usepackage{apacite}
\usepackage{makerobust}
\DeclareRobustCommand{\citep}[2][]{\cite[#1]{#2}}
\DeclareRobustCommand{\citealp}[2][]{\citeNP[#1]{#2}}
\DeclareRobustCommand{\citet}[2][]{\citeA[#1]{#2}}
\usepackage{chngcntr}
\counterwithout{figure}{chapter}
\counterwithout{table}{chapter}
\counterwithout{footnote}{chapter}
\bibpunct[, ]{(}{)}{,}{a}{,}{,}
\usepackage{etoolbox}
\makeatletter
\patchcmd{\NAT@citex}
{\ifNAT@swa\else\if*#2*\else\NAT@cmt#2\fi
\if\relax\NAT@date\relax\else\NAT@@close\fi\fi}
{\ifNAT@swa\else\if*#2*\else\ifNAT@par\else\NAT@cmt#2\fi\fi
\if\relax\NAT@date\relax\else\NAT@@close%
\if*#2*\else\ifNAT@par\NAT@cmt#2\fi\fi\fi\fi}{}{}
\makeatother
\begin{filecontents}{\jobname.bib}
@Book{companion,
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}}
\end{filecontents}
\begin{document}
\noindent
\cmd{citet}: \citet[e.g.][100]{adams}, \citet[pp. 1--10]{companion,adams} \\
\cmd{Citet}: \Citet[pp. 1--10]{adams}, \Citet[pp. 1--10]{companion} \\
\cmd{citet*}: \citet*[pp. 1--10]{companion,adams} \\
\cmd{Citet*}: \Citet*[p. 10]{companion} \\
\cmd{cite}: \cite[e.g.][100]{adams}, \cite{companion} \\
\cmd{citep}: \citep[e.g.][p. 20]{adams}, \citep[1--10]{companion,adams} \\
\cmd{citetext}, \cmd{citealp}:
\citetext{see \citealp{companion}, or even better \citealp{adams}} \\
\cmd{citeauthor}: \citeauthor{adams}, \citeauthor{companion} \\
\cmd{citeyear}: \citeyear{adams}, \citeyear{companion} \\
\bibliographystyle{plainnat}
\bibliography{\jobname}
\end{document}
有谁知道如何apacite
结合驯服野兽natbib
吗?
答案1
使用etoolbox
您可以修补命令natbib
使用来设置所有非数字引用标签:\NAT@citex
。后记\NAT@citex
作为第二个参数传递给(#2
)。对于\citet
及其变体\ifNAT@swa
将扩展<false>
,\ifNAT@par
扩展<true>
并\NAT@date
定义。
\documentclass{article}
\usepackage{natbib}
\usepackage{etoolbox}
\makeatletter
\patchcmd{\NAT@citex}
{\ifNAT@swa\else\if*#2*\else\NAT@cmt#2\fi
\if\relax\NAT@date\relax\else\NAT@@close\fi\fi}
{\ifNAT@swa\else\if*#2*\else\ifNAT@par\else\NAT@cmt#2\fi\fi
\if\relax\NAT@date\relax\else\NAT@@close%
\if*#2*\else\ifNAT@par\NAT@cmt#2\fi\fi\fi\fi}{}{}
\makeatother
\begin{filecontents}{\jobname.bib}
@Book{companion,
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}}
\end{filecontents}
\newcommand{\cmd}[1]{\textbackslash\texttt{#1}}
\begin{document}
\noindent
\cmd{citet}: \citet[e.g.][100]{adams}, \citet[pp. 1--10]{companion,adams} \\
\cmd{Citet}: \Citet[pp. 1--10]{adams}, \Citet[pp. 1--10]{companion} \\
\cmd{citet*}: \citet*[pp. 1--10]{companion,adams} \\
\cmd{Citet*}: \Citet*[p. 10]{companion} \\
\cmd{cite}: \cite[e.g.][100]{adams}, \cite{companion} \\
\cmd{citep}: \citep[e.g.][p. 20]{adams}, \citep[1--10]{companion,adams} \\
\cmd{citetext}, \cmd{citealp}:
\citetext{see \citealp{companion}, or even better \citealp{adams}} \\
\cmd{citeauthor}: \citeauthor{adams}, \citeauthor{companion} \\
\cmd{citeyear}: \citeyear{adams}, \citeyear{companion} \\
\bibliographystyle{plainnat}
\bibliography{\jobname}
\end{document}