部分式付きオートナンバー

部分式付きオートナンバー

パッケージを作る方法はありますかオートナム部分式を扱いますか? 次の例では、参照は正しく式 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ロードすることが推奨されることに注意してください(私もオプションを使用することを選択しました)。hyperrefhypertexnames=falseautonumhidelinks

パッケージautonumは、その方程式が実際に参照されたときにのみ方程式番号を生成するため、その環境がサイレントに参照されるときに、サブ方程式環境内のすべての方程式を参照する方法が必要です。これは、ラベルを取得して何もしない独自の参照コマンドを定義し、パッケージによって提供されるマクロを使用して、それが参照コマンドであることを autonum パッケージに伝えることで実現できます\autonum@generatePatchedReference

\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例に示すように、サブ方程式環境を参照するために使用するものを次に示します。

関連情報