4

When I use fancyref with the vario package option:

\usepackage[vario]{fancyref}
\newcommand{\figvref}[1]{\figurename~\vref{#1}}
\newcommand{\tabvref}[1]{\tablename~\vref{#1}}

The above would produce a result in such a way that, for example, when referencing a figure (lets say Figure 1) residing on the next page (lets say it is page 3), this would produce the following:

"bla bla bla as per Figure 1 on page 3"

However, I would like the 'page 3' part of the above to be formatted using the 'fmtcount' package:

\usepackage{fmtcount}
\newcommand{\wordnum}[1]{\numberstringnum{#1} (#1)}

Insomuch as that the above example should be formatted in the following manner:

"bla bla bla as per Figure 1 on page three (3)"

Can someone please let me know how to use fmtcount within fancyref?

  • Sorry but why are you using fancyref here at all? – cfr Jul 25 '15 at 13:17
  • Please give us an MWE rather than asking people to construct one from scratch. – cfr Jul 25 '15 at 13:20
  • Wouldn't this be easier with refcount and fmtcount? – user31729 Jul 25 '15 at 13:23
6

You can redefine \reftextfaraway using \vrefpagenum as detailed in the examples in varioref's manual: \vrefpagenum{<macro>}{<label>}. This saves the page number in <macro> and can then be used as argument to fmtcount's \numberstringnum:

\documentclass{article}
\usepackage{varioref,fmtcount}

\renewcommand*\reftextfaraway[1]{%
  \vrefpagenum\fignum{#1}%
  on page \numberstringnum{\fignum}~(\pageref{#1})%
}

\begin{document}

\figurename~\vref{fig:foo}

\newpage
\null\newpage
\null\newpage

\begin{figure}
  \caption{foo bar}\label{fig:foo}
\end{figure}

\end{document}
  • (+1) but, at least when combined with fancyref, this gives errors on first compilation. – cfr Jul 25 '15 at 22:01
  • @cfr If I use \usepackage{varioref,fmtcount,fancyref} (and delete the aux file) I don't get any errors. Also not with \usepackage{fmtcount}\usepackage[vario]{fancyref}. – clemens Jul 25 '15 at 22:30
  • This doesn't work with \pagenumbering{roman}, though. – clemens Jul 25 '15 at 22:30
  • I get an error if I add a new label with an \fref{that label} earlier in the document. The first time I compile after the additions, I get errors. The second time, it is fine as the info is available, I assume. – cfr Jul 25 '15 at 22:31
  • \documentclass{article} \usepackage{varioref,fmtcount} \usepackage[vario]{fancyref} \renewcommand*\reftextfaraway[1]{% \vrefpagenum\fignum{#1}% on page \numberstringnum{\fignum}~(\pageref{#1})% } \begin{document} \Fref{fig:foo} is on a distant page. % \Fref{sec:asec} is on the same page as \fref{fig:foo}. \newpage \null\newpage \null\newpage \Fref{fig:foo} is on this page. \begin{figure} \caption{foo bar}\label{fig:foo} \end{figure} % \section{sec}\label{sec:asec} \end{document} Compile twice. Then uncomment the lines. Compile once -> errors. Compile again -> OK. – cfr Jul 25 '15 at 22:33

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.