ref 和 autoref 中的字体样式

ref 和 autoref 中的字体样式

我想同时使用 \autoref 和 \ref,因此在列举文本中的参考文献时,我可以得到类似“Ecuaciones 1 y 2”的内容(带有课程 1是由 \autoref 插入的链接,并且2\ref 插入的链接)。问题是我需要文本中的所有引用都是无衬线的,但我无法让 \autoref 和 \ref 默认使用无衬线,并且在每种情况下插入 \textsf 或 \sffamily 也不切实际。使用此 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}

我明白了: 在此处输入图片描述

显示了不匹配的字体的混乱情况:塔布拉 0.0全部是衬线,智力测验是衬线字体,但是0.10.2是无衬线字体。

我尝试过类似的事情:

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

但这样做会破坏字幕的格式。

有没有办法获取无衬线字体的所有交叉引用?谢谢。

答案1

cleveref软件包会为您完成所有艰苦的工作:

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

在此处输入图片描述

相关内容