[Tex/LaTex] \veqref{} command like \vref…from varioref package

cleverefcross-referencingvarioref

1) The varioref package gives \vref, which gives output as follows…

figure~\ref{fig:test} on page~\pageref{fig:test}.

2) The amsmath package gives \eqref{}, which gives output as follows…

equation (1.5) ie instead of printing a plain number as 1.5, it will print (1.5)

Now, the question is… is there any command like "`veqref`", which can give out put as

equation~\eqref{eq:test} on page~\pageref{eq:test}, something like equation (1.5) on page 30

I did not know how to do this…


Thank you cmhughes for the answer…

I added Eq.~ as follows…

\labelformat{equation}{Eq.~\tagform@{#1}}

A little more example…

\documentclass{book}
\usepackage{amsmath}
\usepackage{varioref}


% this bit makes sure that the number is typeset upright- needs amsmath
\makeatletter
\labelformat{equation}{Eq.~\tagform@{#1}}
\makeatother

\begin{document}

\chapter{One}
Bla bla bla...
\begin{equation}\label{eq:myequation}
    f(x)=x^2+\sin(x)
\end{equation}
Here is a reference: \vref{eq:myequation}.
\emph{Here is another reference: \vref{eq:myequation}.}

\clearpage
Bla bla bla...\\
See \vref{eq:myequation} and use it.

\chapter{Two}
Bla bla bla...\\
See \vref{eq:myequation} and use it.


\end{document}

Best Answer

Section 2.3 of the documentation details that you can use

\labelformat{equation}{(#1)}

so that \vref works as you would want it to for equations.

In fact, following egreg's comment, one should have the reference typeset upright, even if it is contained in environment that is (for example) italic.

enter image description here

A complete MWE follows.

\documentclass{article}
\usepackage{amsmath}
\usepackage{varioref}

% this bit makes sure that the number is typeset upright- needs amsmath
\makeatletter
\labelformat{equation}{\tagform@{#1}}
\makeatother

\begin{document}

\begin{equation}\label{eq:myequation}
    f(x)=x^2+\sin(x)
\end{equation}
Here is a reference: \vref{eq:myequation}.

\emph{Here is another reference: \vref{eq:myequation}.}
\end{document}
Related Question