If you just wish to reverse the numbering - not the order - then you can use the following approach:
\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}
The idea is to count the number of references by tapping into each "\bibitem
". Once all is counted, we insert a \label
at the end of the document (using \AtEndDocument
). This label is retrieved and used in a calculation (thanks to the expandable \getrefnumber
from refcount
) to reverse the numbering.
For multiple bibliographies per document, you could use \citesinthissection{<num>}
as defined below:
\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}
Remember to update the count of items whenever you add elements to your bibliography. Use the defernumbers=true
global option and resetnumbers=true
option from the second \printbibliography
onwards. You may need to use options like keyword
/notkeyword
options in order to print exactly only what you want in each bibliography part.
You could write something like that
\newif\ifnumericCVbibliography
\numericCVbibliographytrue % replace true with false to disable
\newlength{\hintscolumnwidthV}
\setlength\hintscolumnwidthV{\hintscolumnwidth}
\ifnumericCVbibliography
\usepackage[backend = biber,
style = nature,
sorting = none
]{biblatex}
\def\printbibnumber{\hspace*{1.5em}%
\llap{\printtext[labelnumberwidth]{%
\printfield{prefixnumber}%
\printfield{labelnumber}%
}%
}%
}
\addtolength\hintscolumnwidthV{-1.75em}
\else
\usepackage[backend = biber,
style = authoryear,
sorting = none
]{biblatex}
\def\printbibnumber\relax
\fi
and then use the \printnumber
macro before your \tldatecventryV
.
The \hspace{1.5em}
makes room for two-digit numbers.
Complete (working, I hope) example:
\documentclass[sans]{moderncv}
\moderncvstyle{classic}
\moderncvcolor{orange}
\usepackage[scale=0.75]{geometry}
\usepackage{moderntimeline}
\tlmaxdates{1888}{1929}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@Article{Jones1929,
author = {Jones, Grinnell and Dole, Malcolm},
title = {THE VISCOSITY OF AQUEOUS SOLUTIONS OF STRONG ELECTROLYTES},
journaltitle = {J. Am. Chem. Soc.},
date = {1929},
volume = {51},
number = {10},
pages = {2950--2964},
doi = {10.1021/ja01385a012}
}
@Article{Drude1894,
author = {Drude, P. and Nernst, W.},
title = {{\"U}ber Elektrostriktion durch freie Ionen},
journaltitle = {Z. Phys. Chem.},
date = {1894},
volume = {15},
pages = {79--85},
}
@Article{Hofmeister1888,
author = {Hofmeister, Franz},
title = {Zur Lehre von der Wirkung der Salze},
journaltitle = {Arch. Exp. Pathol. Pharmakol.},
date = {1888},
volume = {25},
number = {1},
pages = {1--30},
doi = {10.1007/BF01838161},
}
\end{filecontents*}
%-----------------------------------------------------------
\newif\ifnumericCVbibliography
\numericCVbibliographytrue % replace true with false to disable
\newlength{\hintscolumnwidthV}
\setlength\hintscolumnwidthV{\hintscolumnwidth}
\ifnumericCVbibliography
\usepackage[backend = biber,
style = nature,
sorting = none
]{biblatex}
\def\printbibnumber{\hspace*{1.5em}%
\llap{\printtext[labelnumberwidth]{%
\printfield{prefixnumber}%
\printfield{labelnumber}%
}%
}%
}
\addtolength\hintscolumnwidthV{-1.75em}
\else
\usepackage[backend = biber,
style = authoryear,
sorting = none
]{biblatex}
\def\printbibnumber\relax % do nothing
\fi
\addbibresource{\jobname.bib}
%-----------------------------------------------------------
\makeatletter
\newcommand*{\cventryV}[1][.25em]{}
% for numeric bibliography
\newcommand{\tldatecventryV}[2][color1]{%
\issincefalse
\tl@formatstartyear{#2}
\cventryV{\tikz[baseline=0pt]{
\useasboundingbox (2ex,0ex) rectangle (\hintscolumnwidthV,1ex);
\fill [\tl@runningcolor] (0,0)
rectangle (\hintscolumnwidthV,\tl@runningwidth);
\fill [#1] (0,0)
++(\tl@startfraction*\hintscolumnwidthV,0pt)
node [tl@singleyear] {#2}
node {$\bullet$};
}}}
\makeatother
% 'numeric' bibliography environment (from numeric.bbx)
\defbibenvironment{bibliography}
{\list
{\printbibnumber % here you see the macro in action
\tldatecventryV{%
\thefield{year} % actual year from bibitem
}}
{\setlength{\topsep}{0pt}% layout parameters based on moderncvstyleclassic.sty
\setlength{\labelwidth}{\hintscolumnwidth}%
\setlength{\labelsep}{\separatorcolumnwidth}%
\setlength{\itemsep}{\bibitemsep}%
\leftmargin\labelwidth%
\addtolength{\leftmargin}{-.35\labelsep}% <-- changed
\advance\leftmargin\labelsep
}%
\sloppy\clubpenalty4000\widowpenalty4000}
{\endlist}
{\item}
%-----------------------
\AtEveryBibitem{\clearfield{year}}
%-------------------------------------------------------------------------------
% reverse numbering of publications
%-------------------------------------------------------------------------------
% Count total number of entries in each refsection
\AtDataInput{%
\csnumgdef{entrycount:\therefsection}{%
\csuse{entrycount:\therefsection}+1}}
% Print the labelnumber as the total number of entries in the
% current refsection, minus the actual labelnumber, plus one
\DeclareFieldFormat{labelnumber}{\mkbibdesc{#1}}
\newrobustcmd*{\mkbibdesc}[1]{%
\number\numexpr\csuse{entrycount:\therefsection}+1-#1\relax}
%------------------- Personal Data for CV header -------------------------------
\name{Joan}{Doe}
%-------------------------------------------------------------------------------
\begin{document}
\makecvtitle
\nocite{*}
\printbibliography[type=article,title={Journal Publications}]
\end{document}
Best Answer
\defbibenvironment
pretty much takes the same arguments as\newenvironment
. For the standard numeric styles the default bibliography environment is defined innumeric.bbx
. You can adapt this definition to use the list layout parameters formoderncv
'sthebibliography
environment. The following document takes the parameters frommoderncvstyleclassic.sty
.