
Я пытаюсь создать более длинный документ и столкнулся со следующей проблемой authoryear-comp
:
Если я установил uniquelist=minyear
, я получаю цитаты с NAME YEARa и NAME YEARb, если список авторов идентичен. Пока все хорошо.
Если я цитирую две статьи в одной команде cite, я получаю YEARa,b
. Можно ли получить i) пробел между , и b: YEARa, b
; или ii) YEARa, YEARb
?
Это MWE для демонстрации:
\documentclass{article}
\usepackage[backend=biber,bibencoding=utf8,dashed=false,style=authoryear-comp,uniquename=false,uniquelist=minyear,date=year,maxcitenames=2, useprefix=true,maxbibnames=99,mincrossrefs=99,sorting=ynt,sortcites=true,isbn=false,eprint=false,urldate=long]{biblatex}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{a1,
author={John Smith and Mary Stuart and Peter Pan},
year = 2020,
journal = {Awesome Journal},
volume = 3
}
@article{a2,
author={John Smith and Mary Stuart and Peter Pan},
year = 2020,
journal = {Another Journal},
volume = 3
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\cite{a1,a2}
\end{document}
Вывод выглядит так:
и между запятой после a и b нет пробела.
решение1
Добавление пространства можно сделать, настроив biblatex
макрос cite:extradate
. Здесь используется \addthinspace
макрос, предоставленныйbiblatex
\renewbibmacro*{cite:extradate}{%
\iffieldundef{extradate}
{}
{\printtext[bibhyperref]{\addthinspace\printfield{extradate}}}}
Вторую запрошенную форму можно получить, переписав cite
макрос:
\documentclass{article}
\usepackage[backend=biber,bibencoding=utf8,dashed=false,style=authoryear-comp,uniquename=false,uniquelist=minyear,date=year,maxcitenames=2, useprefix=true,maxbibnames=99,mincrossrefs=99,sorting=ynt,sortcites=true,isbn=false,eprint=false,urldate=long]{biblatex}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{a1,
author={John Smith and Mary Stuart and Peter Pan},
year = 2020,
journal = {Awesome Journal},
volume = 3
}
@article{a2,
author={John Smith and Mary Stuart and Peter Pan},
year = 2020,
journal = {Another Journal},
volume = 3
}
\end{filecontents}
\addbibresource{\jobname.bib}
\renewbibmacro*{cite:extradate}{%
\iffieldundef{extradate}
{}
{\printtext[bibhyperref]{\addthinspace\printfield{extradate}}}}
\begin{document}
\cite{a1,a2}
\makeatletter
\renewbibmacro*{cite}{%
\iffieldundef{shorthand}
{\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
{\usebibmacro{cite:label}%
\setunit{\printdelim{nonameyeardelim}}%
\usebibmacro{cite:labeldate+extradate}%
\usebibmacro{cite:reinit}}
{\iffieldequals{namehash}{\cbx@lasthash}
{\ifthenelse{\iffieldequals{labelyear}{\cbx@lastyear}\AND
\(\value{multicitecount}=0\OR\iffieldundef{postnote}\)}
{\setunit{\addcomma\addspace}% <---- punuctation
\usebibmacro{cite:labeldate+extradate}} % <---- instead of cite:extradate
{\setunit{\compcitedelim}%
\usebibmacro{cite:labeldate+extradate}%
\savefield{labelyear}{\cbx@lastyear}}}
{\printnames{labelname}%
\setunit{\printdelim{nameyeardelim}}%
\usebibmacro{cite:labeldate+extradate}%
\savefield{namehash}{\cbx@lasthash}%
\savefield{labelyear}{\cbx@lastyear}}}}
{\usebibmacro{cite:shorthand}%
\usebibmacro{cite:reinit}}%
\setunit{\multicitedelim}}
\makeatother
\cite{a1,a2}
\end{document}
Вам, возможно, придется сделать что-то подобное для других команд цитирования. Их исходный код находится в authoryear-comp.cbx
. .log
Полный путь в вашей системе смотрите в файле.
решение2
Вы можете использовать biblatex-ext
замену плагина для authoryear-comp
, ext-authoryear-comp
.
Затем вам просто нужно переопределить extradateonlycompcitedelim
по своему вкусу.
\documentclass{article}
\usepackage[
backend=biber,
style=ext-authoryear-comp,
sorting=ynt,
uniquename=false,uniquelist=minyear,
maxbibnames=99, maxcitenames=2,
useprefix=true,
dashed=false,
date=year, urldate=long,
isbn=false, eprint=false,
mincrossrefs=99,
]{biblatex}
\DeclareDelimFormat{extradateonlycompcitedelim}{\addcomma\space}
\begin{filecontents}{\jobname.bib}
@article{a1,
author={John Smith and Mary Stuart and Peter Pan},
year = 2020,
journal = {Awesome Journal},
volume = 3
}
@article{a2,
author={John Smith and Mary Stuart and Peter Pan},
year = 2020,
journal = {Another Journal},
volume = 3
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\cite{a1,a2}
\end{document}
Простая альтернатива переопределению довольно сложных макросов cite для получения «Автор Yeara, Yearb» — это сброс \cbx@lastyear
при каждом нажатии клавиши cite. (Конечно, изменение макросов было бы эффективнее, но это решение намного короче в преамбуле.)
\documentclass{article}
\usepackage[
backend=biber,
style=authoryear-comp,
sorting=ynt,
uniquename=false,uniquelist=minyear,
maxbibnames=99, maxcitenames=2,
useprefix=true,
dashed=false,
date=year, urldate=long,
isbn=false, eprint=false,
mincrossrefs=99,
]{biblatex}
\makeatletter
\AtEveryCitekey{\global\undef\cbx@lastyear}
\makeatother
\begin{filecontents}{\jobname.bib}
@article{a1,
author={John Smith and Mary Stuart and Peter Pan},
year = 2020,
journal = {Awesome Journal},
volume = 3
}
@article{a2,
author={John Smith and Mary Stuart and Peter Pan},
year = 2020,
journal = {Another Journal},
volume = 3
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\cite{a1,a2}
\end{document}
Это решение также подойдет для biblatex-ext
стилей.