[Tex/LaTex] Different fancyref strings for different reference targets

cross-referencingfancyref

I use fancyref with the default prefixes (chap:, fig: and so on). I'm not entirely happy with the way the references are generated when the referenced object is on a different page. For tables and figures, the package generates something like Abbildung 42 auf Seite 84 (figure 42 on page 84), which is acceptable. When referring to an entire chapter, the package uses the same text (Kapitel 4 auf Seite 50). In my opinion, that isn't entirely correct — the chapter is not placed on page 50, it starts on page 50 and may stretch across any number of pages. I'd rather like the \fref{} command to use a different text when referring to chapters and parts, like Kapitel 4 ab Seite 50. At the same time, the references to figures and tables should not change. Is this possible?

MWE

\documentclass{scrartcl}
\usepackage[ngerman]{babel} 
\usepackage[german]{fancyref}    
\usepackage{lipsum}

\begin{document}

\section{Einleitung}
\label{sec:A}
%\usepackage{graphics} is needed for \includegraphics
\begin{figure}[htp]
  Ze Figure
  \caption{A Figure}
  \label{fig:Foo}
\end{figure}
\lipsum[1-10]

\section{Überleitung}
\label{sec:B}
\lipsum[1-10]

\section{Weiterleitung}
Wie in \fref{sec:A} bereits erw"ahnt\ldots
% This reads "auf Seite 1", should be "ab Seite 1"

Wie in \fref{fig:Foo} zu erkennen ist\ldots
% This reads "auf Seite 1", which is acceptable and should not be changed

\end{document}

Best Answer

You can redefine the vario format for cross-references to sections so that it matches the plain one.

For example:

\documentclass[ngerman]{scrartcl}
\usepackage{babel}
\usepackage[german]{fancyref}
\usepackage{lipsum}
\frefformat{vario}{\fancyrefseclabelprefix}{%
      \frefsecname\fancyrefdefaultspacing#1}
\Frefformat{vario}{\fancyrefseclabelprefix}{%
      \Frefsecname\fancyrefdefaultspacing#1}

\begin{document}

\section{Einleitung}
\label{sec:A}
%\usepackage{graphics} is needed for \includegraphics
\begin{figure}[htp]
  Ze Figure
  \caption{A Figure}
  \label{fig:Foo}
\end{figure}
\lipsum[1-10]

\section{Überleitung}
\label{sec:B}
\lipsum[1-10]

\section{Weiterleitung}
Wie in \fref{sec:A} bereits erw"ahnt\ldots
% This reads "auf Seite 1", should be "ab Seite 1"

Wie in \fref{fig:Foo} zu erkennen ist\ldots
% This reads "auf Seite 1", which is acceptable and should not be changed

\end{document}

produces the desired output, if I've understood your question correctly:

plainer section references and fancier figure ones

Related Question