2

I'd like to use both \autoref and \ref, so when enumerating references in the text I can get something like "Ecuaciones 1 y 2" (with Ecuación 1 being a link inserted by \autoref and 2 a link inserted by \ref). The problem is that I need all the references in the text to be sans serif, but I can't get \autoref and \ref to use sans serif by default, and inserting \textsf or \sffamily in every case wouldn't be practical. With this MWE:

\documentclass[twoside, 11pt]{book}
\usepackage[utf8]{inputenc}
\usepackage[spanish, es-noindentfirst, es-nosectiondot]{babel}
\renewcommand{\theequation}{\sffamily\thechapter.\arabic{equation}}
\renewcommand{\thetable}{\thechapter.\arabic{figure}}
\usepackage[font={sf, footnotesize}]{caption}
\usepackage[colorlinks=true]{hyperref}

\begin{document}

Este texto es sólo para incluir las referencias a la \autoref{tab:prueba}, la \autoref{eq:ecuacion1} y la \ref{eq:ecuacion2}.

\begin{table}
\begin{center}
\caption{Prueba de tabla.}
\label{tab:prueba}
\begin{tabular}{c c c}
Columna 1 & Columna 2 & Resultados\\
1 & 1 & 2
\end{tabular}
\end{center}
\end{table}

\begin{equation}
\label{eq:ecuacion1}
1 + 1 = 2
\end{equation}

\begin{equation}
\label{eq:ecuacion2}
1 + 1 = 2
\end{equation}

\end{document}

I get this: enter image description here

which shows a terrible mess of mismatched fonts: Tabla 0.0 is all serif, Ecuación is in serif, but 0.1 and 0.2 are sans serif.

I tried things like:

\renewcommand{\thetable}{\sffamily\thechapter.\arabic{table}}

but doing so ruins the formatting of the captions.

Is there any way of getting all cross references in sans serif? Thanks.

2

The cleveref package does all the hard work for you:

\documentclass[twoside, 11pt,spanish]{book}
\usepackage[utf8]{inputenc}
\usepackage[spanish, es-noindentfirst, es-nosectiondot]{babel}
%\renewcommand{\theequation}{\sffamily\thechapter.\arabic{equation}}
%\renewcommand{\thetable}{\thechapter.\arabic{figure}}
\usepackage[font={sf, footnotesize}]{caption}
\usepackage[colorlinks=true]{hyperref}

\usepackage[capitalise,nameinlink,noabbrev]{cleveref}


\makeatletter
\def\@setcref{\sffamily\@@setcref{cref}}%
\makeatother

\begin{document}

Este texto es sólo para incluir las referencias a la \cref{tab:prueba}, la \cref{eq:ecuacion1,eq:ecuacion2}.

\begin{table}
\begin{center}
\caption{Prueba de tabla.}
\label{tab:prueba}
\begin{tabular}{c c c}
Columna 1 & Columna 2 & Resultados\\
1 & 1 & 2
\end{tabular}
\end{center}
\end{table}

\begin{equation}
\label{eq:ecuacion1}
1 + 1 = 2
\end{equation}

\begin{equation}
\label{eq:ecuacion2}
1 + 1 = 2
\end{equation}

\end{document}

enter image description here

  • Thank you so much for your help! (and quick answer). It solved my problem. – Pertrecho Dec 5 '18 at 16:32
  • @Pertrecho Glad to hear that your problem is solved! – book Dec 5 '18 at 17:11

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.