
나는 이것에 대해 처음 언급할 때 온라인 참고 자료를 방문한 날짜를 추가하고 싶습니다. 스타일 biblatex
로 사용하고 있습니다 authoryear-comp
. MWE는 다음과 같습니다.
\documentclass{scrreprt}
\usepackage[style=authoryear-comp]{biblatex}
\addbibresource{\jobname.bib}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@online{key,
title = {Very nice online reference},
url = {https://www.example.com/},
urldate = {2019-11-25},
author = {Nobody},
}
\end{filecontents}
% Start of the document.
\begin{document}
% Your content.
I want to cite here with the urldate in the citation.
\parencite{key} should look like:
(Author 2001, visited on 25.11.2019) but just when I first reference it.
In every later cication it shall just look (Author 2001).
% End of the document.
\end{document}
누구든지 그 문제를 해결하도록 도와줄 수 있나요?
사용자의 비고https://tex.stackexchange.com/users/14649: 다음 질문입니다.텍스트에서 urldate에 액세스하는 방법.
답변1
이런 식으로 시도해 볼 수 있습니다. 테스트에는 옵션이 citetracker
필요합니다 \ifciteseen
. 정의는 다음 두 줄의 cite
원래 정의입니다 .authoryear-comp.cbx
\setunit{\addcomma\space}%
\usebibmacro{cite:urlinfo}%
마지막에 추가되었습니다.
에 대해서도 동일한 작업을 수행할 수 있지만 이 구성에서는 약간 예상치 못한 출력을 제공할 수 있는 몇 가지 특별한 경우(압축 인용, 이름이나 연도가 없는 인용, 속기)가 있다는 textcite
점에 유의해야 합니다 . \textcite
더 나은 일반적인 솔루션을 생각할 수 없으므로 출력을 주의 깊게 조사하는 것이 좋습니다.
\documentclass{scrreprt}
\usepackage[style=authoryear-comp, citetracker]{biblatex}
\newbibmacro*{cite:urlinfo}{%
\ifciteseen
{}
{\DeclareFieldFormat{urldate}{\bibstring{urlseen}\space##1}%
\printurldate}}
\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}%
\usebibmacro{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{\addcomma\space}%
\usebibmacro{cite:urlinfo}%
\setunit{\multicitedelim}}
\renewbibmacro*{textcite}{%
\iffieldequals{namehash}{\cbx@lasthash}
{\iffieldundef{shorthand}
{\ifthenelse{\iffieldequals{labelyear}{\cbx@lastyear}\AND
\(\value{multicitecount}=0\OR\iffieldundef{postnote}\)}
{\setunit{\addcomma}%
\usebibmacro{cite:extradate}}
{\setunit{\compcitedelim}%
\usebibmacro{cite:labeldate+extradate}%
\savefield{labelyear}{\cbx@lastyear}}}
{\setunit{\compcitedelim}%
\usebibmacro{cite:shorthand}%
\global\undef\cbx@lastyear}}
{\ifnameundef{labelname}
{\iffieldundef{shorthand}
{\usebibmacro{cite:label}%
\setunit{%
\global\booltrue{cbx:parens}%
\printdelim{nonameyeardelim}\bibopenparen}%
\ifnumequal{\value{citecount}}{1}
{\usebibmacro{prenote}}
{}%
\usebibmacro{cite:labeldate+extradate}}
{\usebibmacro{cite:shorthand}}}
{\printnames{labelname}%
\setunit{%
\global\booltrue{cbx:parens}%
\printdelim{nameyeardelim}\bibopenparen}%
\ifnumequal{\value{citecount}}{1}
{\usebibmacro{prenote}}
{}%
\iffieldundef{shorthand}
{\iffieldundef{labelyear}
{\usebibmacro{cite:label}}
{\usebibmacro{cite:labeldate+extradate}}%
\savefield{labelyear}{\cbx@lastyear}}
{\usebibmacro{cite:shorthand}%
\global\undef\cbx@lastyear}}%
\stepcounter{textcitecount}%
\savefield{namehash}{\cbx@lasthash}}%
\setunit{\addcomma\space}%
\usebibmacro{cite:urlinfo}%
\setunit{%
\ifbool{cbx:parens}
{\bibcloseparen\global\boolfalse{cbx:parens}}
{}%
\textcitedelim}}
\makeatother
\begin{filecontents}{\jobname.bib}
@online{key,
title = {Very nice online reference},
url = {https://www.example.com/},
urldate = {2019-11-25},
author = {Nobody},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\parencite{key}
\parencite{key}
\end{document}