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.

I want to use \vpageref and have a comma right after it. The problem is that a space is inserted even though I defined \reftextcurrent to be {}. In the example below I could fix this by adding the [] to \vpageref, but in my book this trick somehow does not work. Is the additional space a bug? How can I fix it?

\documentclass{article}
\usepackage{varioref}
\renewcommand{\reftextcurrent}{}

\begin{document}

\section{Test}

I have a problem with Figure~\ref{test}\vpageref[]{test}, which I cannot solve.

\begin{figure}[b]

\caption{A figure}
\label{test}
\end{figure}


\end{document}
share|improve this question

3 Answers 3

up vote 5 down vote accepted

Use the starred version \vpageref* or, even better, replace the \ref/\vpageref combo with \vref.

(The additional space before [!] \vpageref is an unfortunate design decision; see section 2.2. of the varioref manual for details.)

\documentclass{article}

\usepackage{varioref}

\renewcommand{\reftextcurrent}{}

\begin{document}

\section{Test}

I have a problem with Figure~\ref{test}\vpageref*{test}, which I cannot solve.

I have a problem with Figure~\vref{test}, which I cannot solve.

\begin{figure}[b] 
\caption{A figure}
\label{test}
\end{figure}

\end{document}

enter image description here

share|improve this answer
    
Thanks! How silly not to take \vref in the first place. I use it at other places, but started with \ref and then thought about adding the page reference. Thanks anyway. Maybe we delete this question. Sort of embarrassing ... –  Stefan Müller Oct 11 '12 at 19:49

I just defined me a \aref command which automatically adds the Prefix like Figure, ... and it adds the page reference if needed.

The code is:

\def\aref#1{\autoref{#1}\vpageref*{#1}}
\renewcommand{\reftextcurrent}{\unskip}
\renewcommand{\reftextbefore}{\ auf der vorherigen Seite}
\renewcommand{\reftextfacebefore}{\ auf der vorherigen Seite}
\renewcommand{\reftextafter}{\ auf der nächsten Seite}
\renewcommand{\reftextfaceafter}{\ auf der nächsten Seite}
\renewcommand{\reftextfaraway}[1]{\ auf Seite \pageref{#1}}

Just use it as normal \aref{fig:Figure1}.

Maybe it helps somebody, Michael v.W.

share|improve this answer
    
Please add a full answer which shows the output of your command as well, such that other users can copy-&-paste the answer to test. –  Christian Hupfer May 23 at 13:51

As an alternative (perhaps you've already written the book in a specific style, without knowing about \vpageref* or \vref...), you can

\renewcommand{\reftextcurrent}{\unskip}

This removes the skip that you see, and you don't have to change your code.

share|improve this answer

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.