[Tex/LaTex] Bibliography with numbered style

bibliographiesbibtexnumbering

I am writing a paper and I need the references to be numbered, all the references are in a .bib file, I am using the journal template + bibtex, the packages I am using are:

\usepackage{natbib}
\usepackage{hyperref,url}
\newcounter{bibcount}

The journal commands are:

\newcommand\BibTeX{{\rmfamily B\kern-.05em \textsc{i\kern-.025em b}\kern-.08em
T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}
\def\volumeyear{2016}
\begin{document}

Then:

\bibliography{mybibfile}{}
\bibliographystyle{unsrtnat}

Now the pdf file is not appearing when I run, I have errors of:

  • Package natbib Error: Bibliography not compatible with author-year citations. …and\NAT@force@numbers{}\NAT@force@numbers
  • Overfull \hbox (10.09238pt too wide) in paragraph
  • h' float specifier changed toht'.
  • Underfull \hbox (badness 10000) in paragraph

The complete code (MWE):

\documentclass[Afour,sageh,times]{sagej}
\usepackage{moreverb,url}          
\usepackage[colorlinks,bookmarksopen,bookmarksnumbered,citecolor=red,urlcolor=red]{hyperref}
        \newcommand\BibTeX{{\rmfamily B\kern-.05em \textsc{i\kern-.025em                         b}\kern-.08em
        T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}

        \def\volumeyear{2016}
        %% Symbol and math packages
        \usepackage{mathtools}
        \usepackage{bm}
        \usepackage{amssymb}
        \usepackage{array}
        \usepackage[utf8]{inputenc}
        \usepackage[T1]{fontenc}
        \usepackage{textcomp}
        \usepackage{gensymb}

        %% Figure packages
        \usepackage{graphicx}
        \usepackage{float}
        \usepackage{subcaption}
        \usepackage{capt-of}
        \usepackage{natbib}
        \usepackage{hyperref,url}
        \newcounter{bibcount}
        \newcommand\BibTeX{{\rmfamily B\kern-.05em \textsc{i\kern-.025em 
         b}\kern-.08em
        T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}
        \def\volumeyear{2016}
        \begin{document}

        \section{Introduction}
        A very very very long introduction.

        \section{Figure}
        \begin{figure}[htb!] 
        \centering 
        \begin{subfigure}[t]{1\linewidth}
        \centering
        \includegraphics[scale=0.23,clip]{f1.png}
        \caption{f1 cap}
        \label{fig:f1}
        \end{subfigure}
        \qquad
        \begin{subfigure}[t]{1\linewidth}
        \centering
       \includegraphics[scale=0.21,clip]{f2.png}
       \caption{f2 cap}
       \label{fig:f2}
       \end{subfigure}
       \caption{ f1 and f2}
       \label{fig:f1f2}
       \end{figure}

       \section{Table}
       \begin{table}[h]
        \small\sf\centering
        \caption{abc\label{tab1}}
        \begin{tabular}{llll}
        \toprule
        abc&a &b & c \\
        \midrule
        \texttt{1}&1 &1   & 1 \\
        \texttt{2}&2  & 2   & 2\\
        \texttt{3}&3     & 3     & 3  \\
        \bottomrule
        \end{tabular}\\[10pt]
        \end{table}


        Citing reference \cite{R1}, reference \cite{R2} and reference \cite{R3}.

        \bibliography{bibsample}{}
        \bibliographystyle{sageV}
        \end{document}

In the bibsample.bib file we have:

@article{R1,
title = "A Guide to Latex",
journal = "Addison-Wesley",
volume = "1",
number = "1",
pages = "1 - 2",
year = "2003",,
author = "Kopka H and Daly PW",
}

@article{R2,
title = "LaTeX: a Document Preparation System",
journal = "Addison-Wesley",
volume = "1",
number = "1",
pages = "1 - 2",
year = "1994",,
author = "Lamport",
}



@article{R3,
title = "The  LaTeX  Companions",
journal = "Addison-Wesley",
volume = "1",
number = "1",
pages = "1 - 2",
year = "1994",,
author = "Mittelbach F and Goossens M",
}

Best Answer

In your given code and bib file are several errors, for example the order of calling packages (hyperref should be the last one in your case, or do not write ,, in your bib entrys, , is needed ...).

Because I do not have your used class and style I changed them to class article and style plainnat and I added option numbers to natbib to get numbered bib entrys in your bibliography.

Please study my changes in the following MWE (package filecontents is only used to have a compilable MWE with bib file and TeX code):

\RequirePackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{R1,
  title = "A Guide to Latex",
  journal = "Addison-Wesley",
  volume = "1",
  number = "1",
  pages = "1 - 2",
  year = "2003",
  author = "Kopka H and Daly PW",
}
@article{R2,
  title = "LaTeX: a Document Preparation System",
  journal = "Addison-Wesley",
  volume = "1",
  number = "1",
  pages = "1 - 2",
  year = "1994",
  author = "Lamport",
}
@article{R3,
  title = "The  LaTeX  Companions",
  journal = "Addison-Wesley",
  volume = "1",
  number = "1",
  pages = "1 - 2",
  year = "1994",
  author = "Mittelbach F and Goossens M",
}
\end{filecontents}


\documentclass{article}%[Afour,sageh,times]{sagej}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{textcomp}

\usepackage{subcaption}
\usepackage{graphicx}
\usepackage{booktabs}

\usepackage{url}
\usepackage[numbers]{natbib}
\usepackage[%
  colorlinks,bookmarksopen,bookmarksnumbered,citecolor=red,urlcolor=red
]{hyperref}

\newcommand\BibTeX{{\rmfamily B\kern-.05em \textsc{i\kern-.025em 
  b}\kern-.08em
  T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}
\def\volumeyear{2016}


\begin{document}

\section{Introduction}
A very very very long introduction.

\section{Figure}
\begin{figure}[htb!] 
\centering 
\begin{subfigure}[t]{1\linewidth}
    \centering
    \includegraphics[scale=0.23,clip]{example-image-a}
    \caption{f1 cap}
    \label{fig:f1}
    \end{subfigure}
    \qquad
    \begin{subfigure}[t]{1\linewidth}
    \centering
   \includegraphics[scale=0.21,clip]{example-image-b}
   \caption{f2 cap}
   \label{fig:f2}
\end{subfigure}
   \caption{ f1 and f2}
   \label{fig:f1f2}
\end{figure}

\section{Table}
\begin{table}[ht]
    \small\sf\centering
    \caption{abc\label{tab1}}
    \begin{tabular}{llll}
    \toprule
    abc&a &b & c \\
    \midrule
    \texttt{1}&1 &1   & 1 \\
    \texttt{2}&2  & 2   & 2\\
    \texttt{3}&3     & 3     & 3  \\
    \bottomrule
    \end{tabular}\\[10pt]
\end{table}


Citing reference \cite{R1}, reference \cite{R2} and reference \cite{R3}.

\bibliographystyle{plainnat} % sageV
\bibliography{\jobname}

\end{document}

and the resulting pdf file:

resulting pdf

Related Question