optidef를 사용한 참조가 작동하지 않습니다.

optidef를 사용한 참조가 작동하지 않습니다.

내 라벨(P)에 최적화 문제가 있습니다. 그러나 \ref{e}방정식이 아닌 최적화 문제를 나타냅니다. \tag(P)가 없으면 모든 것이 작동합니다. 이 문제를 해결하는 방법은 무엇입니까?

\documentclass[11pt,a4paper]{scrreprt}

\usepackage{amsmath}
\usepackage{optidef}
\usepackage{hyperref}

\begin{document}
    
\begin{mini}|s|
    {}{c^\top x}
    {\tag{P}\label{P}}
    {}
    \addConstraint{Ax}{=b}
    \addConstraint{x}{\geq 0}.
\end{mini}

\begin{align}
    1+e^{i \pi} = 0 \label{e}
\end{align} 

Reference to \ref{P}

Reference to \ref{e}
    
\end{document}

답변1

\theHequation환경 내부에서 문제를 해결할 수 있습니다 mini.

\documentclass[11pt,a4paper]{scrreprt}

\usepackage{amsmath}
\usepackage{optidef}
\usepackage{hyperref}

\newcommand{\ui}{\mathrm{i}}% if you really want upright

\AddToHook{env/mini/begin}{%
  \edef\theHequation{mini\unexpanded\expandafter{\theequation}}%
}

\begin{document}

\begin{mini}|s|
    {}{c^\top x}
    {\tag{P}\label{P}}
    {}
    \addConstraint{Ax}{=b}
    \addConstraint{x}{\geq 0}.
\end{mini}

\begin{align}
    1+\exp(\ui \pi) = 0 \label{e}
\end{align} 

Reference to \ref{P}

Reference to \ref{e}
    
\end{document}

링크는 올바른 지점을 가리킬 것입니다.

참고: \i수학 모드에서는 작동하지 않습니다(어쨌든 점이 없는 i를 생성합니다). \i실제 문서에서 재정의하는 경우에는 그렇게 하지 마십시오.

여기에 이미지 설명을 입력하세요

관련 정보