设置
\theoremstyle{definition}
\newtheorem{definition}{Definition}[section]
\theoremstyle{plain}
\newtheorem{theorem}[definition]{Theorem}
\newcounter{nremarkctr}
\newcommand*{\nremarkname}{Remark \textnormal{\thenremarkctr}}
\newenvironment{nremark}[1][\nremarkname]
{\refstepcounter{nremarkctr}
\begin{proof}[#1]\renewcommand*{\qedsymbol}{\(\diamond\)}}
{\end{proof}}
\numberwithin{nremarkctr}{section}
在第 3 节中创建以下编号:
定义3.1
定理 3.2
定理 3.3
定义3.4
备注 3.1
但我想要
定义3.1
定理 3.2
定理 3.3
定义3.4
备注 3.5
我知道这样做的原因是我用了\numberwithin{nremarkctr}{section}
,但需要类似 的东西\numberwithin{nremarkctr}{definition}
,这是由 启发而来的\newtheorem{theorem}[definition]{Theorem}
。但这不起作用。我怎样才能得到所需的编号?
答案1
您不想玩,\counterwithin
但要使用正确的计数器(definition
):
\documentclass[]{article}
\usepackage{amsthm}
\theoremstyle{definition}
\newtheorem{definition}{Definition}[section]
\theoremstyle{plain}
\newtheorem{theorem}[definition]{Theorem}
\newcommand*{\nremarkname}{Remark \textnormal{\thedefinition}}
\newenvironment{nremark}[1][\nremarkname]
{%
\refstepcounter{definition}%
\begin{proof}[#1]\renewcommand*{\qedsymbol}{\(\diamond\)}%
}
{\end{proof}}
\begin{document}
\section{Foo}
\begin{definition}
foo
\end{definition}
\begin{theorem}
foo
\end{theorem}
\begin{theorem}
foo
\end{theorem}
\begin{definition}
foo
\end{definition}
\begin{nremark}
foo
\end{nremark}
\end{document}
答案2
请勿滥用proof
:
\documentclass{article}
\usepackage{amsthm}
\theoremstyle{definition}
\newtheorem{definition}{Definition}[section]
\theoremstyle{plain}
\newtheorem{theorem}[definition]{Theorem}
\theoremstyle{remark}
\newtheorem{innernremark}[definition]{Remark}
\newenvironment{nremark}
{\par\pushQED{\qed}\renewcommand\qedsymbol{$\diamond$}\innernremark}
{\popQED\endinnernremark}
\begin{document}
\section{Foo}
\begin{definition}
foo
\end{definition}
\begin{theorem}
foo
\end{theorem}
\begin{theorem}
foo
\end{theorem}
\begin{definition}
foo
\end{definition}
\begin{nremark}
foo
\end{nremark}
\end{document}