
私は、年別の見出しが付いた参考文献のサブカテゴリを作成しようとしています (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 が表示されたくないでしょう)。
2 番目のブロックは、2 行目に指定されたすべての年をループし、それぞれに異なるカテゴリを作成します。次に、これらのサブ書誌の見出しが定義されます。最後に、最後の行でエントリを年カテゴリに一致させます。
\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}]}
ムウェ
\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}