숫자 대신 (*) 및 (**)를 사용한 자동 라벨 수식

숫자 대신 (*) 및 (**)를 사용한 자동 라벨 수식

제목처럼 특정 환경(증명 등)에서 수식에 번호 매기기 대신 (*), (**), ...를 사용하여 라벨을 붙이고 싶습니다. 이것을 달성하는 방법이 있습니까?

답변1

이 같은?

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

이는 더미 증명 카운터가 재설정되지 않는 한 (불분명하지만) hyperref여러 번 발생하는 경우에도 작동합니다 .**proof

방정식 번호는 에서 사용되기 전에 먼저 확장됩니다 \loopstars.

물론, 기호가 10개보다 많으면 문제가 발생합니다. 즉, 방정식 '숫자'가 너무 넓어집니다!

\documentclass[11pt]{article}
\usepackage{amsmath}
\usepackage{amsthm}

\newcounter{starcnt}
\makeatletter
\newcommand{\loopstars}[1]{%
  \c@starcnt\z@%
  \loop\unless\ifnum\c@starcnt = #1%
  \advance \c@starcnt by \@ne%
  *%
  \repeat%
}
\makeatother

\newcounter{proof}
\usepackage{xpatch}

\makeatletter
\AtBeginEnvironment{proof}{%
  \refstepcounter{proof}%
  \renewcommand{\theHequation}{equation.\arabic{proof}.\arabic{equation}}
  \renewcommand{\theequation}{\protect\loopstars{\number\value{equation}}}
}

\makeatother

\usepackage{hyperref}


\begin{document}

In \eqref{foo} we see that and in \eqref{foobar}


\begin{proof}
  \begin{equation}
    E=mc^2
    \end{equation}  
    \begin{align}
      E=mc^2 \label{foo} \\
      E=mc^2
 \end{align}    
\end{proof}

\clearpage
\setcounter{equation}{0}
\begin{proof}
  \begin{equation}
    E=mc^2
    \end{equation}  
    \begin{align}
      E=mc^2 \label{foobar} \\
      E=mc^2
 \end{align}    
\end{proof}

코드 골프를 앞두고

  \documentclass[11pt]{article}
\usepackage{amsmath}
\usepackage{amsthm}

\newcounter{starcnt}
\newcounter{proof}
\newcounter{dummycntr}

\newcommand{\mynumberingplaceholder}{$\int\!$}
\makeatletter
\newcommand{\loopsymbols}[1]{%
  \raggedleft%
  \c@starcnt\z@%
  \loop\unless\ifnum\c@starcnt = #1%
  \advance \c@starcnt by \@ne%
  \mynumberingplaceholder%
  \repeat%
}
\makeatother

\usepackage{xpatch}

\makeatletter
\AtBeginEnvironment{proof}{%
  \refstepcounter{proof}%
  \renewcommand{\theHequation}{equation.\arabic{proof}.\arabic{equation}}
  \renewcommand{\theequation}{\protect\loopsymbols{\number\value{equation}}}
}

\makeatother

\usepackage{hyperref}


\begin{document}

In \eqref{foo} we see that and in \eqref{foobar}


\begin{proof}
  \begin{equation}
    E=mc^2
    \end{equation}  
    \begin{align}
      E=mc^2 \label{foo} \\
      E=mc^2
    \end{align} 
    \loop\unless\ifnum\value{dummycntr} = 10
    \stepcounter{dummycntr}
    \begin{equation}
      c^2 = a^2 +b^2 \\
    \end{equation}  
    \repeat
\end{proof}

\clearpage
\setcounter{equation}{0}
\begin{proof}
  \begin{equation}
    E=mc^2
    \end{equation}  
    \begin{align}
      E=mc^2 \label{foobar} \\
      E=mc^2
 \end{align}    
\end{proof}



\end{document}

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

답변2

Christian의 아이디어를 바탕으로 증명의 방정식 번호를 재설정하고 외부 항목을 표준으로 유지하는 버전이 있습니다. 또한 주어진 proof환경에서 기호를 (로컬로) 변경할 수 있습니다(기본값은 별표입니다).

\documentclass{article}

\usepackage{amsmath,amsthm,xpatch}
\usepackage{hyperref}

\ExplSyntaxOn
\cs_new:Npn \stars #1
 {
  \prg_replicate:nn { \use:c { c@#1 } } { \l_anhoa_eqsym_tl }
 }
\tl_new:N \l_anhoa_eqsym_tl
\NewDocumentCommand{\seteqsymbol}{m}
 {
  \tl_set:Nn \l_anhoa_eqsym_tl { #1 }
 }
\ExplSyntaxOff
\seteqsymbol{*} % initialize

\newcounter{saveequation}
\newcounter{proof}
\xapptocmd{\proof}
 {%
  \stepcounter{proof}%
  \setcounter{saveequation}{\value{equation}}%
  \setcounter{equation}{0}%
  \renewcommand{\theequation}{\stars{equation}}%
  \renewcommand{\theHequation}{\theproof.\arabic{equation}}%
 }{}{}
\xapptocmd{\endproof}
 {\setcounter{equation}{\value{saveequation}}}
 {}{}

\begin{document}

Here is an equation
\begin{equation}
a=b
\end{equation}

\begin{proof}
This is an important equation
\begin{equation}
0=0\label{a}
\end{equation}
Note that \eqref{a} together with
\begin{equation}
0=0
\end{equation}
ends the proof.
\end{proof}

\begin{proof}\seteqsymbol{\ensuremath{\vee}}
This is an important equation
\begin{equation}
0=0\label{b}
\end{equation}
Note that \eqref{b} together with
\begin{equation}
0=0
\end{equation}
ends the proof.
\end{proof}

Here is an equation
\begin{equation}
a=b
\end{equation}

\end{document}

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

관련 정보