答案1
如果您只是希望反转编号(而不是顺序),那么您可以使用以下方法:
\documentclass{moderncv}
\usepackage{biblatex,refcount}
\makeatletter
% https://tex.stackexchange.com/q/66829/5764
\newcounter{numbibentries}
\renewbibmacro*{finentry}{\stepcounter{numbibentries}\finentry}
% https://tex.stackexchange.com/q/123805/5764
\defbibenvironment{bibliography}
{\list
{\printtext[labelnumberwidth]{% label format from numeric.bbx
\printfield{prefixnumber}%
\number\numexpr\getrefnumber{num-bib-entries}-\abx@field@labelnumber+1\relax}}
{\setlength{\topsep}{0pt}% layout parameters from moderncvstyleclassic.sty
\setlength{\labelwidth}{\hintscolumnwidth}%
\setlength{\labelsep}{\separatorcolumnwidth}%
\leftmargin\labelwidth%
\advance\leftmargin\labelsep}%
\sloppy\clubpenalty4000\widowpenalty4000}
{\endlist}
{\item}
\AtEndDocument{% Add reference at end of document to remember number of bib-entries.
\edef\@currentlabel{\thenumbibentries}\label{num-bib-entries}}
\makeatother
\moderncvstyle{classic}
\moderncvcolor{blue}
\firstname{John}
\familyname{Doe}
\addbibresource{biblatex-examples.bib}
\begin{document}
\makecvtitle
\nocite{companion,knuth:ct:a,knuth:ct:b}
\printbibliography[title={Publications}]
\end{document}
这个想法是\bibitem
点击每个“ ”来计算引用数。一旦全部计算完毕,我们\label
在文档末尾插入一个(使用\AtEndDocument
)。此标签被检索并用于计算(得益于可扩展\getrefnumber
的refcount
) 来反转编号。
对于每个文档的多个参考书目,您可以\citesinthissection{<num>}
按以下定义使用:
\documentclass{moderncv}
\usepackage[defernumbers=true]{biblatex}
\makeatletter
\newcommand{\citesinthissection}[1]{\xdef\@totalcites{#1}}
% https://tex.stackexchange.com/q/123805/5764
\defbibenvironment{bibliography}
{\list
{\printtext[labelnumberwidth]{% label format from numeric.bbx
\printfield{prefixnumber}%
\number\numexpr\@totalcites-\abx@field@labelnumber+1\relax}}
{\setlength{\topsep}{0pt}% layout parameters from moderncvstyleclassic.sty
\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{biblatex-examples.bib}
\begin{document}
\makecvtitle
\nocite{companion,knuth:ct:a,knuth:ct:b}
\citesinthissection{3}% There are 3 cites in this section
\printbibliography[notkeyword=primary,title={Publications}]
\nocite{aristotle:anima,aristotle:physics}
\citesinthissection{2}% There are 2 cites in this section
\printbibliography[keyword=primary,resetnumbers=true,title={Other Publications}]
\end{document}
记住,每当您向参考书目添加元素时,都要更新项目数。从第二个开始使用defernumbers=true
全局选项和选项。您可能需要使用/ options 之类的选项,以便在每个参考书目部分中准确打印您想要的内容。resetnumbers=true
\printbibliography
keyword
notkeyword