在“笔记”中创建类似定理的环境(参见示例)

在“笔记”中创建类似定理的环境(参见示例)

我想创建以下风格来编写数学:

设计页面

事实上,以上内容是我自己创建的,但一些数字和间距我必须手动设置(当然我希望这是自动的)。

因此,以下几点对我很重要:

  • 我希望页面包含“注释”,这些注释的编号为 1.1、1.2 等,其中第一个数字指的是节/段落(因此在我的示例中,第 1 节中有四个注释)。我希望每个注释都可以添加粗体显示的标题(例如注释 1.1)。
  • 我希望在注释中能够添加类似定理的环境(在我的示例中,您可以找到“注释”、“引理”等)。最好有一个单独的命令来实现这一点,然后可以按我想要的方式命名它(引理或命题或其他名称)。此外,我希望它们在出现的注释中被编号(参见示例),除非我选择不编号(因此在我的示例中,“注释”没有编号)。
  • 在这些类似定理的环境之间,我想包含一些小空间(我在示例中选择了 \medskip)。但每当我有两个这样的环境时,我不希望这个空间加倍。
  • 最后但并非最不重要的一点:我希望某个章节的标题、注释的第一个单词以及类似定理的环境的标题能够对齐(比如说缩进一个段落)。

任何帮助或建议都非常感谢。当然,部分解决方案也欢迎,如果有不清楚的地方我可以提供详细信息。

提前谢谢!AYK

答案1

这可能近似于您的愿望;但是,我发现编号方案太繁琐:我认为没有理由在注释下对陈述进行编号。

如果\newnote后面紧跟着\begin,则假定存在类似定理的陈述。

\documentclass{article}

\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{chngcntr}

\usepackage{lipsum}

\makeatletter
\newif\ifnotebegin
\newcounter{note}[section]
\renewcommand{\thenote}{\thesection.\arabic{note}}
\newcommand{\newnote}{\@ifnextchar\begin\xnew@note\new@note}
\newcommand{\new@note}[1][]{%
  \par\addvspace{\topsep}%
  \refstepcounter{note}%
  \global\notebeginfalse
  \noindent\formatnote{#1}%
}
\newcommand{\formatnote}[1]{%
  \makebox[\parindent][l]{\normalfont\bfseries\thenote}%
  \if\relax\detokenize{#1}\relax\else\textbf{#1}\ \fi
}
\newcommand{\xnew@note}{%
  \refstepcounter{note}%
  \global\notebegintrue
}
\newcommand\notenumberorindent{%
  \ifnotebegin
    \formatnote{}%
  \else
    \hspace*{\parindent}%
  \fi
  \global\notebeginfalse
}
\makeatother

\declaretheoremstyle[
  headfont=\normalfont\itshape,
  notefont=\normalfont\itshape,
  bodyfont=\normalfont\itshape,
  notebraces={\textnormal{(}}{\textnormal{)}},
  headformat=\notenumberorindent\NAME\ \textup{({\bfseries\NUMBER})}\NOTE,
  headpunct=\ ---,
]{ayk}

\declaretheorem[
  style=ayk,
  within=note,
  name=Lemma,
]{lemma}
\declaretheorem[
  style=ayk,
  sibling=lemma,
  name=Proposition,
]{proposition}

\counterwithin{equation}{lemma}
\AtBeginDocument{\setlength{\parindent}{2em}}

\begin{document}

\section{First notes}

\newnote[Hello]
\lipsum[2]

\begin{lemma}[Some Lemma]
A lemma about something
A lemma about something
A lemma about something
A lemma about something
\end{lemma}

\begin{lemma}
Some other lemma Bla bla
\end{lemma}

\begin{proposition}
Some Proposition
\begin{equation}
  E = mc^2 
\end{equation}
\end{proposition}

\newnote
This note has no title. \lipsum[2]

\begin{lemma}[Some Lemma]
A lemma about something
A lemma about something
A lemma about something
A lemma about something
\end{lemma}

\begin{lemma}
Some other lemma Bla bla
\end{lemma}

\begin{proposition}
Some Proposition
\begin{equation}
  E = mc^2 
\end{equation}
\end{proposition}

\newnote\begin{lemma}[Some Lemma]
A lemma about something
A lemma about something
A lemma about something
A lemma about something
\end{lemma}

\begin{lemma}
Some other lemma Bla bla
\end{lemma}

\begin{proposition}
Some Proposition
\begin{equation}
  E = mc^2 
\end{equation}
\end{proposition}

\end{document}

在此处输入图片描述

答案2

仅是初步解决方案...缩进尚未完成。

\newtheorem{foo}{Foo}[section]将定义一个名为的环境foo,标题为,Foo以及一个名为(你猜对了-- foo;-))的计数器,每次section计数器步进时都会重置。

\newtheorem{otherfoo}[foo]{Otherfoo}将定义一个名为的环境otherfoo,标题Otherfoo计数器——它将使用计数器foo,即foo共享otherfoo计数器。

由于计数器格式需要更改,因此必须手动完成,counterwithinchngcntr我的角度来看,这没有帮助。

\documentclass{article}

%\usepackage{chngcntr}
\usepackage{amsthm}

%\usepackage{xpatch}

\newtheorem{notes}{Note}[section]
\newtheorem{lemma}{\normalfont\textit{Lemma}}[notes]
\newtheorem{proposition}[lemma]{\normalfont\textit{Proposition}}

\renewcommand{\thelemma}{(\thenotes.\arabic{lemma})}
\renewcommand{\theequation}{\thenotes.\arabic{lemma}.\arabic{equation}}


\usepackage{blindtext}
\begin{document}

\section{First notes}

\begin{notes}{Hello}
\blindtext
\begin{lemma}{Some Lemma}
\blindtext
\end{lemma}

\begin{lemma}{Some other lemma}
Bla bla
\end{lemma}

\begin{proposition}{Some Proposition}
\begin{equation}
  E = mc^2 
\end{equation}
\end{proposition}

\begin{proposition}{Some Proposition}
\begin{equation}
  E^2 = (mc^2)^2 +\left(pc\right)^2
\end{equation}

\end{proposition}

\end{notes}


\end{document}

在此处输入图片描述

答案3

基于和 的ntheorem解决方案:mathtoolsetoolbox

\documentclass[twoside,a4paper,11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{amsfonts}
\usepackage[hmargin=3cm]{geometry}
\setlength\parindent{1.1cm}
\usepackage{microtype}
\usepackage{mathtools, amssymb}
\newtagform{bold}{\bfseries(}{)}
\usetagform{bold}
\usepackage{etoolbox}
\usepackage{titlesec}
\titleformat{\section}{\Large\bfseries}{\rlap{§\thesection.}}{1.1cm}{\lsstyle\MakeUppercase}
\titleformat{\subsection}[runin]{\normalsize\bfseries}{\rlap{\thesubsection.}}{1.1cm}{\mbox{}}
\usepackage[thref, amsmath, thmmarks]{ntheorem}%
\makeatletter
\newtheoremstyle{myplain}%
{\item[\hskip\labelsep \theorem@headerfont ##1\ \textup{\bfseries(##2)}\ \theorem@separator]}%
{\item[\hskip\labelsep \theorem@headerfont ##1\ \textup{\bfseries(##2)}\ (##3)\theorem@separator]}
\makeatother
\theoremstyle{myplain}
\theoremheaderfont{\itshape}
\theorembodyfont{\itshape}
\theoremseparator{\textemdash}
\newtheorem{lemma}{\hspace*{1.1cm}Lemma}[subsection]%
\newtheorem{prop}[lemma]{Proposition}
\newtheorem{defn}[lemma]{Definition}

\theoremstyle{nonumberplain}
\theorembodyfont{\upshape}
\theoremseparator{ \textemdash}
\newtheorem{remark}{\hspace*{1.1cm}Remark}
\theoremsymbol{\ensuremath{\diamondsuit}}
\newtheorem{proof}{\hspace*{1.1cm}Proof}

\usepackage{lipsum}
\usepackage{cleveref}

\newcommand\note[1][]{\subsection{#1}\ifblank{#1}{\hskip-\labelsep}{\relax}}% 

\usepackage{chngcntr}
\counterwithin{equation}{lemma}

\begin{document}

\section{Some section}
\note[Some optional title]
\lipsum[1]

\note[]
\lipsum[3]

\begin{remark}
\lipsum[5]
\end{remark}

\note
\lipsum[4]
\begin{lemma}\label{lemma1}\lipsum[3]
\end{lemma}

\begin{proof}
A brilliant proof. Blah blah blah. A brilliant proof. Blah blah blah. A brilliant proof. Blah blah blah. A brilliant proof with an unlikely final formula
 \[n! \sim_\infty \sqrt{2\pi n}\Bigl(\frac{n}{\mathrm e}\Bigr)^n.\] %
\end{proof}
\lipsum[5]
\begin{prop}A very interesting proposition, with an amazing formula:
\begin{equation}\label{quadratic}
  x_0 ,x_1 =\frac{-b\pm\sqrt{b^2-4ac}}{2a}
\end{equation}
\end{prop}

\end{document} 

在此处输入图片描述 在此处输入图片描述

相关内容