按照问题答案使用 biblatex 和 moderncv 创建参考书目,我想在出版物上显示年份,但每年只显示一次。
此示例打印每个年份
\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}
我想删除每个子书目中的第二个 2003。
有人可以帮忙吗?
答案1
尝试
\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
其灵感来自于如何authoryear
以及怎样authortitle
实现他们的dash
选择\bbx@lasthash
。
我们定义一个新的宏\bbx@lastyear
来保存最后一条记录的年份,如果year
当前记录的字段和\bbx@lastyear
年份相符,我们就不必打印年份,否则我们打印年份并更新\bbx@lastyear
。这是在
\iffieldequals{year}{\bbx@lastyear}
{}
{\printfield{year}\savefield{year}{\bbx@lastyear}}
位。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}