[Tex/LaTex] Adding Publication in moderncv template

bibtexmoderncv

How can I add the following publication (for example) in the moderncv template?

Albert Einstein. Zur Elektrodynamik bewegter K ̈orper. (German) [On the electrodynamics of moving bodies]. Annalen der Physik, 322(10):891–921,1905.

I have created a file called publication.bib where I stored the information:

 @article{einstein,
         author = "Albert Einstein",
         title = "{Zur Elektrodynamik bewegter K{\"o}rper}. ({German})
                [{On} the electrodynamics of moving bodies]",
         journal = "Annalen der Physik",
         volume = "322",
         number = "10",
         pages =  "891--921",
         year = "1905",
         DOI = "http://dx.doi.org/10.1002/andp.19053221004"
   }

Then I have called the publication.bib in document.tex.

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

 \moderncvcolor{green}   

 \usepackage[utf8]{inputenc}       

  \usepackage[scale=0.75]{geometry}

  \name{John}{Doe}
  \title{Resumé title}            

  \address{street and number}{postcode city}{country}

  \phone[mobile]{+1~(234)~567~890}         

  \phone[fixed]{+2~(345)~678~901}        

  \phone[fax]{+3~(456)~789~012}      

  \email{john@doe.org}         

  \homepage{www.johndoe.com}       

  \extrainfo{additional information}     

   \begin{document}

   \makecvtitle

   \section{Education}
   \cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description}  % arguments 3 to 6 can be left empty
  \cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description}


 \bibliographystyle{unsrt}
 \bibliography{publication}

 \end{document}

The document.tex run normally. But it doesn't show the information contained in publication.bib.

enter image description here

Why doesn't it showing the reference?

Best Answer

You nearly did it.

The only thing missing is that you need to use command \nocite{*} to tell BibTeX that all bib entrys should be added to the bibliography.

Please see the following MWE (I used filecontents to have bib file and tex code together in one MWE; important changing is marked with <========):

\RequirePackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@article{einstein,
  author  = "Albert Einstein",
  title   = "{Zur Elektrodynamik bewegter K{\"o}rper}. ({German})
              [{On} the electrodynamics of moving bodies]",
  journal = "Annalen der Physik",
  volume  = "322",
  number  = "10",
  pages   =  "891--921",
  year    = "1905",
  DOI     = "http://dx.doi.org/10.1002/andp.19053221004"
}
\end{filecontents*}


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

\moderncvcolor{green}   
\usepackage[utf8]{inputenc}       
\usepackage[scale=0.75]{geometry}

\name{John}{Doe}
\title{Resumé title}            
\address{street and number}{postcode city}{country}
\phone[mobile]{+1~(234)~567~890}         
\phone[fixed]{+2~(345)~678~901}        
\phone[fax]{+3~(456)~789~012}      
\email{john@doe.org}         
\homepage{www.johndoe.com}       
\extrainfo{additional information}     


\begin{document}

\makecvtitle

\section{Education}
\cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description}  % arguments 3 to 6 can be left empty
\cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description}

\nocite{*} % <==========================================================
\bibliographystyle{unsrt}
\bibliography{\jobname} % To use bib file created by filecontents

\end{document}

with the resulting page after compiling with pdflatex, bibtex, pdflatex, pdflatex:

resulting pdf