问题编号环境

问题编号环境

我想使用下面这段代码来定义定理风格:

\tcbuselibrary{theorems}

\newtcbtheorem[number within = section]{mytheorem}{\emph{Teorema}}
{colback = blue!10,
colframe = blue!50!black,
fonttitle = \bfseries}{th}

我在用其他环境(例如定义)对其进行编号时遇到了问题。我尝试定义一个“幽灵”计数器

\newcounter{count} \numberwithin{count}{section}
\theoremstyle{definition}       
\newtheorem{definition}[count]{\protect\definitionname}

所以只要改变= 部分内的数量为了数量 = 计数范围内

它几乎可以工作,但现在定理的编号是“1.2.1”,“1.3.1”等等,而定义(和其他)的编号是“1.2”,“1.3”...

我怎样才能解决这个问题?

编辑:这是我最初问题中使用的代码

\documentclass[11pt]{article}


\usepackage[most]{tcolorbox}             %tcolorbox para caixas.
\usepackage{amsmath}
\usepackage{amsthm}

\newcounter{count} \numberwithin{count}{section}

\tcbuselibrary{theorems}

\newtcbtheorem[number within = count]{teo}{\emph{Teorema}}
{colback = blue!10,
colframe = blue!50!black,
fonttitle = \bfseries}{th}

\theoremstyle{definition}           % use "definition-style" font for the rest.
\newtheorem{definition}[count]{\protect\definitionname}
\providecommand{\definitionname}{Def}

\title{Test document}

\makeindex
\begin{document}
\maketitle
    \tableofcontents
\section{Test section 1}

Here is the section 
\begin{definition}
Test definition. 1
\end{definition}

\begin{teo}{Teo 1}{}
Test theorem. 1
\end{teo}

\section{Test section 2}

Here is the section  2
\begin{definition}
Test definition. 2
\end{definition}

\begin{teo}{Teo 2}{}
Test theorem. 2
\end{teo}

\end{document}

答案1

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

% new theorem "definition", this defines new counter "definition"
\theoremstyle{definition}           
\newtheorem{definition}{Def}[section]

% new theorem "teo", numbered like "definition"
\newtcbtheorem[use counter*=definition]
  {teo}{\emph{Teorema}}{
    colback = blue!10,
    colframe = blue!50!black,
    fonttitle = \bfseries
  }{th}

\begin{document}

\section{Test section}

\begin{definition} 
Test definition.
\end{definition}

\begin{teo}{Teo}{}
Test theorem.
\end{teo}

\begin{definition}
Test definition.
\end{definition}

\begin{definition}
Test definition.
\end{definition}

\begin{teo}{Teo}{}
Test theorem.
\end{teo}

\end{document}

在此处输入图片描述

相关内容