
Мне бы хотелось иметь возможность менять varioref
струны. В частности, on the facing page
одну.
Это не должно быть проблемой. В документации четко указаны различные используемые макросы, и я думаю, что я смогу изменить их с помощью:
\renewcommand\reftextfaceafter{on the following page}
\renewcommand\reftextafter {on the next page}
\renewcommand\reftextfacebefore{on the previous page}
\renewcommand\reftextbefore {on the previous page}
Это работает нормально, если только я не использую его babel
вместе с varioref
.
MWE следует:
\documentclass{book}
\usepackage[english]{babel} % works if this line is commented out
\usepackage{varioref}
\renewcommand\reftextfaceafter{on the following page}
\renewcommand\reftextafter {on the next page}
\renewcommand\reftextfacebefore{on the previous page}
\renewcommand\reftextbefore {on the previous page}
\begin{document}
empty page
\clearpage
\begin{figure}
\centering
\rule{5cm}{3cm}
\caption{Caption}
\label{fig}
\end{figure}
\clearpage
Figure \vref{fig}
\end{document}
решение1
Если вы поставите \renewcommand
s после \begin{document}
, то все будет работать нормально. Если вы поставите их в преамбуле, они будут перезаписаны, когда что-то будет настроено в конце преамбулы/начале документа.
Однако я не думаю, что размещение их после \begin{document}
— правильное решение. Посмотрите руководство повариореф, мы находим измененные инструкции для документов, которые используютвавилон. Они предлагают следующий код:
\documentclass[english]{book}
\usepackage{babel} % works if this line is commented out
\usepackage{varioref}
\addto\extrasenglish{% page 5 of varioref's manual
\renewcommand\reftextfaceafter{on the following page}%
\renewcommand\reftextafter {on the next page}%
\renewcommand\reftextfacebefore{on the previous page}%
\renewcommand\reftextbefore {on the previous page}%
}
\begin{document}
empty page
\clearpage
\begin{figure}
\centering
\rule{5cm}{3cm}
\caption{Caption}
\label{fig}
\end{figure}
\clearpage
Figure \vref{fig}
\end{document}
Обратите внимание, что при передаче english
в класс документа, а не напрямую в babel
, другие пакеты, поддерживающие язык, смогут подхватить настройку.
решение2
babel
выполняет некоторые переопределения прямо в \AtBeginDocument
, поэтому \renewcommand
макросы \ref....
должны быть подключены даже позже, т. е. использовать \AtBeginDocument{...}
вокруг \renewcommand
и изменения вступят в силу, поскольку это новое \AtBeginDocument
добавление контента выполняется после предыдущих. (В противном случае используйте подход, как предлагается в решении cfr -- это также \addto
упоминается в руководстве по пакету)varioref
\documentclass{book}
\usepackage[english]{babel} % works if this line is commented out
\usepackage{varioref}
\AtBeginDocument{%
\renewcommand\reftextfaceafter{on the following page}
\renewcommand\reftextafter{on the next page}
\renewcommand\reftextfacebefore{on the previous page}
\renewcommand\reftextbefore{on the previous page}
}
\begin{document}
empty page
\clearpage
\begin{figure}
\centering
\rule{5cm}{3cm}
\caption{Caption}
\label{fig}
\end{figure}
\clearpage
Figure \vref{fig}
\end{document}