You mixed here two things.
First: The part
\RequirePackage{filecontents}
\begin{filecontents}{\jobname.bib} % <===========================================
@BOOK{Human:1,
title = {{R}ocket {P}ropulsion {E}lements},
publisher = {John Wiley Sons},
author = Name J.~E.},
year = {2017},
edition = {4th},
}
@ARTICLE{Person:2,
author = {Jones, A.~B. and Smith, J.~M.},
title = {{A}rticle {T}itle},
journal = {{J}ournal {T}itle},
year = {2013},
volume = {13},
pages = {123-456},
number = {52},
month = {March},
publisher = {Publisher}
}
\end{filecontents}
is only used to build an compilable MWE including TeX code and bib
file. Suppose you have the file mwe.tex
then \jobname.bib
is changed to mwe.bib
to be accessable from the MWE.
Usually you have a file mybib.bib
you can address to you code (if it is in the same directory) with \bibliography{mybib}
Please see that the extention .bib
is ommitted.
So in your case simply use
\RequirePackage{filecontents}
\begin{filecontents}{\jobname.bib}
@BOOK{Human:1,
title = {{R}ocket {P}ropulsion {E}lements},
publisher = {John Wiley Sons},
author = Name J.~E.},
year = {2017},
edition = {4th},
}
@ARTICLE{Person:2,
author = {Jones, A.~B. and Smith, J.~M.},
title = {{A}rticle {T}itle},
journal = {{J}ournal {T}itle},
year = {2013},
volume = {13},
pages = {123-456},
number = {52},
month = {March},
publisher = {Publisher}
}
\end{filecontents}
\documentclass[11pt,a4paper,oneside]{article}
\usepackage{natbib}
\usepackage{url}
\usepackage[utf8x]{inputenc}
\usepackage{siunitx}
\usepackage{indentfirst}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usetikzlibrary{patterns}
\usepackage{caption}
\usepackage{pgfplots}
\usepackage{listings}
\usepackage{color}
\usepackage{graphicx}
\graphicspath{{images/}}
\usepackage{parskip}
\usepackage{cite}
\usepackage{fancyhdr}
\usepackage{vmargin}
\setmarginsrb{3 cm}{2.5 cm}{3 cm}{2.5 cm}{1 cm}{1.5 cm}{1 cm}{1.5 cm}
\usepackage[colorlinks]{hyperref} % <===============================================
\title{Life is too short to learn LaTeX} % Title
\author{Rageful} % Author
\date{01.01.2019} % Date
\makeatletter
\let\thetitle\@title
\let\theauthor\@author
\let\thedate\@date
\makeatother
\pagestyle{fancy}
\fancyhf{}
\rhead{\theauthor}
\lhead{\thetitle}
\cfoot{\thepage}
\renewcommand{\refname}{Referance}
\begin{document}
\begin{titlepage}
\centering
\vspace*{0.5 cm}
\includegraphics[scale = 0.08]{latex.png}\\[1.0 cm]
{\centering \textsc{\LARGE \ \ \ \ \ \ \ \ \ LATEX} \newline\newline \textsc{\LARGE PROJECT}\\[2.0 cm]}
\textsc{\Large 17.01.2019}\\[0.5 cm]
\rule{\linewidth}{0.2 mm} \\[0.4 cm]
{ \huge \bfseries \thetitle}\\
\rule{\linewidth}{0.2 mm} \\[3.5 cm]
\begin{minipage}{0.5\textwidth}
\begin{flushleft} \large
\emph{Person A}\\
\end{flushleft}
\end{minipage}~
\begin{minipage}{0.4\textwidth}
\begin{flushright} \large
\emph{Person B :} \\
\end{flushright}
\end{minipage}\\[2 cm]
\end{titlepage}
\section{Preface}
Why is LaTeX too hard? \cite{NAME:1}
\newpage
\bibliographystyle{unsrt}
\bibliography{\jobname} % bibliography prints here
\end{document}
to show your issue with an MWE.
SECOND: in real simply use
file mybib.bib
@BOOK{Human:1,
title = {{R}ocket {P}ropulsion {E}lements},
publisher = {John Wiley Sons},
author = Name J.~E.},
year = {2017},
edition = {4th},
}
@ARTICLE{Person:2,
author = {Jones, A.~B. and Smith, J.~M.},
title = {{A}rticle {T}itle},
journal = {{J}ournal {T}itle},
year = {2013},
volume = {13},
pages = {123-456},
number = {52},
month = {March},
publisher = {Publisher}
}
and the productive tex code, for example test.tex
(see command \bibliography{mybib}
at the end):
\documentclass[11pt,a4paper,oneside]{article}
\usepackage{natbib}
\usepackage{url}
\usepackage[utf8x]{inputenc}
\usepackage{siunitx}
\usepackage{indentfirst}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usetikzlibrary{patterns}
\usepackage{caption}
\usepackage{pgfplots}
\usepackage{listings}
\usepackage{color}
\usepackage{graphicx}
\graphicspath{{images/}}
\usepackage{parskip}
\usepackage{cite}
\usepackage{fancyhdr}
\usepackage{vmargin}
\setmarginsrb{3 cm}{2.5 cm}{3 cm}{2.5 cm}{1 cm}{1.5 cm}{1 cm}{1.5 cm}
\usepackage[colorlinks]{hyperref} % <===============================================
\title{Life is too short to learn LaTeX} % Title
\author{Rageful} % Author
\date{01.01.2019} % Date
\makeatletter
\let\thetitle\@title
\let\theauthor\@author
\let\thedate\@date
\makeatother
\pagestyle{fancy}
\fancyhf{}
\rhead{\theauthor}
\lhead{\thetitle}
\cfoot{\thepage}
\renewcommand{\refname}{Referance}
\begin{document}
\begin{titlepage}
\centering
\vspace*{0.5 cm}
\includegraphics[scale = 0.08]{latex.png}\\[1.0 cm]
{\centering \textsc{\LARGE \ \ \ \ \ \ \ \ \ LATEX} \newline\newline \textsc{\LARGE PROJECT}\\[2.0 cm]}
\textsc{\Large 17.01.2019}\\[0.5 cm]
\rule{\linewidth}{0.2 mm} \\[0.4 cm]
{ \huge \bfseries \thetitle}\\
\rule{\linewidth}{0.2 mm} \\[3.5 cm]
\begin{minipage}{0.5\textwidth}
\begin{flushleft} \large
\emph{Person A}\\
\end{flushleft}
\end{minipage}~
\begin{minipage}{0.4\textwidth}
\begin{flushright} \large
\emph{Person B :} \\
\end{flushright}
\end{minipage}\\[2 cm]
\end{titlepage}
\section{Preface}
Why is LaTeX too hard? \cite{NAME:1}
\newpage
\bibliographystyle{unsrt}
\bibliography{mybib} % bibliography prints here <====================
\end{document}
Please see that I changed the order of calling hyperref
: in your case is should be called last and do not call packages twice (I deleted the second call of hyperref
in the code above) ...
UPDATE:
Now let us have a look on your given code. There are some issues too:
You called package cite
causing the error you mentioned. Please read the documentation of cite
with typing texdoc cite
on your terminal/console. If you want to use package cite
, you need to delete the call of natbib
(you can not use both together) and use \bibliographystyle{unsrt}
.
If you want to use natbib
(please read documentation with texdoc natbib
on your console/terminal) you need to delete the call of cite
and to change the used bibliography style to \bibliographystyle{unsrtnat}
. To get numbered bib entries add option numbers
to natbib
: \usepackage[numbers]{natbib}
. For the following MWE I choosed this variant ...
In your bib entry Human:1
is a {
missing for author:
@BOOK{Human:1,
title = {{R}ocket {P}ropulsion {E}lements},
publisher = {John Wiley Sons},
author = {Name J.~E.},
year = {2017},
edition = {4th},
}
In your bib file is no bib entry NAME:1
you call in your tex code. I changed it to Human:1
.
Now please see the following compilable code
\RequirePackage{filecontents}
\begin{filecontents}{\jobname.bib}
@BOOK{Human:1,
title = {{R}ocket {P}ropulsion {E}lements},
publisher = {John Wiley Sons},
author = {Name J.~E.},
year = {2017},
edition = {4th},
}
@ARTICLE{Person:2,
author = {Jones, A.~B. and Smith, J.~M.},
title = {{A}rticle {T}itle},
journal = {{J}ournal {T}itle},
year = {2013},
volume = {13},
pages = {123--456},
number = {52},
month = {March},
publisher = {Publisher},
}
\end{filecontents}
\documentclass[11pt,a4paper]{article}
\usepackage[numbers]{natbib} % <===================================
\usepackage{url}
\usepackage[utf8x]{inputenc}
\usepackage{siunitx}
\usepackage{indentfirst}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usetikzlibrary{patterns}
\usepackage{caption}
%\usepackage{pgfplots} % <========================= not needed for issue
\usepackage{listings}
\usepackage{color}
\usepackage{graphicx}
\graphicspath{{images/}}
\usepackage{parskip}
\usepackage{fancyhdr}
\usepackage{vmargin}
\setmarginsrb{3 cm}{2.5 cm}{3 cm}{2.5 cm}{1 cm}{1.5 cm}{1 cm}{1.5 cm}
\usepackage[colorlinks]{hyperref} % <===============================================
\title{Life is too short to learn LaTeX} % Title
\author{Rageful} % Author
\date{01.01.2019} % Date
\makeatletter
\let\thetitle\@title
\let\theauthor\@author
\let\thedate\@date
\makeatother
\pagestyle{fancy}
\fancyhf{}
\rhead{\theauthor}
\lhead{\thetitle}
\cfoot{\thepage}
\renewcommand{\refname}{Referance}
\begin{document}
\begin{titlepage}
\centering
\vspace*{0.5 cm}
\includegraphics[scale = 0.08]{example-image}\\[1.0 cm]
{\centering \textsc{\LARGE \ \ \ \ \ \ \ \ \ LATEX} \newline\newline \textsc{\LARGE PROJECT}\\[2.0 cm]}
\textsc{\Large 17.01.2019}\\[0.5 cm]
\rule{\linewidth}{0.2 mm} \\[0.4 cm]
{ \huge \bfseries \thetitle}\\
\rule{\linewidth}{0.2 mm} \\[3.5 cm]
\begin{minipage}{0.5\textwidth}
\begin{flushleft} \large
\emph{Person A}\\
\end{flushleft}
\end{minipage}~
\begin{minipage}{0.4\textwidth}
\begin{flushright} \large
\emph{Person B :} \\
\end{flushright}
\end{minipage}\\[2 cm]
\end{titlepage}
\section{Preface}
Why is LaTeX too hard? \cite{Human:1}
\newpage
\bibliographystyle{unsrtnat} % <==================================
\bibliography{\jobname} % bibliography prints here
\end{document}
and the resulting pdf:
At last a remark: your used \ \ \ \ \ \ \ \ \
to build your title page is wrong. Better use \vspace{3cm}
and change the used value for your needs ...
\begin{filecontents}{\water.bib}
correct? Should it be\begin{filecontents}{water.bib}
?\water
towater
, (b) not load thenatbib
package (since it's a mistake to load bothnatbib
andcite
), (c) in the entryHuman:1
, changeauthor = Name J.~E.}
toauthor = {Name J.~E.}
(can you spot the missing{
symbol?), and (d) used\cite
commands to cite eitherHuman:1
orPerson:2
. Your code currently features\cite{NAME:1}
, but you do not provide an entry with keyNAME:1
...