在里面使用 BibLaTeX 模仿 BibTeX “apalike”-(biblatex-apa 坏了?) 提供的答案工作正常,直到需要添加页码或“参见:”引用整个内容就被破坏了......
有没有简单的方法可以修复它?还有其他解决方法吗?
以下是示例代码和结果:
% !TEX TS-program = arara
% !TEX encoding = UTF-8 Unicode
% arara: xelatex: { shell: true }
% arara: biber
% arara: xelatex: { shell: true }
\documentclass{article}
\usepackage{xcolor}
\usepackage{hyperref}
\hypersetup{%
colorlinks=true,
citecolor=blue}
\usepackage{polyglossia}
\setmainlanguage[variant=british]{english}
\usepackage{csquotes}
\PassOptionsToPackage{%
natbib=true,
style=authoryear-comp,
hyperref=true,
backend=biber,
maxbibnames=99,
firstinits=true,
uniquename=init,
maxcitenames=2,
parentracker=true,
url=false,
doi=false,
isbn=false,
eprint=false,
backref=true,
} {biblatex}
\usepackage{biblatex}
\renewcommand*{\postnotedelim}{\addcolon\space} % Xtras
\DeclareFieldFormat{postnote}{#1} % Xtras
\DeclareFieldFormat{multipostnote}{#1} % Xtras
\DeclareNameAlias{sortname}{last-first}
% remove "in:" from articles. Thanks to Herbert.
\renewbibmacro{in:}{%
\ifentrytype{article}{}{%
\printtext{\bibstring{in}\intitlepunct}}}
% mit "month" and "language" from Bibliography
%%% \AtEveryBibitem{%
%%% \clearfield{month}{}%
%%% \clearlist{language}{}%
%%% }
% some natbib backwards compatibility
\let\citealp\cite
\let\cite\textcite
% increase vertical space between bibliography items.
\setlength\bibitemsep{0.5ex}
\setlength\bibnamesep{1.2ex}
% Comma before and after journal volume. Thanks to lockstep.
\renewbibmacro*{volume+number+eid}{%
\setunit*{\addcomma\space}% NEW
\printfield{volume}%
\printfield{number}%
\printfield{eid}}
\DeclareFieldFormat[article]{number}{(#1)}% number of a journal
% Citation Hyperlinks (not just years), thanks to Audrey.
\makeatletter
\renewbibmacro*{cite}{% Based on cite bib macro from authoryear-comp.cbx
\iffieldundef{shorthand}
{\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
{\printtext[bibhyperref]{% Include labelname in hyperlink
\DeclareFieldAlias{bibhyperref}{default}% Prevent nested hyperlinks
\usebibmacro{cite:label}%
\setunit{\addspace}%
\usebibmacro{cite:labelyear+extrayear}}%
\usebibmacro{cite:reinit}}
{\iffieldequals{namehash}{\cbx@lasthash}
{\ifthenelse{\iffieldequals{labelyear}{\cbx@lastyear}\AND
\(\value{multicitecount}=0\OR\iffieldundef{postnote}\)}
{\setunit{\addcomma}%
\usebibmacro{cite:extrayear}}
{\setunit{\compcitedelim}%
\usebibmacro{cite:labelyear+extrayear}%
\savefield{labelyear}{\cbx@lastyear}}}
{\printtext[bibhyperref]{% Include labelname in hyperlink
\DeclareFieldAlias{bibhyperref}{default}% Prevent nested hyperlinks
\printnames{labelname}%
\setunit{\nameyeardelim}%
\usebibmacro{cite:labelyear+extrayear}}%
\savefield{namehash}{\cbx@lasthash}%
\savefield{labelyear}{\cbx@lastyear}}}}
{\usebibmacro{cite:shorthand}%
\usebibmacro{cite:reinit}}%
\setunit{\multicitedelim}}
\renewbibmacro*{textcite}{% Based on textcite bib macro from authoryear-comp.cbx
\iffieldequals{namehash}{\cbx@lasthash}
{\iffieldundef{shorthand}
{\ifthenelse{\iffieldequals{labelyear}{\cbx@lastyear}\AND
\(\value{multicitecount}=0\OR\iffieldundef{postnote}\)}
{\setunit{\addcomma}%
\usebibmacro{cite:extrayear}}
{\setunit{\compcitedelim}%
\usebibmacro{cite:labelyear+extrayear}%
\savefield{labelyear}{\cbx@lastyear}}}
{\setunit{\compcitedelim}%
\usebibmacro{cite:shorthand}%
\global\undef\cbx@lastyear}}
{\ifnameundef{labelname}
{\printtext[bibhyperref]{% Include labelname in hyperlink
\DeclareFieldAlias{bibhyperref}{default}% Prevent nested hyperlinks
\iffieldundef{shorthand}
{\usebibmacro{cite:label}%
\setunit{%
\global\booltrue{cbx:parens}%
\addspace\bibopenparen}%
\ifnumequal{\value{citecount}}{1}
{\usebibmacro{prenote}}
{}%
\usebibmacro{cite:labelyear+extrayear}}
{\usebibmacro{cite:shorthand}}%
\ifthenelse{\iffieldundef{postnote}\AND
\(\value{multicitetotal}=0\AND\value{citetotal}=1\)}
{\bibcloseparen% Include closing parenthesis in hyperlink
\global\boolfalse{cbx:parens}}
{}}}
{\printtext[bibhyperref]{% Include labelname in hyperlink
\DeclareFieldAlias{bibhyperref}{default}% Prevent nested hyperlinks
\printnames{labelname}%
\setunit{%
\global\booltrue{cbx:parens}%
\addspace\bibopenparen}%
\ifnumequal{\value{citecount}}{1}
{\usebibmacro{prenote}}
{}%
\iffieldundef{shorthand}
{\iffieldundef{labelyear}
{\usebibmacro{cite:label}}
{\usebibmacro{cite:labelyear+extrayear}}%
\savefield{labelyear}{\cbx@lastyear}}
{\usebibmacro{cite:shorthand}%
\global\undef\cbx@lastyear}%
\ifthenelse{\iffieldundef{postnote}\AND
\(\value{multicitetotal}=0\AND\value{citetotal}=1\)}
{\bibcloseparen% Include closing parenthesis in hyperlink
\global\boolfalse{cbx:parens}}
{}}%
\savefield{namehash}{\cbx@lasthash}}}%
\setunit{%
\ifbool{cbx:parens}
{\bibcloseparen\global\boolfalse{cbx:parens}}
{}%
\multicitedelim}}
\makeatother
% Backrefs "cited" instead of "cit"
\DefineBibliographyStrings{english}{%
backrefpage={cited on p\adddot},
backrefpages={cited on pp\adddot}
}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{Attanasio2010,
abstract = {This paper provides a critical survey of the large literature on the life cycle model of consumption, both from an empirical and a theoretical point of view. It discusses several approaches that have been taken in the literature to bring the model to the data, their empirical successes and failures. Finally, the paper reviews a number of changes to the standard life cycle model that could help solve the remaining empirical puzzles.},
author = {Kaminsky, Graciela Laura and Schmukler, Sergio L.},
journal = {NBER Working Paper},
month = feb,
shorttitle = {Consumption and saving},
title = {{Consumption and saving: models of intertemporal allocation and their implications for public policy}},
url = {http://papers.ssrn.com/sol3/papers.cfm?abstract\_id=1558816 http://www.nber.org/papers/w15756},
volume = {756},
number = {12},
year = {2010}
}
@article{Galindo2002,
author = {Galindo, Arturo and Schiantarelli, Fabio and Weiss, Andrew},
journal = {American Economic Review},
month = apr,
shorttitle = {Does Financial Liberalization Improve the Allocati},
title = {{Does Financial Liberalization Improve the Allocation of Investment?: Micro Evidence from Developing Countries}},
url = {http://ideas.repec.org/p/idb/wpaper/4295.html},
volume = {47},
number = {2},
year = {2002}
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
Finally, as written by \cite{Attanasio2010}, my Bibliography is cool \citep{Galindo2002}. Furthermore (see, for example, \citealp{Attanasio2010}) there are some cool tweaks.
\cite[see:][pg.~3]{Attanasio2010} here ,,see:'' should go before first author and constitute part of the link, also ,,pg.~3)'' should be part of the link
\citep[see:][pg.~3]{Galindo2002} here ,,see:'' should go before opening bracket and \emph{not} constitute part of the link, also ,,pg.~3'' should be part of the link
\printbibliography
\end{document}