Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question

2 Answers 2

up vote 14 down vote accepted

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}
share|improve this answer
    
Thank you cmhughes for the answer... –  sandu May 4 '12 at 9:34

I recommend you to take a look at the package cleveref. According to its description:

[t]he package enhances LaTeX's cross-referencing features, allowing the format of references to be determined automatically according to the type of reference. The formats used may be customised in the preamble of a document.

I use it myself, and it is very flexible and configurable.

And here is a MWE, showing the use of cleveref:

\documentclass{article}
\usepackage{cleveref}

\begin{document}

\begin{equation}\label{eq:myequation}
    f(x)=x^2+\sin(x)
\end{equation}

Here is a reference to \cref{eq:myequation}. 

Here is a reference to the number alone:
\labelcref{eq:myequation}.

\emph{Here is another reference, see the upright  
reference number without any additional commands or  
packages:
 \cref{eq:myequation}.}

\end{document}

The use of labelformat in varioref has some limitations, which are described on page 5 in cleveref’s manual. cleveref has its own labelformat, also described in the manual (for more advance users).

You do not need to name the figure, tables or the page. A reference to an equation on another page in your manuscript is written:

See \cref{eq:myequation} on \cpageref{eq:myequation}
share|improve this answer
2  
Hi Sveinung, It is useful if you give a minimum working example. –  sandu May 5 '12 at 9:05
    
Thank you for MWE –  sandu Jul 7 '12 at 7:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.