![カスタム方程式環境の autoref 名をオーバーライドする](https://rvso.com/image/475708/%E3%82%AB%E3%82%B9%E3%82%BF%E3%83%A0%E6%96%B9%E7%A8%8B%E5%BC%8F%E7%92%B0%E5%A2%83%E3%81%AE%20autoref%20%E5%90%8D%E3%82%92%E3%82%AA%E3%83%BC%E3%83%90%E3%83%BC%E3%83%A9%E3%82%A4%E3%83%89%E3%81%99%E3%82%8B.png)
\autoref
カスタム名を使用する環境に基づいて、パッケージからhyperref
カスタム環境への参照を取得できませんequation
。カスタム名を使用する代わりに、このような参照では「方程式」が使用されます。
次の例を考えてみましょう。
\documentclass{article}
\usepackage{hyperref}
% Define a 'query' counter and environment, based on 'equation'
\newcounter{query}
\newenvironment{query}
{\refstepcounter{query}%
\renewcommand\theequation{Q\arabic{query}}\equation}
{\endequation}
% Attempt to override the name autoref uses for the query environment
\newcommand{\queryautorefname}{Query}
\begin{document}
A labelled instance of the query environment can be found below:
%
\begin{query}
\label{q:my_query}
Q(x) = ...
\end{query}
A reference to \autoref{q:my_query} using \texttt{autoref} uses the wrong name to refer to the environment (i.e., Equation rather than Query).
\end{document}
この問題 (例で説明されているように) は、この方法で作成された参照が、本来は「クエリ Q1」と読みたいところ、「方程式 Q1」と読み取られてしまうことです。これを実現するには、何を変更すればよいでしょうか。
これを機能させるための別の戦略(たとえば、環境の別の定義)も検討していますが、環境の内容が数式モードに設定され、環境のカウンターが他のカウンター(カウンターなど)から独立していることがquery
重要です。この場合、ではなくを使用すると問題が発生します。これは、使用しなければならないテンプレート/ドキュメント クラスとの組み合わせで問題が発生したためです。query
equation
cleveref
hyperref
svjour3
答え1
\documentclass{article}
\usepackage{hyperref}
% Define a 'query' counter and environment, based on 'equation'
\newcounter{query}
\makeatletter
\newenvironment{query}
{\stepcounter{query}%
\def\Hy@chapterstring{equation}%
\def\Hy@chapapp{query}%
\renewcommand\theequation{Q\arabic{query}}\equation}
{\endequation}
\makeatother
% Attempt to override the name autoref uses for the query environment
\newcommand{\queryautorefname}{Query}
\begin{document}
A labelled instance of the query environment can be found below:
%
\begin{query}
\label{q:my_query}
Q(x) = ...
\end{query}
A reference to \autoref{q:my_query} using \texttt{autoref} uses the wrong name to refer to the environment (i.e., Equation rather than Query).
\end{document}