I am trying to reference equations in latex (I am writing in overleaf) and am using the code as in the official overleaf documentation i.e.
\begin{equation}\label{Emc2}
E=mc^2
\end{equation}
Einstein wrote his famous equation \ref{Emc2}, blah blah blah ....
However on compiling, the reference just shows as a pure number i.e.
Einstein wrote his famous equation 1, blah blah blah ….
whereas I would like the number reference in parentheses, as it is in most academic papers
Einstein wrote his famous equation (1), blah blah blah ….
I am surprised that I haven't been able to find documentation for this.
EDIT:
As requested, I am putting in more complete source code. I am writing in several files and have a control file:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{subfiles}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{a4wide}
\title{ }
\author{ }
\date{April 2019}
\begin{document}
\maketitle
\subfile{introduction.tex}
\subfile{math.tex}
\subfile{1.tex}
\subfile{2.tex}
\subfile{3.tex}
\subfile{4.tex}
\subfile{5.tex}
\bibliographystyle{unsrt}
\bibliography{ref.bib}
\end{document}
And an example of where I am putting in the equation and reference
\documentclass[1.tex]{subfiles}
\begin{document}
\section{.....}
..text..
\begin{equation}\label{PLT}
Z(\lambda) = \int_{\mathcal{C_x}} dz g(z) e^{-\frac{f(x)}{\lambda}}
\end{equation}
..text..
iv) The exact value of the integral \eref{PLT} is then given by...
Which shows up as
The exact value of the integral PLT is then given by…
Note that when I am compiling, I am doing so from my control file. All of the citations come out fine in squared brackets, and the references work when using \ref, but not when using \eref
Best Answer
You have two options; either use
(\ref{..})
or\eqref{..}
as noted out by @marmot in a comment. The latter requires addingamsmath
in your preamble.