6

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}
5

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

  • 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
6

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.

1

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.

  • 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. – user31729 May 23 '14 at 13:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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