4

I am looking for a package for theorems (which can be framed, shaded, …). I use ntheorem but I see that PSTricks is involved when I use shaded theorems, and I want to use Tikz rather than PSTricks. I did some research but there are many packages for theorems and I’m lost.

I’ve seen tcolorbox but, for instance, I don’t want boxes surrounding my examples (I just want the name "Example" in a box, with a counter, of course). And the tcolorbox documentation is over 500 pages in English, whereas I am French).

My document is over 600 pages (with theorems, lemmas, ...) and of course, I just want to modify the definitions of the environments in the preamble.

So if someone can tell me which packages I could use …

6
  • 3
    Could you provide an example what you would like your theorems to look like? It is not very clear from your question why tcolorbox would not be the right package for you (apart from its admittedly long manual). Dec 18, 2021 at 16:07
  • 5
    I think if you want to use a TikZ based package to typeset theorems in boxes, tcolorbox is really the best option. If there is something specific you want to achieve with tcolorbox and you don't know how to do it, you could just ask it here in a separate question.
    – Vincent
    Dec 18, 2021 at 16:09
  • 1
    You can easily have shaded theorems with the framed package. A sledge-hammer like TiKZ is not necessary.
    – Bernard
    Dec 18, 2021 at 16:22
  • @Didier bonjour, tcolorbox is indeed the right package for you. You hae mutliple options using keys to adjust the format of the boxes and even have them transparent as in here.
    – JeT
    Dec 18, 2021 at 16:23
  • Thank you all for your help. I can’t provide any example because I write from my tablet. I am a little afraid with tcolorbox because the documentation is very long and I don’t have time to read 600 pages (it takes me more time because English is not my first language). Is it possible with tcolorbox to have an environment for Exercise with the following requirements : no frame for the exercise itself but a frame (with a color) for the name Exercise and the counter (referred to the chapter). If the answer is yes, I will look at tcolorbox
    – Didier
    Dec 18, 2021 at 16:41

2 Answers 2

4

If my crystal ball is working, this is what you're looking for:

\documentclass{book}
\usepackage[most]{tcolorbox}
\tcbuselibrary{theorems}
\newtcbtheorem[number within=chapter]{theorem}{Theorem}%
    {enhanced,
    enhanced jigsaw,
    breakable, 
    sharp corners,
    boxrule=0pt,
    boxsep=0pt,
    left=0pt,
    right=0pt,
    bottom=0pt,
    opacityback=0,
    opacityframe=0,
    coltitle=black,
    fonttitle=\bfseries,
    fontupper=\itshape,
    attach boxed title to top left,
    boxed title style={colframe=cyan,
    colback=cyan!30},
    }{th}

\begin{document}
\chapter{My chapter}
\section{My section}
In the following you have two examples with \texttt{tcolorbox}.
Theorem \ref{th:without} is has no name, but only the number. Pay attention to how we refer to it, the label is a parameter of the environment, with the prefix \texttt{th:}. The prefix is choosed in the tcbtheorem definition
\begin{theorem}{}{without}
Paulo is a duck. He always says quack, hence he's a duck.
\end{theorem}
Whereas the other theorem,
Theorem \ref{th:with}, has a name:
\begin{theorem}{Pythagoras}{with}
The area of the square whose side is the hypotenuse is equal to the sum of the areas of the squares on the two catheti. 
\end{theorem}
I numbered the theorems within chapters.
\end{document}

enter image description here

2
  • Your crystal ball is working great. Thanks a lot
    – Didier
    Dec 18, 2021 at 18:37
  • 1
    @Didier You're welcome! You don't need to read all the package documentation, just search for the option you need.
    – CarLaTeX
    Dec 18, 2021 at 18:38
0

Maybe something like this can get you started:

\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{theorems}

\usepackage{lipsum}

\newtcbtheorem[number within=section]{mytheo}{Example}%
{oversize, left=5pt, right=5pt, bottom=0pt, sharp corners, boxrule=0mm, colback=black!0, colframe=black!0, colbacktitle=blue!25!black, fonttitle=\bfseries}{th}

\begin{document}

\lipsum[1]

\begin{mytheo}{This is my title}{theoexample}
This is the text of the theorem. The counter is automatically assigned and,
in this example, prefixed with the section number.
\end{mytheo}

\lipsum[1]

\end{document}

enter image description here

1
  • 2
    Hello again. I looked (just a little) at the documentation of tcolorbox and I am going to use it. Just a few questions: is it possible to choose in the declaration of the environment the vertical space before and after the theorem? And for an environment without box, is it possible to add at the end something (for instance five stars centered) to indicate the end of the environment (of course, it should be in the declaration of the environment)
    – Didier
    Dec 18, 2021 at 20:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .