중첩 정리 레이블

중첩 정리 레이블

다음 동작을 얻도록 정리 환경을 어떻게 정의할 수 있습니까?

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

예제를 생성하는 코드는 다음과 같습니다.

\documentclass[10pt,a4paper]{article}
\usepackage{amsthm}
\theoremstyle{definition}
\newtheorem{proposition}{Proposition}
\renewcommand{\theproposition}{\thesection.\arabic{proposition}}
\newcommand{\propositionautorefname}{Proposition}
\theoremstyle{definition}
\newtheorem{question}{Question}
\renewcommand{\thequestion}{\thesection.\arabic{question}}
\newcommand{\questionautorefname}{Q.}
\theoremstyle{definition}
\newtheorem{reflection}{Reflection}
\renewcommand{\thereflection}{}
\newcommand{\reflectionautorefname}{Reflection}
\begin{document}
    \begin{proposition}
        My proposition
        \begin{reflection}
            My reflection should be numbered 0.1.1. or 1
        \end{reflection}
        \begin{reflection}
            My reflection should be numbered 0.1.2. or 2
        \end{reflection}
    \end{proposition}
    \begin{question}
        My question
        \begin{reflection}
            My reflection should be numbered 0.1.1. or 1
        \end{reflection}
        \begin{reflection}
            My reflection should be numbered 0.1.2. or 2
        \end{reflection}
    \end{question}
\end{document}

답변1

  • 환경에 연속적으로 번호를 매기려면 reflection-- 1, 2등 --그리고proposition새 환경 이나 question환경이 나타날 때마다 재설정되므로 해당 명령을 삭제 \renewcommand{\thereflection}{}하고 다음으로 교체 해야 합니다.

    \makeatletter
    \@addtoreset{reflection}{proposition}
    \@addtoreset{reflection}{question}
    \makeatother
    

    또는 @egreg가 주석에서 지적한 것처럼 동등하고 더 간결하게,

    \counterwithin*{reflection}{proposition}
    \counterwithin*{reflection}{question}
    

    (이것은 \counterwithin*{reflection}{proposition}와 동일하기 때문에 작동합니다 \makeatletter \@addtoreset{reflection}{proposition} \makeatother.)

  • 또는 환경이 발생할 때마다 재설정을 계속 실행하면서 또는 번호(가장 최근에 발생한 것) reflection가 접두사로 붙는 환경 번호를 얻으려면 명령을 삭제해야 하지만 이제는 명령을 다음으로 바꿔야 합니다.propositionquestionpropositionquestion\renewcommand{\thereflection}{}

    \usepackage{etoolbox}
    \AtBeginEnvironment{proposition}{\counterwithin{reflection}{proposition}}
    \AtBeginEnvironment{question}{\counterwithin{reflection}{question}}
    
  • 그런데 지시문 을 통해 카운터가 증가할 때마다 propositionquestion카운터를 재설정 하려면 다음을 변경해야 합니다.section\section

    \renewcommand{\theproposition}{\thesection.\arabic{proposition}}
    

    그리고

    \renewcommand{\thequestion}{\thesection.\arabic{question}}
    

    에게

    \counterwithin{proposition}{section}
    

    그리고

    \counterwithin{question}{section}
    

    각기. 또는 두 \renewcommand명령문을 삭제하고 명령문을 변경하십시오.

    \newtheorem{proposition}{Proposition}
    

    그리고

    \newtheorem{question}{Question}
    

    에게

    \newtheorem{proposition}{Proposition}[section]
    

    그리고

    \newtheorem{question}{Question}[section]
    

    각기.

\theoremstyle{definition}덧붙여서, 코드에서 의 두 번째 및 세 번째 인스턴스는 중복되므로 생략할 수 있습니다(?!).

답변2

또는 reflection다음 중 하나에 따라 쉽게 번호를 매길 수 있습니다 .propositionquestion

\documentclass[10pt,a4paper]{article}

\usepackage{amsthm}

\theoremstyle{definition}

\newtheorem{proposition}{Proposition}[section]
\newcommand{\propositionautorefname}{Proposition}

\newtheorem{question}{Question}[section]
\newcommand{\questionautorefname}{Q.}

\newtheorem{reflection}{Reflection}
\newcommand{\reflectionautorefname}{Reflection}

\counterwithin*{reflection}{proposition}
\counterwithin*{reflection}{question}

\begin{document}

\section{Title}

\begin{proposition}
My proposition
\begin{reflection}
My reflection should be numbered 1
\end{reflection}
\begin{reflection}
My reflection should be numbered 2
\end{reflection}
\end{proposition}

\begin{question}
My question
\begin{reflection}
My reflection should be numbered or 1
\end{reflection}
\begin{reflection}
My reflection should be numbered or 2
\end{reflection}
\end{question}

\end{document}

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

proposition또는 숫자를 추가하려면 조금 더 복잡합니다 question.

\documentclass[10pt,a4paper]{article}

\usepackage{amsthm}

\theoremstyle{definition}

\newtheorem{propositioninner}{Proposition}[section]
\newcommand{\propositioninnerautorefname}{Proposition}
\newenvironment{proposition}
  {%
   \renewcommand{\PropositionOrQuestion}{\thepropositioninner}%
   \propositioninner
  }
  {\endpropositioninner}

\newtheorem{questioninner}{Question}[section]
\newcommand{\questioninnerautorefname}{Q.}
\newenvironment{question}
 {%
  \renewcommand{\PropositionOrQuestion}{\thequestioninner}%
  \questioninner
 }
 {\endquestioninner}

\newcommand{\PropositionOrQuestion}{}
\newtheorem{reflection}{Reflection}
\newcommand{\reflectionautorefname}{Reflection}

\counterwithin*{reflection}{propositioninner}
\counterwithin*{reflection}{questioninner}
\renewcommand{\thereflection}{\PropositionOrQuestion.\arabic{reflection}}

\begin{document}

\section{Title}

\begin{proposition}
My proposition
\begin{reflection}
My reflection should be numbered 1.1.1
\end{reflection}
\begin{reflection}
My reflection should be numbered 1.1.2
\end{reflection}
\end{proposition}

\begin{question}
My question
\begin{reflection}
My reflection should be numbered or 1.1.1
\end{reflection}
\begin{reflection}
My reflection should be numbered or 1.1.2
\end{reflection}
\end{question}

\end{document}

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

관련 정보