![Переопределить имя автоссылки для пользовательской среды уравнений](https://rvso.com/image/475708/%D0%9F%D0%B5%D1%80%D0%B5%D0%BE%D0%BF%D1%80%D0%B5%D0%B4%D0%B5%D0%BB%D0%B8%D1%82%D1%8C%20%D0%B8%D0%BC%D1%8F%20%D0%B0%D0%B2%D1%82%D0%BE%D1%81%D1%81%D1%8B%D0%BB%D0%BA%D0%B8%20%D0%B4%D0%BB%D1%8F%20%D0%BF%D0%BE%D0%BB%D1%8C%D0%B7%D0%BE%D0%B2%D0%B0%D1%82%D0%B5%D0%BB%D1%8C%D1%81%D0%BA%D0%BE%D0%B9%20%D1%81%D1%80%D0%B5%D0%B4%D1%8B%20%D1%83%D1%80%D0%B0%D0%B2%D0%BD%D0%B5%D0%BD%D0%B8%D0%B9.png)
Я не могу заставить ссылки, сделанные с помощью \autoref
из hyperref
пакета, в пользовательскую среду, основанную на equation
среде, использовать пользовательское имя. Вместо использования пользовательского имени такие ссылки используют "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}