루프를 사용하여 Bibcheck 정의

루프를 사용하여 Bibcheck 정의

나는 (biblatex를 사용하여) 연도별 제목으로 내 참고문헌의 하위 범주를 만들려고 합니다. defbibcheck를 사용하여 다음과 같이 연도별로 확인할 수 있다는 것을 알았습니다.

\defbibcheck{2013}{
  \iffieldint{origyear}
    {\ifnumequal{\thefield{origyear}}{2013}
      {}
      {\skipentry}
    }
    {\iffieldint{2013}
      {\ifnumequal{\thefield{year}}{2013}
       {}
       {\skipentry}
    }
    {\skipentry}
   }
}       

그러나 연도가 많기 때문에 매년 이 사본을 갖고 싶지는 않습니다. 나는 다음과 같이 패키지 \foreach에서 사용할 수 있다고 생각했습니다 pgffor.

\foreach \year in {2012,2013}{%
 \defbibcheck{\year}{
  \iffieldint{origyear}
    {\ifnumequal{\thefield{origyear}}{\year}
      {}
      {\skipentry}
    }
    {\iffieldint{\year}
      {\ifnumequal{\thefield{year}}{\year}
        {}
        {\skipentry}
      }
      {\skipentry}
    }
}
}   

그러나 \prinbibliography[check=2013]결과는 다음과 같습니다. Check '2013' not found.이를 수행하는 다른 방법이 있습니까?

편집: 아래의 최소 작동하지 않는 예:

\documentclass{article}
\usepackage{filecontents}
\usepackage{pgffor}
\usepackage{biblatex}


\foreach \year in {2012,2013}{%
 \defbibcheck{\year}{
  \iffieldint{origyear}
    {\ifnumequal{\thefield{origyear}}{\year}
      {}
      {\skipentry}
    }
    {\iffieldint{\year}
      {\ifnumequal{\thefield{year}}{\year}
        {}
        {\skipentry}
      }
      {\skipentry}
    }
}
}


\begin{filecontents*}{\jobname.bib}
@inproceedings{Bar2013,
    author = {F. Bar and B. Foo},
    booktitle = {The conference on nothing},
pages = {1--2},
title = {{A meaningless title}},
year = {2013}
}
@inproceedings{Bar2012,
    author = {F. Bar},
booktitle = {International Conference on Information},
pages = {3--4},
title = {{Advanced functionality and performance or nothing }},
year = {2012}
}
\end{filecontents*}
\addbibresource{\jobname.bib}
\begin{document}
\nocite{*}
\printbibliography[check=2013]
\end{document} 

답변1

이 같은?

\begin{filecontents*}{\jobname.bib}
@inproceedings{Bar2011,
    author = {F. Bar and B. Foo},
    booktitle = {The conference 2011 on nothing},
pages = {1--2},
title = {{A meaningless title}},
year = {2011}
}

@inproceedings{Bar2013,
    author = {F. Bar and B. Foo},
    booktitle = {The conference 2013 on nothing},
pages = {1--2},
title = {{A meaningless title}},
year = 2013
}

@inproceedings{Bar2012,
    author = {F. Bar},
booktitle = {International Conference on Information 2012},
pages = {3--4},
title = {{Advanced functionality and performance or nothing }},
year = {2012}
}

@inproceedings{Bar2012b,
    author = {F. Bar and B. Foo},
    booktitle = {The conference on nothing},
pages = {1--2},
title = {{A meaningless title}},
year = {2012}
}

@inproceedings{Bar2014,
    author = {F. Bar and B. Foo},
    booktitle = {The conference on nothing 2014},
pages = {1--2},
title = {{A meaningless title}},
year = {2014}
}
\end{filecontents*}

\documentclass{article}
\usepackage{filecontents}
\usepackage{pgffor}
\usepackage{biblatex}

\defbibcheck{ylist}{%
  \iffieldint{year}{%
    \xdef\fldyear{\thefield{year}}\xdef\doskip{1}%
    \foreach \yr in \yrlist{%
      \ifnumequal{\fldyear}{\yr}{\xdef\doskip{0}\breakforeach}{}%
    }%
    \ifnumequal{\doskip}{1}{\skipentry}{}%
  }%
  {\skipentry}%
}

\addbibresource{\jobname.bib}
\begin{document}
\def\yrlist{2012,2013,2011,2010}
Years: \yrlist

\nocite{*}
\printbibliography[check=ylist]
\end{document} 

여기에 이미지 설명을 입력하세요

편집하다: MWE연도별 참고자료:

\begin{filecontents*}{\jobname.bib}
@inproceedings{Bar2011,
    author = {F. Bar and B. Foo},
    booktitle = {The conference 2011 on nothing},
pages = {1--2},
title = {{A meaningless title}},
year = {2011}
}

@inproceedings{Bar2013,
    author = {F. Bar and B. Foo},
    booktitle = {The conference 2013 on nothing},
pages = {1--2},
title = {{A meaningless title}},
year = 2013
}

@inproceedings{Bar2012,
    author = {F. Bar},
booktitle = {International Conference on Information 2012},
pages = {3--4},
title = {{Advanced functionality and performance or nothing }},
year = {2012}
}

@inproceedings{Bar2012b,
    author = {F. Bar and B. Foo},
    booktitle = {The conference on nothing},
pages = {1--2},
title = {{A meaningless title}},
year = {2012}
}

@inproceedings{Bar2014,
    author = {F. Bar and B. Foo},
    booktitle = {The conference on nothing 2014},
pages = {1--2},
title = {{A meaningless title}},
year = {2014}
}
\end{filecontents*}

\documentclass{article}
\usepackage{filecontents}
\usepackage{pgffor}
\usepackage{biblatex}

\addbibresource{\jobname.bib}

\begin{document}
\nocite{*}
%
\def\yrlist{2011,2012,2013}

\foreach \yr in \yrlist{%
  \defbibcheck{ylist}{%
    \iffieldint{year}{%
        \ifnumequal{\thefield{year}}{\yr}{}{\skipentry}%
    }%
    {\skipentry}%
  }%
  \renewcommand{\refname}{REFERENCES: \yr}%
  \printbibliography[check=ylist]
}
\end{document} 

여기에 이미지 설명을 입력하세요

답변2

당신은 적응할 수 있습니다오드리의 답변에게매우 유사한 문제 (참고문헌을 알파벳순으로 분할하는 방법은 무엇입니까?).

\makeatletter
\def\ifskipbib{\iftoggle{blx@skipbib}}
\makeatother

\def\yearlist{}
\forcsvlist{\listadd\yearlist}{2010,2011,2012,2013}
\forlistloop{\DeclareBibliographyCategory}{\yearlist}
\renewcommand*{\do}[1]{\defbibheading{#1}{\section*{#1}}}
\dolistloop{\yearlist}
\AtDataInput{\ifskipbib{}{\addtocategory{\thefield{year}}{\thefield{entrykey}}}}

첫 번째 코드 블록은 참고문헌에 나타나지 않는 항목을 건너뛰도록 합니다(빈 2010이 거기에 있는 것을 원하지 않을 것입니다).

두 번째 블록은 두 번째 줄에 지정된 모든 연도를 반복하고 각 연도에 대해 다른 범주를 만듭니다. 그런 다음 이러한 하위 참고문헌의 제목이 정의됩니다. 마지막으로 마지막 줄은 항목을 해당 연도 범주와 일치시킵니다.

\documentclass{article}
\usepackage{biblatex}

\begin{filecontents*}{\jobname.bib}
@inproceedings{Bar2013,
    author = {F. Bar and B. Foo},
    booktitle = {The conference on nothing},
pages = {1--2},
title = {{A meaningless title}},
year = {2013}
}
@inproceedings{Bar2012,
    author = {F. Bar},
booktitle = {International Conference on Information},
pages = {3--4},
title = {{Advanced functionality and performance or nothing }},
year = {2012}
}
\end{filecontents*}

\makeatletter
\def\ifskipbib{\iftoggle{blx@skipbib}}
\makeatother

\def\yearlist{}
\forcsvlist{\listadd\yearlist}{2010,2011,2012,2013}
\forlistloop{\DeclareBibliographyCategory}{\yearlist}
\renewcommand*{\do}[1]{\defbibheading{#1}{\section*{#1}}}
\dolistloop{\yearlist}
\AtDataInput{\ifskipbib{}{\addtocategory{\thefield{year}}{\thefield{entrykey}}}}

\addbibresource{\jobname.bib}
\begin{document}
  \nocite{*}
  \printbibheading
  \bibbycategory
\end{document} 

코드의 반자동 버전도 있습니다.

새 명령을 정의하여

\newcommand{\yearcheck}[1]{%
  \defbibcheck{#1}{
    \iffieldint{origyear}
      {\ifnumequal{\thefield{origyear}}{#1}
        {}
        {\skipentry}
      }
      {\iffieldint{year}
        {\ifnumequal{\thefield{year}}{#1}
          {}
          {\skipentry}
        }
        {\skipentry}
      }
   }
}

그런 다음 이를 사용하여 다음을 통해 연도 턱받이를 만들 수 있습니다.

\yearcheck{2012}
\yearcheck{2013}

\foeach다음과 같은 루프 내에서는 작동하지 않는 것 같습니다 .\foreach \year in {2012,2013} {\yearcheck{\year}}

또는 루프를 통해 훨씬 더 좋습니다(@g.kov에게 감사드립니다).

\foreach \year in {2012,2013} {\global\yearcheck{\year}}

참고문헌 인쇄는 루프를 통해서도 구현할 수 있습니다.

\foreach \year in {2012,2013} {\printbibliography[check=\year,title={\year}]}

MWE

\documentclass{article}
\usepackage{filecontents}
\usepackage{biblatex}
\usepackage{pgffor}

\newcommand{\yearcheck}[1]{%
  \defbibcheck{#1}{
    \iffieldint{origyear}
      {\ifnumequal{\thefield{origyear}}{#1}
        {}
        {\skipentry}
      }
      {\iffieldint{year}
        {\ifnumequal{\thefield{year}}{#1}
          {}
          {\skipentry}
        }
        {\skipentry}
      }
   }
}

\begin{filecontents*}{\jobname.bib}
@inproceedings{Bar2013,
    author = {F. Bar and B. Foo},
    booktitle = {The conference on nothing},
pages = {1--2},
title = {{A meaningless title}},
year = {2013}
}
@inproceedings{Bar2012,
    author = {F. Bar},
booktitle = {International Conference on Information},
pages = {3--4},
title = {{Advanced functionality and performance or nothing }},
year = {2012}
}
\end{filecontents*}
\addbibresource{\jobname.bib}

\foreach \year in {2012,2013} {\global\yearcheck{\year}}
\begin{document}
  \nocite{*}
  \foreach \year in {2012,2013} {\printbibliography[check=\year,title={\year}]}
\end{document} 

관련 정보