编辑定理环境

编辑定理环境

我有两个关于在 Tex 上编辑定理环境的问题。在已回答的问题中我没有看到具体的答案,所以我在这里询问,希望不会经常被问到。

首先,我想知道如何创建由下划线标题组成的左行,然后在定理的底部创建一条小行,就像这张图一样:在此处输入图片描述 然后,需要哪些包来执行此操作 - 以及按什么顺序执行(我在添加一些包时遇到了一些麻烦,例如不兼容,尤其是“hyperref”和“ntheorem”包)?

我根本不是 Tex 专家,所以像“将其剪切并粘贴到你的代码中”这样的答案就令人满意了!

谢谢。

答案1

你可以使用 thmbox 包来实现

\documentclass{article}
\usepackage{thmbox}
\newtheorem[L]{thm}{Theorem}[section]
\newtheorem{lem}[thm]{Lemma}
\newtheorem[S]{cor}[thm]{Corollary}

\begin{document}

\begin{lem}{First resualt}
Here a lemma
\end{lem}

\begin{thm}{Important}
Great theorem
\end{thm}

\begin{cor}{Final}
Here the corollary
\end{cor}

\end{document}

对于 ntheorem compatibilite 可能是

\usepackage[amsmath,hyperref,thmmarks]{ntheorem}

或者如果使用 amsthm 定理样式

\usepackage[amsthm,amsmath,hyperref,thmmarks]{ntheorem}

答案2

我想尝试用答案\tcolorbox作为练习,但 Bernard 给出了一个很好的理由,thmbox不能跨页拆分tcbtheorems。所以,如果有人感兴趣,这里有一个起点。

Atcbthmbox看上去类似于thmboxtcbSthmbox[S]-thmboxtcbLthmbox[L]-thmbox

\documentclass{article}
\usepackage{lipsum}
\usepackage{amsmath,amssymb}
\usepackage[most]{tcolorbox}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage{lmodern}

\tcbset{
    thmbox/.style={
        enhanced,
        breakable,
        sharp corners=all,
        fonttitle=\bfseries\normalsize,
        fontupper=\normalsize\itshape,
         top=0mm,
         bottom=0mm,
         right=0mm,
        colback=white,
        colframe=white,
        colbacktitle=white,
        coltitle=black,
        attach boxed title to top left,
        boxed title style={empty, size=minimal, bottom=1.5mm},
        overlay unbroken ={
            \draw (title.south west)--(title.south east);
            \draw ([xshift=3.5mm]frame.north west)|-%
                  (frame.south east)--(frame.north east);},
        overlay first={
            \draw (title.south west)--(title.south east); 
            \draw ([xshift=3.5mm]frame.north west)--([xshift=3.5mm]frame.south west);
            \draw (frame.north east)--(frame.south east);},
        overlay middle={
            \draw ([xshift=3.5mm]frame.north west)--([xshift=3.5mm]frame.south west);
            \draw (frame.north east)--(frame.south east);},
        overlay last={
            \draw ([xshift=3.5mm]frame.north west)|-%
                  (frame.south east)--(frame.north east);},
        },
    S/.style={thmbox, 
        overlay unbroken ={
            \draw (title.south west)--(title.south east);
            \draw ([xshift=3.5mm]frame.north west)--([xshift=3.5mm]frame.south west);},
        overlay first={
            \draw (title.south west)--(title.south east); 
            \draw ([xshift=3.5mm]frame.north west)--([xshift=3.5mm]frame.south west);},
        overlay middle={
            \draw ([xshift=3.5mm]frame.north west)--([xshift=3.5mm]frame.south west);},
        overlay last={
            \draw ([xshift=3.5mm]frame.north west)--([xshift=3.5mm]frame.south west);},
        },
    L/.style={thmbox, 
        overlay unbroken ={
            \draw (title.south west)--(title.south east);
            \draw ([xshift=3.5mm]frame.north west)|-([xshift=15mm]frame.south west);},
        overlay first={
            \draw (title.south west)--(title.south east); 
            \draw ([xshift=3.5mm]frame.north west)--([xshift=3.5mm]frame.south west);},
        overlay middle={
            \draw ([xshift=3.5mm]frame.north west)--([xshift=3.5mm]frame.south west);},
        overlay last={
            \draw ([xshift=3.5mm]frame.north west)|-([xshift=15mm]frame.south west);},
        },
    LQ/.style={thmbox, 
        overlay unbroken ={
            \draw (title.south west)--(title.south east);
            \draw ([xshift=3.5mm]frame.north west)|-([xshift=15mm]frame.south west);
            \node[anchor=east] at (frame.south east) {$\square$};},
        overlay first={
            \draw (title.south west)--(title.south east); 
            \draw ([xshift=3.5mm]frame.north west)--([xshift=3.5mm]frame.south west);},
        overlay middle={
            \draw ([xshift=3.5mm]frame.north west)--([xshift=3.5mm]frame.south west);},
        overlay last={
            \draw ([xshift=3.5mm]frame.north west)|-([xshift=15mm]frame.south west);
            \node[anchor=east] at (frame.south east) {$\square$};},
    },  
}

\newtcbtheorem[]{tcbthmbox}{Theorem}{thmbox}{theo}
\newtcbtheorem[]{tcbSthmbox}{Theorem}{thmbox,S}{theo}
\newtcbtheorem[]{tcbLthmbox}{Theorem}{thmbox,L}{theo}
\newtcbtheorem[]{proof}{Démonstration}{thmbox,LQ}{theo}

\begin{document}

\begin{tcbthmbox}{First result}{}
\lipsum[3]
\end{tcbthmbox}

\begin{tcbSthmbox}{Important}{}
\lipsum[2]
\end{tcbSthmbox}

\begin{tcbLthmbox}{Final}{}
\lipsum[1]
\end{tcbLthmbox}

\begin{proof}{Proof}{}
\lipsum[1]
\end{proof}
\end{document}

在此处输入图片描述

更新:

\newtcbtheorem[<init options>]{<name>}{<display name>}{<options>}{<prefix>}

有五个参数<init options>与自动编号相关;name是用作环境的名称\begin{name}...\end{name}display name,标题前使用的单词或单词:定理、引理、演示……;options都是tcolorbox定义其外观的选项,以及prefix分配给每个环境的标签前使用的前缀。一旦定义,每个tcbtheorem环境都声明为

\begin{name}{title}{label}
...
\end{name} 

它使用两个强制参数titlelabel。它们是强制的,但可以为空。如果证明除了之外没有任何标题Démonstration,则将标题留空。在这种情况下(或在和:之间使用的任何其他字符)将消失。display nametitle

如果您还想抑制定理编号,则有两个选项,第一个是\begin{name*}...\end{name*}。带星号的变体没有编号,但它也没有标签,也没有列在定理列表中。第二种可能性是使用选项是定理选项。可以在命令内部、参数中或通过定理环境中的可选theorem name参数添加此选项: 。\tcbset\newtcbtheorem <options>\begin{proof}[theorem name]{}{}

下面的代码比以前的版本稍微简化了一些,显示了一些示例proof

\documentclass{article}
\usepackage{lipsum}
\usepackage{amsmath,amssymb}
\usepackage[most]{tcolorbox}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage{lmodern}

\tcbset{
    thmbox/.style={
        enhanced,
        breakable,
        sharp corners=all,
        fonttitle=\bfseries\normalsize,
        fontupper=\normalsize\itshape,
         top=0mm,
         bottom=0mm,
         right=0mm,
        colback=white,
        colframe=white,
        colbacktitle=white,
        coltitle=black,
        attach boxed title to top left,
        boxed title style={empty, size=minimal, bottom=1.5mm},
        overlay unbroken ={
            \draw (title.south west)--(title.south east);
            \draw ([xshift=3.5mm]frame.north west)--([xshift=3.5mm]frame.south west);},
        overlay first={
            \draw (title.south west)--(title.south east); 
            \draw ([xshift=3.5mm]frame.north west)--([xshift=3.5mm]frame.south west);},
        overlay middle={
            \draw ([xshift=3.5mm]frame.north west)--([xshift=3.5mm]frame.south west);},
        overlay last={
            \draw ([xshift=3.5mm]frame.north west)--([xshift=3.5mm]frame.south west);},
        },
    Boxed/.style={ 
        overlay unbroken and last app ={
            \draw ([xshift=3.5mm]frame.south west)-|(frame.north east);},
        },
    L/.style={ 
        overlay unbroken and last app ={
            \draw ([xshift=3.5mm]frame.south west)--++(0:11.5mm);},
        },
    Q/.style={ 
        overlay unbroken and last app={
            \node[anchor=east] at (frame.south east) {$\square$};},
    },  
}

\newtcbtheorem[]{tcbthmbox}{Theorem}{thmbox,Boxed}{theo}
\newtcbtheorem[]{tcbSthmbox}{Theorem}{thmbox}{theo}
\newtcbtheorem[]{tcbLthmbox}{Theorem}{thmbox,L}{theo}
\newtcbtheorem[]{proof}{Démonstration}{thmbox,Q}{theo}

\begin{document}

\begin{proof}{Title}{}
\textcolor{red}{A demonstration with title and number}

\lipsum[2]
\end{proof}

\begin{proof}{}{}
\textcolor{red}{A demonstration without title but with number}

\lipsum[3]
\end{proof}

\begin{proof}[theorem name]{}{}
\textcolor{red}{A demonstration without title and number}

\lipsum[3]
\end{proof}

\begin{proof*}{}

\textcolor{red}{Starred version}

\lipsum[3]
\end{proof*}

\end{document}

在此处输入图片描述

相关内容