varioref:更改預設的「在對頁上」字串

varioref:更改預設的「在對頁上」字串

我希望能夠更換琴弦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

如果你把\renewcommands 放在後面\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並且更改生效,因為此新內容添加是在先前的內容之後執行的。 (否則使用cfr 解決方案建議的 - 方法 - 這在軟體包手冊中也提到)\ref....\AtBeginDocument{...}\renewcommand\AtBeginDocument\addtovarioref

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

在此輸入影像描述

相關內容