
Как определить среду теоремы таким образом, чтобы получить следующее поведение:
Код, генерирующий пример:
\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
был дополнен префиксом либо ,proposition
либоquestion
числом (в зависимости от того, что произошло последним), при этом выполняя сброс всякий раз, когда встречаетсяproposition
средаquestion
, вам все равно следует удалить инструкцию\renewcommand{\thereflection}{}
, но теперь вы должны заменить ее на\usepackage{etoolbox} \AtBeginEnvironment{proposition}{\counterwithin{reflection}{proposition}} \AtBeginEnvironment{question}{\counterwithin{reflection}{question}}
Кстати, если вы хотите, чтобы счетчики
proposition
иquestion
сбрасывались каждый раз, когда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
по одному proposition
из следующих вариантов question
:
\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}