4

This question already has an answer here:

following the question answer creating bibliographies with biblatex and moderncv, i would like to show the year on the publication BUT only once for year each year.

This example print the year after each one

\RequirePackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@ARTICLE{a1,
 author = {Author},
 title = {Title},
 journaltitle = {Superjournal},
 year = {2003},
}
@article{a4,
 author = {Author4},
 title = {Title4},
 journaltitle = {Superjournal},
 year = {2003},
}
@article{a2,
 author = {Buthor},
 title = {Ztitle},
 journaltitle = {Superjournal},
 year = {2000},
}
@article{a3,
 author = {Duthor},
 title = {Ztitle},
 journaltitle = {Superjournal},
 year = {2002},
}
@InProceedings{p1,
 author = {Author},
 title = {Title},
 Booktitle = {conference xy},
 year = {2003},
}
@InProceedings{p4,
 author = {Author4},
 title = {Title4},
 Booktitle = {conference xy},
 year = {2003},
}
@InProceedings{p2,
 author = {Buthor},
 title = {Ztitle},
 Booktitle = {conference xy},
 year = {2000},
}
@InProceedings{p3,
 author = {Duthor},
 title = {Ztitle},
 Booktitle = {conference xy},
 year = {2002},
}

\end{filecontents*}

\documentclass{moderncv}

\usepackage[sorting=ydnt,
style=numeric-comp,
,doi=false,url=false,
    firstinits=true,
backend=biber]{biblatex}

    \defbibenvironment{bibliography}
     {\list
         {\printfield{year}}
         {\setlength{\topsep}{0pt}
      \setlength{\labelwidth}{\hintscolumnwidth}%
      \setlength{\labelsep}{\separatorcolumnwidth}%
      \leftmargin\labelwidth%
      \advance\leftmargin\labelsep}%
      \sloppy\clubpenalty4000\widowpenalty4000}
      {\endlist}
      {\item}

    \moderncvstyle{classic}  
    \moderncvcolor{blue}       
    \firstname{John}
    \familyname{Doe}
    \addbibresource{\jobname.bib}


\begin{document}
\section{Publications}

\begin{refsection}
\nocite{*}

\printbibliography[title={Article},heading=subbibliography,type=article]
\end{refsection}

\begin{refsection}
\nocite{*}
\printbibliography[title={Proceedings},heading=subbibliography,type=inproceedings]
\end{refsection}
\end{document}

result

i would like to get rid of the second 2003 in each sub-bibliography.

someone can help?

marked as duplicate by egreg, user13907, Martin Schröder, Zarko, darthbith Jan 23 '16 at 13:45

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

3

Try

\makeatletter
\InitializeBibliographyStyle{\global\undef\bbx@lastyear}

\defbibenvironment{bibliography}
  {\list
     {\iffieldequals{year}{\bbx@lastyear}
       {}
       {\printfield{year}\savefield{year}{\bbx@lastyear}}}
     {\setlength{\topsep}{0pt}
      \setlength{\labelwidth}{\hintscolumnwidth}%
      \setlength{\labelsep}{\separatorcolumnwidth}%
      \leftmargin\labelwidth%
      \advance\leftmargin\labelsep}%
      \sloppy\clubpenalty4000\widowpenalty4000}
  {\endlist}
  {\item}
\makeatother

which is inspired by how authoryear and authortitle implement their dash option with \bbx@lasthash.

We define a new macro \bbx@lastyear that holds the year of the last entry, if the year field of the current entry and \bbx@lastyear coincide we do not have to print a year, otherwise we print the year and update \bbx@lastyear. That is done in the

\iffieldequals{year}{\bbx@lastyear}
  {}
  {\printfield{year}\savefield{year}{\bbx@lastyear}}

bit. MWE

\RequirePackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@ARTICLE{a1,
 author = {Author},
 title = {Title},
 journaltitle = {Superjournal},
 year = {2003},
}
@article{a4,
 author = {Author4},
 title = {Title4},
 journaltitle = {Superjournal},
 year = {2003},
}
@article{a2,
 author = {Buthor},
 title = {Ztitle},
 journaltitle = {Superjournal},
 year = {2000},
}
@article{a3,
 author = {Duthor},
 title = {Ztitle},
 journaltitle = {Superjournal},
 year = {2002},
}
@InProceedings{p1,
 author = {Author},
 title = {Title},
 Booktitle = {conference xy},
 year = {2003},
}
@InProceedings{p4,
 author = {Author4},
 title = {Title4},
 Booktitle = {conference xy},
 year = {2003},
}
@InProceedings{p2,
 author = {Buthor},
 title = {Ztitle},
 Booktitle = {conference xy},
 year = {2000},
}
@InProceedings{p3,
 author = {Duthor},
 title = {Ztitle},
 Booktitle = {conference xy},
 year = {2002},
}

\end{filecontents*}

\documentclass{moderncv}

\usepackage[sorting=ydnt,
  style=authortitle,
  doi=false, url=false,
  firstinits=true,
  backend=biber]{biblatex}

\makeatletter
\InitializeBibliographyStyle{\global\undef\bbx@lastyear}

\defbibenvironment{bibliography}
  {\list
     {\iffieldequals{year}{\bbx@lastyear}
       {}
       {\printfield{year}\savefield{year}{\bbx@lastyear}}}
     {\setlength{\topsep}{0pt}
      \setlength{\labelwidth}{\hintscolumnwidth}%
      \setlength{\labelsep}{\separatorcolumnwidth}%
      \leftmargin\labelwidth%
      \advance\leftmargin\labelsep}%
      \sloppy\clubpenalty4000\widowpenalty4000}
  {\endlist}
  {\item}
\makeatother

    \moderncvstyle{classic}  
    \moderncvcolor{blue}       
    \firstname{John}
    \familyname{Doe}
    \addbibresource{\jobname.bib}


\begin{document}
\section{Publications}

\begin{refsection}
\nocite{*}

\printbibliography[title={Article},heading=subbibliography,type=article]
\end{refsection}

\begin{refsection}
\nocite{*}
\printbibliography[title={Proceedings},heading=subbibliography,type=inproceedings]
\end{refsection}
\end{document}

enter image description here

Not the answer you're looking for? Browse other questions tagged or ask your own question.