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