List of publications with multiple bib files
Here is an approach with multibib
:
\documentclass{article}
\usepackage{filecontents,multibib,etoolbox}
\title{\Large\bfseries
Selected Publications
}
\author{
{\scshape Dr MWE}\\
Department of Minimum Working,\\
University of Examples
}
\begin{filecontents}{publications-2000.bib}
@article{MWE1,
author = {MWE, Dr},
title = {How to produce an {MWE}},
journal = {Journal of MWEs},
year = {2000},
volume = {1},
pages = {1--10}
}
\end{filecontents}
\begin{filecontents}{publications-2001.bib}
@article{MWE2,
author = {MWE, Dr},
title = {How to produce yet another an {MWE}},
journal = {Journal of MWEs},
year = {2001},
volume = {2},
pages = {1--10}
}
\end{filecontents}
\begin{filecontents}{publications-2002.bib}
@article{MWE2,
author = {MWE, Dr},
title = {How to produce yet another {MWE}, again},
journal = {Journal of MWEs},
year = {2002},
volume = {3},
pages = {1--10}
}
\end{filecontents}
\newcommand{\yearlist}{}
\forcsvlist{\listadd\yearlist}{2000,2001,2002}
\renewcommand{\do}[1]{\newcites{year\romannumeral #1}{#1}}
\dolistloop{\yearlist}
\begin{document}
\maketitle
\renewcommand{\do}[1]{\csuse{nociteyear\romannumeral #1}{*}%
\csuse{bibliographystyleyear\romannumeral #1}{unsrt}%
\csuse{bibliographyyear\romannumeral #1}{publications-#1}}%
\dolistloop{\yearlist}
\end{document}
What multibib
does, is introduce a new command \newcites
. Writing
\newcites{papers}{My papers}
prepares for creating a bibliography with heading My papers
. It creates new commands
\citepapers
\nocitepapers
\bibliographystylepapers
\bibliographypapers
which are then used as drop in replacements for the usual commands.
Now in your case there are a couple of further problems. We can't use your looping command with \newcites
inside, as it creates a group and the new commands only exist inside that group. Instead we can use looping constructs from the etoolbox
package. I have done this above by building up a \yearlist
and then calling \dolistloop
on this list, after having redefined \do
to effect what I need.
The second problem is that we can't use numbers as part of the new command names (at lest no easily). The standard LaTeX way around this is to replace the numbers by their roman numeral equivalent. So I call
\newcites{year\romannumeral 2000}{2000}
instead of \newcites{year2000}
, etc.
Now when you compile the example file above with latex
, files yearmm.aux
, yearmmi.aux
,... are written. You then run bibtex
on each of these in turn, before running latex
again.
A final remark, styling of the heading should not really be done inside \refname
. See How to change Bibliography heading? for some approaches to this.
I would use bibtopic
to which lets you easily group different bibs. You just have to run bibtex for each generated .aux file and you can either continue or reset numbering.
\documentclass{article}
\usepackage{filecontents, pgffor}
\usepackage{bibtopic}
%\usepackage[sectcntreset]{bibtopic} %use to reset numbering in each section
\title{\Large\bfseries
Selected Publications
}
\author{
{\scshape Dr MWE}\\
Department of Minimum Working,\\
University of Examples
}
\begin{filecontents}{publications_2000.bib}
@article{MWE1,
author = {MWE, Dr},
title = {How to produce an {MWE}},
journal = {Journal of MWEs},
year = {2000},
volume = {1},
pages = {1--10}
}
\end{filecontents}
\begin{filecontents}{publications_2001.bib}
@article{MWE2,
author = {MWE, Dr},
title = {How to produce yet another an {MWE}},
journal = {Journal of MWEs},
year = {2001},
volume = {2},
pages = {1--10}
}
\end{filecontents}
\begin{filecontents}{publications_2002.bib}
@article{MWE3,
author = {MWE, Dr},
title = {How to produce yet another {MWE}, again},
journal = {Journal of MWEs},
year = {2002},
volume = {3},
pages = {1--10}
}
\end{filecontents}
\begin{document}
\maketitle
\nocite{*}
\bibliographystyle{unsrt}
\foreach \yr in {2000,...,2002}{
\subsection*{\large \yr}
\begin{btSect}{publications_\yr}
\btPrintNotCited
\end{btSect}
}
\end{document}