4

How can we to create an exercise environment like this: enter image description here

I tried

\definecolor{orange}{rgb}{1,0.7,0}

\fboxset{rounded,border-color=orange}

But it wasn't success.

1
  • 2
    The tcolorbox package might be useful.
    – leandriis
    Dec 26, 2020 at 8:48

1 Answer 1

5

In the following example, I used \newtcbtheorem from the tcolorbox package. Spacing, colors, numbering scheme and more can of course be adjusted further to suit your needs:

enter image description here

\documentclass{report}

\usepackage[most]{tcolorbox}
\newtcbtheorem[auto counter, number within=chapter,]{mydef}{Definition}%
              {enhanced jigsaw,% 
               sharp corners,%
               boxrule=0pt,%
               fonttitle=\color{orange}\bfseries,%
               colback=orange!20!white,%
               colbacktitle=orange!20!white,%
               borderline north={2pt}{0pt}{orange},%
               borderline south={2pt}{0pt}{orange},%
               theorem style=plain
               }{th}

    
    
\begin{document}

\chapter{chapter title}

\begin{mydef}{}{label}
contents
\end{mydef}

\end{document} 
7
  • Thanks very much, if I want to change 1.1 to 2.1 (or any other number), how could I do that?
    – NKellira
    Dec 26, 2020 at 10:42
  • Depends on what "2" represents here. In the example code, "1.1" stands for "chapter 1.definition 1" as I guessed, the first number was the chapter number. If that's not the case, please explain, what the first of the two numbers actually stands for.
    – leandriis
    Dec 26, 2020 at 10:46
  • Because I want to write for a post, which not any chapter there.
    – NKellira
    Dec 26, 2020 at 12:13
  • But what does the first number correspond to? A section, an exercise,...? Does it have any meaning? What does "post" refer to in this context? Please explain.
    – leandriis
    Dec 26, 2020 at 12:14
  • 1
    If you number a definition using "2.1" and "2" is the section number and "1" is the subsection number, where is the definition's number? Wouldn't you need a format such as "2.1.3" for the third definition in the first subsection of the second section? If that's the output you want, using number within=subsection instead of number within=chapter should work.
    – leandriis
    Dec 26, 2020 at 12:25

You must log in to answer this question.

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