4

I have two questions about editing theorem environments on Tex. I did not see concrete answers among answered questions, so I ask here mines, hoping that there are not frequently asked.

First, I would like to know how to create the left line form the underlined title and followed by a little line at the bottom of a theorem like on this picture :enter image description here Then, which packages are needed to do that - and in which order (I encountered some trouble with adding some packages together, something like incompatibility, especially with "hyperref" and "ntheorem" packages)?

I am not an expert at all with Tex, so an answer like "cut and past it in your code" will be satisfying!

Thanks.

Nicolas
  • 311
  • Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. –  Mar 28 '15 at 11:31
  • Thank you for the welcome. I did not posted my "work" because I did not managed to do something correct for Tex, sorry. I just needed a concrete example, as provided below. – Nicolas Mar 28 '15 at 12:11

2 Answers2

9

I wanted to try an answer with \tcolorbox just as an exercise, but Bernard gave a good reason, thmbox can't break across pages and tcbtheorems can. So, in case someone is interested, here you have a starting point.

A tcbthmbox looks similar to thmbox, tcbSthmbox like [S]-thmbox and tcbLthmbox like [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}

enter image description here

Update:

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

has five parameters <init options> are related with automatic numbering; name is the name used as environment \begin{name}...\end{name}; display name, the word or words used before title: Theorem, Lemma, Démonstration, ...; options are all tcolorbox options to define its appearance and prefix a prefix used before the label assigned to each environment. Once defined, every tcbtheorem environment is declared with

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

which uses two mandatory arguments, title and label. They are mandatory but can be empty. If a proof doesn't have any title except Démonstration, just leave the title empty. In this case : (or any other character used between display name and title) will vanish.

If you also want to suppress theorem numbers, you have two options, the first one is \begin{name*}...\end{name*}. The starred variant doesn't have number but it's also unlabeled and not listed in list of theorems. A second possibility consists in using option theorem name is theorem options. This options can be added inside \tcbset command, in \newtcbtheorem <options> parameter or through an optional argument in theorem environment: \begin{proof}[theorem name]{}{}.

Following code which has been a little bit simplified from previous version, shows some examples with 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}

enter image description here

Ignasi
  • 136,588
  • Thank you Ignasi for your answer. Maybe can I add another question : using this theorem environment for my definitions, lemma, etc., how can I change create a special "proof" environment with the title "Démonstration" in french, ending with the white square usually used at the end of the proof ? – Nicolas Apr 01 '15 at 14:43
  • @Nicolas Glad to help you. I can answer your new question but in a couple of days. In the mean time you can look at http://tex.stackexchange.com/a/184530/1952 for better details about tcolorbox theorems. – Ignasi Apr 01 '15 at 15:44
  • Thank you for your help, and thank you for the link, it is very interesting for me to be able to make this presentation. I look forward your answer! – Nicolas Apr 01 '15 at 19:56
  • 1
    @Nicolas I've updated the answer with a proof environment (similar to [L] thmbox) and a little square at bottom right. – Ignasi Apr 02 '15 at 15:02
  • Ok thank you Ignasi. Now I ask you this last thing : is it possible to have the same presentation, execpt that the title on the final document is just "Démonstration" (without the word "proof") and that there is no straight line on the left of the paragraph ? – Nicolas Apr 02 '15 at 18:45
  • 1
    @Nicolas A new edition introduces some simplifications in code and also some comments to explain how it works. Now proof only shows the vertical left line, no horizontal one. – Ignasi Apr 06 '15 at 18:28
  • I saw your edition Ignasi ; is it possible to take off the vertical line on the left ? Anyway, good job ! I do thank you for all you did! – Nicolas Apr 06 '15 at 19:22
  • 1
    @Nicolas Yes. Just comment or delete \draw ([xshift=3.5mm]frame.north west)--([xshift=3.5mm]frame.south west); from overlay unbroken, overlay first, overlay middle and overlay last. But in this case the result will be completely different from your initial question. – Ignasi Apr 06 '15 at 19:28
  • Perfect! You helped me lot, thank you! My original question dealt with theorem/proposition/lemma environments, and I just wanted to know if it was possible to only modify the Demonstration environment. So you did answered all my questions, thanks again!! – Nicolas Apr 06 '15 at 20:46
  • @Ignasi Nice code! Just a note, with your second simplified code, the line joins are not as "sharp" since you're drawing the line segments separately instead of using e.g. |- as in the first code – mbert Dec 30 '23 at 23:05
  • The settings colback=white, colframe=white, colbacktitle=white can be replaced with frame engine=empty, interior titled engine=empty, interior engine=empty to add support for non-white page color, see question #706153 and my answer there. – muzimuzhi Z Jan 15 '24 at 03:52
4

You can do this with thmbox package

\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}

for ntheorem compatibilite may be

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

or if amsthm theorem style is used

\usepackage[amsthm,amsmath,hyperref,thmmarks]{ntheorem}
touhami
  • 19,520