특정 참고문헌에 대해서만 참고문헌 문자열 변경

특정 참고문헌에 대해서만 참고문헌 문자열 변경

에 대한 답변이 질문\DefineBibliographyStrings인용 에 대해 "마지막으로 방문한" 텍스트를 변경하는 데 사용할 수 있는 방법을 설명합니다 @online.

그러나 이 솔루션은 이 유형의 모든 참조에 대한 텍스트를 변경합니다. 특정 참조에 대해서만 텍스트를 변경할 수 있도록 하고 싶습니다.

"마지막 방문"으로 유지하고 싶은 현재 웹페이지에 대한 참조가 있지만 대신 "보관된 날짜"로 표시하고 싶은 archive.org에 대한 링크도 있습니다.

다음은 MRE와 출력입니다. 스택 교환 참조에 날짜 앞에 "보관 날짜"를 붙이고 싶지만 위키피디아 참조는 기본 "방문 위치"로 유지됩니다.

\documentclass{article}
\usepackage{filecontents}
\begin{filecontents}{citations.bib}
@online{wikipedia,
    author       = {{Wikimedia Foundation}},
    title        = {Wikipedia},
    url          = {https://en.wikipedia.org},
    year         = {2019},
    urldate      = {2019-12-09}
}
@online{stack,
    author       = {{Stack Exchange Inc}},
    title        = {Stack Overflow},
    url          = {https://web.archive.org/web/20100813082822/http://www.stackoverflow.com/},
    year         = {2010},
    urldate      = {2010-08-13}
}
\end{filecontents}
\usepackage[style=authoryear,backend=bibtex,urldate=long]{biblatex}
\addbibresource{citations.bib}

\DefineBibliographyStrings{english}{
  urlseen = {archived on} 
}

\begin{document}
Lorem ipsum dolor sit amet \autocite{wikipedia}, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua \autocite{stack}. 
\printbibliography
\end{document}

참고자료

답변1

이는 다음과 같은 간단한 적응입니다."편집기가 포함된 항목의 맞춤 턱받이 스타일"에 대한 moewe의 답변(이것이 효과가 있다면 찬성 투표도 해주세요!)

먼저, 프리앰블에 다음 코드를 추가하세요. 이렇게 하면 biblatex가 를 포함하는 참조에 대해 "보관됨"을 쓰고 options = {archived}, 그렇지 않으면 기본 문자열을 쓰게 됩니다.

% define a new "archivedon" string as an alternative to "urlseen"
\NewBibliographyString{archivedon}
\DefineBibliographyStrings{english}{ 
    archivedon = {archived on}
}

% for each reference, detect if the "archived" option is used and set the urldate string accordingly
\newtoggle{bib:archived}
\DeclareEntryOption{archived}[true]{%
  \settoggle{bib:archived}{#1}}
\DeclareFieldFormat{urldate}{% 
  \mkbibparens{%
    \iftoggle{bib:archived}
      {\bibstring{archivedon}} % "archived" option is on - write "archived on"
      {\bibstring{urlseen}} % "archived" option is off - write "visited on"
    \addcolon\space#1}}

그런 다음 사용하는 참고문헌 백엔드(bibtex 또는 biber)에 따라 하나 또는 두 가지 옵션이 있습니다.

a) bibtex를 사용하거나 이 부분을 자동화하지 않으려면 .bib 파일을 편집하고 options = {archived}"보관 위치"를 사용하려는 모든 참조에 추가해야 합니다.

@online{stack,
    author  = {{Stack Exchange Inc}},
    title   = {Stack Overflow},
    url     = {https://web.archive.org/web/20100813082822/http://www.stackoverflow.com/},
    year    = {2010},
    urldate = {2010-08-13},
    options = {archived}
}

b) biber를 사용하는 경우 옵션을 자동으로 설정할 수 있으므로 .bib 파일을 편집할 필요가 없습니다 archived(bibtex에서는 작동하지 않음).

% automatically add the "archived" option when reference url contains "archive.org"
\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map[overwrite]{
      \step[fieldsource=url, match=\regexp{archive\.org},final] 
      \step[fieldset=options, append, fieldvalue={archived=true}] 
    }
  }
}

archivedbibtex용 MWE( archive.org 참조에 옵션을 추가하려면 .bib 파일을 편집해야 함 ):

\documentclass{article}
\usepackage{filecontents}
\begin{filecontents}{citations.bib}
@online{wikipedia,
    author       = {{Wikimedia Foundation}},
    title        = {Wikipedia},
    url          = {https://en.wikipedia.org},
    year         = {2019},
    urldate      = {2019-12-09}
}
@online{stack,
    author       = {{Stack Exchange Inc}},
    title        = {Stack Overflow},
    url          = {https://web.archive.org/web/20100813082822/http://www.stackoverflow.com/},
    year         = {2010},
    urldate      = {2010-08-13},
    options      = {archived}
}

\end{filecontents}
\usepackage[style=authoryear,backend=bibtex,urldate=long]{biblatex}
\addbibresource{citations.bib}


% use "archived on" instead of "visited on" when bib entry includes "options = {archived}"
%   (inspired by https://tex.stackexchange.com/a/265929)
\NewBibliographyString{archivedon}
\DefineBibliographyStrings{english}{ 
    archivedon = {archived on} 
}
\newtoggle{bib:archived}
\DeclareEntryOption{archived}[true]{%
  \settoggle{bib:archived}{#1}}
\DeclareFieldFormat{urldate}{%
  \mkbibparens{%
    \iftoggle{bib:archived}
      {\bibstring{archivedon}}
      {\bibstring{urlseen}}%
    \addcolon\space#1}}
%-----


\begin{document}
Lorem ipsum dolor sit amet \autocite{wikipedia}, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua \autocite{stack}. 

\printbibliography
\end{document}

Biber용 MWE(자동, .bib 편집이 필요하지 않음):

\documentclass{article}
\usepackage{filecontents}
\begin{filecontents}{citations.bib}
@online{wikipedia,
    author       = {{Wikimedia Foundation}},
    title        = {Wikipedia},
    url          = {https://en.wikipedia.org},
    year         = {2019},
    urldate      = {2019-12-09}
}
@online{stack,
    author       = {{Stack Exchange Inc}},
    title        = {Stack Overflow},
    url          = {https://web.archive.org/web/20100813082822/http://www.stackoverflow.com/},
    year         = {2010},
    urldate      = {2010-08-13}
}

\end{filecontents}
\usepackage[style=authoryear,backend=biber,urldate=long]{biblatex} % changed to biber
\addbibresource{citations.bib}


% use "archived on" instead of "visited on" when bib entry includes "options = {archived}"
%   (inspired by https://tex.stackexchange.com/a/265929)
\NewBibliographyString{archivedon}
\DefineBibliographyStrings{english}{ 
    archivedon = {archived on} 
}
\newtoggle{bib:archived}
\DeclareEntryOption{archived}[true]{%
  \settoggle{bib:archived}{#1}}
\DeclareFieldFormat{urldate}{%
  \mkbibparens{%
    \iftoggle{bib:archived}
      {\bibstring{archivedon}}
      {\bibstring{urlseen}}%
    \addcolon\space#1}}
%----------

% for biber only - add the "archived" option automatically when url contains "archive.org"
\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map[overwrite]{
      \step[fieldsource=url, match=\regexp{archive\.org},final]
      \step[fieldset=options, append, fieldvalue={archived=true}]
    }
  }
}
%-----


\begin{document}
Lorem ipsum dolor sit amet \autocite{wikipedia}, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua \autocite{stack}. 

\printbibliography
\end{document}

관련 정보