하위방정식이 있는 자동항

하위방정식이 있는 자동항

패키지로 만드는 방법이 있나요?자동하위 방정식으로 작업 하시겠습니까? 다음 예에서 참조는 eq를 올바르게 읽습니다. 1이지만 방정식에 숫자가 추가되지 않습니다(1a, 1b를 보고 싶습니다).

\documentclass[11pt,a4paper]{article}
\usepackage{amsmath}
\usepackage{hyperref}
\usepackage{cleveref}
\usepackage{autonum}
\begin{document}

\begin{subequations}
    \label{eq:subequations}
    \begin{align}
        1 + 1 = 2, \\
        2 + 2 = 4
    \end{align}
\end{subequations}

Let us examine \cref{eq:subequations}.

\end{document}

답변1

이것은 흥미로웠다. 패키지 appto의 명령을 사용하는 효과적인 솔루션이 있다고 생각합니다 etoolbox. 사용할 때 hyperref패키지를 로드하는 것이 좋습니다 (저도 옵션을 사용하기로 선택했습니다 ).hypertexnames=falseautonumhidelinks

패키지 autonum는 해당 방정식이 실제로 참조될 때만 방정식 번호를 생성하므로 해당 환경이 자동으로 참조될 때 하위 방정식 환경의 모든 방정식을 참조하는 방법이 필요합니다. 레이블을 취하고 아무 작업도 수행하지 않는 자체 참조 명령을 정의하여 이를 수행할 수 있지만, \autonum@generatePatchedReference패키지에서 제공하는 매크로가 포함된 참조 명령임을 autonum 패키지에 알립니다.

\documentclass[11pt,a4paper]{article}
\usepackage{amsmath}
\usepackage[hypertexnames=false, hidelinks]{hyperref} % hypertexnames=false for autonum compatibility (autonum.pdf 3.2 Hyperref)
\usepackage{cleveref}
\usepackage{autonum}
\usepackage{etoolbox} % \appto (etoolbox.pdf 3.3 Hook management)
\newcommand\toplabel[2]{% Args: macro and label for subequations environment
\appto{#1}{(\ref{#2})}%
}
\newcommand\sublabel[2]{% Args: macro and label for a subequation
\appto{#1}{\hoaxref{#2}}% Pretend to reference this equation when #1 is called, to fool autonum
}
\newcommand\hoaxref[1]{%
% Do nothing!
}
\makeatletter
\autonum@generatePatchedReference{hoaxref} % Tell autonum about our reference command (autonum.pdf 3.3 Reference commands)
\makeatother
\begin{document}
\begin{subequations}
    \label{eq:1}
    \begin{align}
        1 + 1 &= 2 \label{eq:1a}\\
        2 + 2 &= 4\label{eq:1b}
    \end{align}
\end{subequations}
\toplabel{\referone}{eq:1}%
\sublabel{\referone}{eq:1a}%
\sublabel{\referone}{eq:1b}%

Let us examine system \referone. 
\begin{subequations}
    \label{eq:2}
    \begin{align}
        3 + 3 &= 8 \label{eq:2a}\\
        4 + 4 &= 8\label{eq:2b}
    \end{align}
\end{subequations}

For comparison, an ordinary reference to system \ref{eq:2}.
\end{document}

산출:

산출

사용법 참고: 일반적인 방법으로 하위 방정식 환경 방정식에 레이블을 지정합니다. 그런 다음 이 환경 아래에서 환경을 참조하고 번호를 매기려는 각 하위 방정식에 대해 매크로를 설정합니다 \toplabel{\myMacroName}{subeq:label}( \sublabel{\myMacroName}{a:sub:equation}모두일 필요는 없습니다!). \myMacroName예제에 표시된 대로 하위 방정식 환경을 참조하는 데 사용할 내용은 다음 과 같습니다.

관련 정보