选择性关闭 varioref 标签格式

选择性关闭 varioref 标签格式

varioref\labelformat引入了可以自动渲染\ref{sec:...}为等的命令section~。此功能对于节省一些输入并使一切变得灵活非常有用(特别是在处理可以改变类型的定理环境时)。

但是,有时你会想关闭它以进行个别引用。例如,我可能想渲染下面代码中的最后一行,但The sections~1 and~2 tell the whole story.由于\labelformatThe sections~section~1 and~section~section~2 tell the whole story. 如何关闭个别参考的标签格式?

\documentclass{article}

\usepackage{varioref}

\labelformat{section}{section~#1}

\let\varref\ref %make me some other command \varref that omits "section"

\begin{document}
    \section{Once upon a time\ldots}\label{sec:once}

    There was a king.

    \section{And then\ldots}\label{sec:then}

    This was already told in \ref{sec:once}.

    \section{Conclusion}

    The sections~\varref{sec:once} and~\varref{sec:then} tell the whole story.
\end{document}

答案1

你滥用了varioref。请cleveref改用:

\documentclass{article}

\usepackage{cleveref}

\begin{document}

\section{Once upon a time\ldots}\label{sec:once}

There was a king.

\section{And then\ldots}\label{sec:then}

This was already told in \cref{sec:once}.

\section{Conclusion}

The \cref{sec:once,sec:then} tell the whole story.

\end{document}

在此处输入图片描述

相关内容