varioref: デフォルトの「向かい側のページ」文字列を変更する

varioref: デフォルトの「向かい側のページ」文字列を変更する

弦を変更できるようにしたいですvarioref。特に、on the facing page1 弦です。

問題はないはずです。ドキュメントには使用されているさまざまなマクロが明記されており、次の方法で変更できると思います。

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

ここに画像の説明を入力してください

関連情報