Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to number bibliography items in the reverse order -- with moderncv and plainnat bibliography style.

Reference:

Enrico's answer at: Bibtex reverse numbering

I tried with Enrico's code, but with moderncv and plainnat (as I want issn, doi etc). But I could not succeed without any errors and warnings.

Here is the code that does not work at all. Sorry for the big code, but it contains necessary bib data and actual code is at the bottom and is minimal. This needs that modercv.cls and .sty files (from http://www.LaTeXTemplates.com) be put in the same directory.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% "ModernCV" CV and Cover Letter
% LaTeX Template
% Version 1.1 (9/12/12)
%
% This template has been downloaded from:
% http://www.LaTeXTemplates.com
%
% Original author:
% Xavier Danaux (xdanaux@gmail.com)
%
% License:
% CC BY-NC-SA 3.0 (http://creativecommons.org/licenses/by-nc-sa/3.0/)
%
%% Important note:  %% <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
% This template requires the moderncv.cls and .sty files to be in the same
% directory as this .tex file. These files provide the resume style and themes
% used for structuring the document.

%%%--------------------------Uncomment if bib files are needed---------------------------------%%

%\begin{filecontents}{mypub.bib}
%@Article{johnson-74,
%  author =       "G. B. Johnson",
%  title =        "Enzyme Polymorphism",
%  journal =      "Science",
%  volume =       "184",
%  pages =        "28--37",
%  year =         "1974",
%}
%
%@Article{johnson-howells,
%  author =       "G. B. Johnson and W. W. Howells",
%  title =        "Title title title title title title title title title
%                 title",
%  journal =      "Journal journal journal",
%  year =         "1974",
%}
%
%@Article{johnson-etc,
%  author =       "G. B. Johnson and W. W. Howells and A. N. Other",
%  title =        "Title title title title title title title title title
%                 title",
%  journal =      "Journal journal journal",
%  year =         "1976",
%}
%
%@Manual{anon-67,
%  author =       "Anon.",
%  title =        "Title title title title title title title title title
%                 title",
%  organization = "Organization organization organization",
%  year =         "1967",
%}
%
%@Article{aslin-49,
%  author =       "E. J. Aslin",
%  title =        "Photostat recording in library work",
%  journal =      "Aslib Proceedings",
%  year =         "1949",
%  volume =       "1",
%  pages =        "49--52",
%}
%
%@Article{fletcher-hopkins,
%  author =       "W. M. Fletcher and F. G. Hopkins",
%  title =        "Lactic Acid in Amphibian Muscle",
%  journal =      "J. Physiol.",
%  year =         "1907",
%  volume =       "35",
%  pages =        "247--309",
%}
%
%\end{filecontents}
%%%-conference bib data --------------------------
%\begin{filecontents}{mypub-conf.bib}
%@CONFERENCE{Raja2007a,
%  author = { R. Ganesh and Harish Kumar},
%  title = {Title of the paper Power Industry},
%  booktitle = {39\textsuperscript{th} North American Power Symposium},
%  year = {2007},
%  number = {978-1-4244-1726-1},
%  address = {USA},
%  month = {September 10--14,},
%  organization = {New Mexico State University},
%  publisher = {IEEE},
%  owner = {Anupama},
%  timestamp = {2013.01.26}
%}
%
%@CONFERENCE{Rac2010,
%  author = {R. Rajesh and Harish Kumar},
%  title = {Title of the paper Transfer Capability},
%  booktitle = {International Conference on Computer Applications in Electrical Engineering
%   Recent Advances},
%  year = {2010},
%  address = {Roorkee},
%  month = {February 19--21,},
%  organization = {IIT Roorkee},
%  publisher = {IEEE},
%  owner = {hcl},
%  timestamp = {2013.01.24}
%}
%
%@CONFERENCE{CRa2009,
%  author = {R. Rajesh and Harish Kumar},
%  title = {Title of the paper Using Differential Evolution},
%  booktitle = {International Conference on Control, Automation, Communication and
%   Energy Conservation},
%  year = {2009},
%  address = {Erode},
%  month = {June 4--6,},
%  publisher = {IEEE},
%  owner = {Anupama},
%  timestamp = {2013.01.26}
%}
%
%@CONFERENCE{Raj2007,
%  author = {R. Rajesh and Harish Kumar},
%  title = {Title of the paper deregulated
%   Environment},
%  booktitle = {International Conference on Power Systems},
%  year = {2007},
%  address = {Bangalore},
%  month = {December 12--14,},
%  organization = {Central Power Research Institute},
%  publisher = {IEEE}
%}
%
%@CONFERENCE{CRy2006,
%  author = {R. Rajesh and Harish Kumar},
%  title = {Title of the paper},
%  booktitle = {IEEE Power India Conference},
%  year = {2006},
%  number = {240},
%  address = {New Delhi},
%  month = {April 12--14,},
%  organization = {IIT Delhi},
%  publisher = {IEEE}
%}
%\end{filecontents}

\documentclass[11pt,a4paper,sans]{moderncv}

\moderncvstyle{classic}
\moderncvcolor{orange}
\usepackage{uri}

%----------------------------------------------------------------------------------------
%   NAME AND CONTACT INFORMATION SECTION
%----------------------------------------------------------------------------------------

\firstname{Harish} % Your first name
\familyname{Kumar} % Your last name

% ????????????????? will this be needed???????????????//
\makeatletter
\renewcommand*{\bibliographyitemlabel}{\@biblabel{\arabic{enumiv}}}
\makeatother
%
%% bibliography with mutiple entries
\usepackage{multibib}
\newcites{journal,conference}{{Journals},{Conferences}}
\usepackage{natbib}
%%%------------------------------------------------------------------
%%% Reverse numbering of bibliography: Enrico's code from -- http://tex.stackexchange.com/a/75613/11232
\usepackage{etaremune}
\makeatletter
\long\def\thebibliography#1{%
  \subsection*{\refname}%
  \@mkboth{\MakeUppercase\refname}{\MakeUppercase\refname}
  \settowidth{\dimen0}{\@biblabel{#1}}%
  \setlength{\dimen2}{\dimen0}%
  \addtolength{\dimen2}{\labelsep}
  \sloppy
  \clubpenalty 4000
  \@clubpenalty
  \clubpenalty
  \widowpenalty 4000
  \sfcode `\.\@m
  \renewcommand{\labelenumiv}{\@biblabel{\theenumiv}} % labels like [3], [2], [1]
  \begin{etaremune}[labelwidth=\dimen0,leftmargin=\dimen2]\@openbib@code
}
\def\endthebibliography{\end{etaremune}}
\def\@bibitem#1{%
  \item \if@filesw\immediate\write\@auxout{\string\bibcite{#1}{\the\value{enumiv}}}\fi\ignorespaces
}
\makeatother

%%%------------------------------------------------------------------

\listfiles

%----------------------------------------------------------------------------------------

\begin{document}

\makecvtitle
%%------------------------------------------------------------------
\section{Publications}
\nocitejournal{*}
\bibliographystylejournal{plainnat}
\bibliographyjournal{mypub}
%
\nociteconference{*}
\bibliographystyleconference{plainnat}
\bibliographyconference{mypub-conf}

%----------------------------------------------------------------------------------------

\end{document}

Question:

How to get an output with references numbered in decreasing order using moderncv, plainnat, multibib all put together in action?

share|improve this question
    
There is no numbering, unless you use the numbers option to natbib. –  egreg Feb 2 '13 at 14:40
add comment

1 Answer

up vote 6 down vote accepted
+200

With natbib the thebibliography environment is defined in a very different way. The following proposal has a limitation: there will no anchor being set for hyperref, but it works as requested.

\documentclass[11pt,a4paper,sans]{moderncv}

\moderncvstyle{classic}
\moderncvcolor{orange}
\usepackage{uri}

%----------------------------------------------------------------------------------------
%   NAME AND CONTACT INFORMATION SECTION
%----------------------------------------------------------------------------------------

\firstname{Harish} % Your first name
\familyname{Kumar} % Your last name

%% bibliography with multiple entries
\usepackage{multibib}
\newcites{journal,conference}{{Journals},{Conferences}}
\usepackage[numbers]{natbib}
%%%------------------------------------------------------------------
%%% Reverse numbering of bibliography
\usepackage{etaremune,etoolbox}
\makeatletter
\AtBeginDocument{%%% natbib redefines the environment there
\renewenvironment{thebibliography}[1]
 {\bibsection\parindent\z@\bibpreamble\bibfont
  \settowidth{\dimen0}{#1.}%
  \setlength{\dimen2}{\dimen0}%
  \addtolength{\dimen2}{\labelsep}
  \begin{etaremune}[labelwidth=\dimen0,leftmargin=\dimen2]
  \ifNAT@openbib
    \renewcommand\newblock{\par}%
  \else
    \renewcommand\newblock{\hskip.11em \@plus .33em \@minus .07em}%
  \fi
  \sloppy
  \clubpenalty4000
  \widowpenalty4000
  \sfcode`\.\@m
  \let\NAT@bibitem@first@sw\@firstoftwo
  \let\citeN\cite\let\shortcite\cite\let\citeasnoun\cite}
 {\bibitem@fin\bibpostamble
  \def\@noitemerr{\PackageWarning{natbib}{Empty `thebibliography' environment}}%
  \end{etaremune}
  \bibcleanup}
}%%% end of \AtBeginDocument

%%% patch \@lbibitem to use only \item (for etaremune)
\patchcmd{\@lbibitem}{\item[\hfil\NAT@anchor{#2}{\NAT@num}]}{\item}{}{}
\makeatother

\begin{document}

\makecvtitle
%%------------------------------------------------------------------
\section{Publications}
\nocitejournal{*}
\bibliographystylejournal{plainnat}
\bibliographyjournal{mypub}
%
\nociteconference{*}
\bibliographystyleconference{plainnat}
\bibliographyconference{mypub-conf}

%----------------------------------------------------------------------------------------

\end{document}

enter image description here

share|improve this answer
    
Thanks, I will ry it out and get back with results. :-). BTW, how to get the brackets like [1] here instead of 1.? –  Harish Kumar Feb 2 '13 at 22:49
    
Thanks. I got it working. But it was too much hack with natbib. I did it hacking plainyr.bst also so as to add issn etc and with your old etaremune code. I have two methods now :-). Thank you. –  Harish Kumar Feb 3 '13 at 1:53
    
How would you add a prefix to each reference section? For instance, having the journals as J6, J5, ... and conferences as C5, C4.... –  Didac Busquets Oct 30 '13 at 11:22
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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