참고 문헌 : 왼쪽 여백에 별표를 추가하여 최근 참조를 자동으로 강조 표시

Aug 19 2020

참고 문헌 목록을 업데이트하고 있으며 마지막 업데이트 이후 추가 된 참고 문헌을 강조하고 싶습니다. 예를 들어, 참조 바로 앞에 별표 (또는 다른 기호)를 추가하고 싶습니다 (이상적으로는 왼쪽 여백에 또는 적어도 참조의 시작 부분에).

그러나 이미 많은 질문 (예 : 일부 키워드 뒤에 별표 추가)과 달리 특정 날짜에 따라 별표를 자동으로 추가하고 싶습니다.

.bib(: YYYY-MM-DD 또는 YYYY.MM.DD 형식) 각각의 참조 필드에 "타임 스탬프"가되도록 파일은 JabRef로 생성 하였다. 이 필드는 별표를 추가하는 데 사용할 수 있습니다.

MWE :

\documentclass{article}
\usepackage[style=authoryear,backend=biber]{biblatex}
\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@book{Rabelais1532,
  author = {Rabelais, Fran\c{c}ois},
  date = {1532},
  title = {Pantagruel},
  timestamp = {2018-07-01},
}
@book{Hugo1862,
  author = {Hugo, Victor},
  date = {1862},
  title = {Les Mis\'{e}rables},
  timestamp = {2019-07-01},
}
@book{Hugo1831,
  author = {Hugo, Victor},
  date = {1831},
  title = {Notre-Dame de Paris},
  timestamp = {2020.01.31},
}
@book{Zola1885,
  author = {Zola, \'{E}mile},
  date = {1885},
  title = {Germinal},
  timestamp = {2020-02-01},
}
@book{Balzac1831,
  author = {de Balzac, Honor\'{e}},
  date = {1831},
  title = {The Skin of Sorrow},
  timestamp = {2020-06-15},
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}
\nocite{*}
\printbibliography
\end{document}

이 게시물에 제공된 다음 코드 를 성공적 으로 수정하려고 시도했습니다 .

\renewbibmacro*{begentry}{%
    \iftimestamp{<thechoosendate>}{%
        \makebox[0pt][r]{\textasteriskcentered\addspace}%
    }{}%
}

예를 들어 2020 년 1 월 31 일 (타임 스탬프> = 2020-01-31) 이후에 추가 된 하이라이트 참조를 원합니다.

어쩌면 우리는 패키지를 사용할 수 있습니다 datetime2및 명령을 \DTMsavedate{lastupdatedate}{2020-01-31}하고 \DTMusedate{lastupdatedate}곧 업데이트를 최적화 할 수 있습니다.

  1. 별표로 식별 된 모든 최근 참조를 얻으려면 어떻게해야합니까?
  2. 이러한 유형의 프로그래밍을 만드는 방법을 배우려면 어떤 문서를 읽어야합니까?

답변

2 moewe Aug 19 2020 at 13:46

나는 이것을 처리하는 많은 방법이 있다고 생각합니다.

어떤 경우 든 첫 번째 단계는 타임 스탬프 데이터가 Biber에 도착하는지 확인하는 것입니다. 표준 데이터 모델에는과 같은 필드가 timestamp없으므로 해당 필드는 무시됩니다. 타임 스탬프 데이터를 biblatex다음 으로 가져 오는 방법은 최소한 두 가지입니다 .

  1. timestamp필드 로 새 데이터 모델을 선언하십시오 .
  2. timestamp알려진 필드 (예 : 스크래치 필드 'usera')로 다시 매핑 합니다.

아래에서는 두 가지 접근 방식의 조합을 사용합니다. 새 날짜 필드 를 선언하고 해당 필드를 Biber 소스 timestampdate맵으로 매핑 timestamp합니다 (기술적 인 이유로의 모든 날짜 필드 biblatex는로 끝나야 ...date하므로 timestampdate좋은 선택 인 것 같습니다). Biber가 필드를 날짜로 구문 분석하고 연도, 월, 일을 별도로 반환 할 수 있기 때문에이 더 복잡한 경로를 선택했습니다. 또한, 우리는에서 날짜 형식을 정상화하기 위해이 단계를 사용할 수 있습니다 YYYY.MM.DDYYYY-MM-DD.

필드를 timestamp통하지 않고 그대로 통과하는 것이 완벽하게 가능 ...date하지만 LaTeX 측에서 날짜를 구문 분석해야합니다 (너무 까다로워서는 안 됨).

날짜가 지나면 biblatex주어진 날짜보다 나이가 많지 않은지 확인하면됩니다. 날짜 부분을 연도, 월, 일을 하나씩 살펴보면 간단히 확인할 수 있습니다. 날짜 필드의 timestampdate경우 연도는 timestampyear, 월 timestampmonth등으로 표시 됩니다 .를 사용하여 원시 필드에 액세스 할 수 있습니다 \thefield.

\documentclass{article}

\begin{filecontents}{timestampdate.dbx}
\ProvidesFile{timestampdate.dbx}[2020/08/19 timestampdate for biblatex]
\DeclareDatamodelFields[type=field, datatype=date, skipout]{
  timestampdate,
}
\DeclareDatamodelEntryfields{
  timestampday,
  timestampendday,
  timestampendhour,
  timestampendminute,
  timestampendmonth,
  timestampendsecond,
  timestampendtimezone,
  timestampendyear,
  timestamphour,
  timestampminute,
  timestampmonth,
  timestampsecond,
  timestamptimezone,
  timestampyear,
}
\end{filecontents}

\usepackage[style=authoryear, backend=biber, datamodel=timestampdate]{biblatex}

\DeclareSourcemap{
  \maps{
    \map{
      % map timestamp to date field timestampdate
      \step[fieldsource=timestamp, fieldtarget=timestampdate]
      % now convert '.' to '-'
      \step[fieldsource=timestampdate, match=\regexp{\.}, replace=\regexp{-}]
      % we should now have YYYY-MM-DD format
    }
  }
}

\makeatletter
% {<datetype prefix>}{<year>}{<month>}{<day>}
% checks if the date stored in the field <datetype>
% is at least <year>-<month>-<day>
% ---
% to understand the code below just 'map'
% \@firstoftwo  -> true
% \@secondoftwo -> false
\newcommand*{\ifdateatleast}[4]{%
  \ifnumgreater{\thefield{#1year}}{#2}
    {\@firstoftwo}
    {\ifnumequal{\thefield{#1year}}{#2}
       {\ifnumgreater{\thefield{#1month}}{#3}
          {\@firstoftwo}
          {\ifnumequal{\thefield{#1month}}{#3}
             {\ifnumless{\thefield{#1day}}{#4}
                {\@secondoftwo}
                {\@firstoftwo}}
             {\@secondoftwo}}}
       {\@secondoftwo}}%
}
\makeatother

\renewbibmacro*{begentry}{%
  \ifdateatleast{timestamp}{2020}{1}{1}
    {\makebox[0pt][r]{\textasteriskcentered\addspace}}
    {}%
}

\begin{filecontents}{\jobname.bib}
@book{Rabelais1532,
  author    = {Rabelais, Fran\c{c}ois},
  date      = {1532},
  title     = {Pantagruel},
  timestamp = {2018-07-01},
}
@book{Hugo1862,
  author    = {Hugo, Victor},
  date      = {1862},
  title     = {Les Mis\'{e}rables},
  timestamp = {2019-07-01},
}
@book{Hugo1831,
  author    = {Hugo, Victor},
  date      = {1831},
  title     = {Notre-Dame de Paris},
  timestamp = {2020.01.31},
}
@book{Zola1885,
  author    = {Zola, \'{E}mile},
  date      = {1885},
  title     = {Germinal},
  timestamp = {2020-02-01},
}
@book{Balzac1831,
  author    = {de Balzac, Honor\'{e}},
  date      = {1831},
  title     = {The Skin of Sorrow},
  timestamp = {2020-06-15},
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}
\nocite{*}
\printbibliography
\end{document}

솔직히 말씀 드리 자면이 프로그램을 어디서부터 읽어야할지 모르겠습니다. 여기서 가장 중요한 점은 데이터를로 가져 오는 것입니다.는 기본적으로 무시 biblatex되기 때문 timestamp입니다 ( biblatex 항목에 "tome"필드 추가 는 '새'필드를 가져 오는 몇 가지 방법을 보여줍니다 biblatex). 그 후에 '그냥'날짜를 파싱하고 비교해야합니다. 이를 수행하는 방법에는 여러 가지가 있습니다. 방금 Biber 및 biblatex날짜 처리 와 관련된 것을 선택 했지만 이것은 주어진 것이 아닙니다. 모든 것을 직접 구문 분석 할 수도 있습니다 (참조 : LaTeX에서 날짜 문자열을 구문 분석하여 다른 날짜 형식으로 변환 할 수 있습니까? ).