6

I've been working with LaTex for a while and with Tikz I've done stuff nothing fancy just things for homework but now I will write my thesis I want some elegant cool theorem box using mdframed and this is my code for the thing I have done

\documentclass{book}
{\usepackage[framemethod=TikZ]{mdframed}
 \mdfdefinestyle{Teorema}{
    frametitlerule=false,
    linecolor=black,%FireBrick
    linewidth=1pt,
    innerlinewidth =1pt,
    frametitlerulewidth=2pt, 
    frametitlebackgroundcolor=blue!40,%DarkSalmon
    backgroundcolor=gray!10,
    skipbelow=15pt,
    }
\mdtheorem[style=Teorema]{teorema}{Teorema}}

what should I modify in my code in order to get something like this

enter image description here

I read the mdframed manual but really I don't why they use some commands.

Thanks

6

An example with tcolorbox.

\documentclass[12pt]{article}

\usepackage[many]{tcolorbox}
\newtcbtheorem[number within=section]{mytheo}{My Theorem}%
  {colback=white,colframe=blue!50,fonttitle=\bfseries,
   enhanced,
   coltitle=blue!75!black,
   attach boxed title to top left=
     {xshift=2ex,yshift=-2mm,yshifttext=-1mm},
   boxed title style={colframe=blue!50,
     colback=blue!50}}{th}
\begin{document}
  \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. This theorem is numbered with
    \ref{th:theoexample} and is given on page \pageref{th:theoexample}.
  \end{mytheo}
\end{document}

enter image description here

And this is the example from mdframed manual modified so that it compiles.

\documentclass{article}
\usepackage{amsmath}
\usepackage[utf8]{inputenc}
\usepackage[framemethod=TikZ]{mdframed}
%% the following is commaon for all examples in mdframed manual
\mdfsetup{skipabove=\topskip,skipbelow=\topskip}
%%% upto here
\newcounter{theo}[section]
\newenvironment{theo}[1][]{%
\stepcounter{theo}%
\ifstrempty{#1}%
 {\mdfsetup{%
   frametitle={%
    \tikz[baseline=(current bounding box.east),outer sep=0pt]
    \node[anchor=east,rectangle,fill=blue!20]
         {\strut Theorem~\thetheo};}}
 }%
{\mdfsetup{%
  frametitle={%
   \tikz[baseline=(current bounding box.east),outer sep=0pt]
   \node[anchor=east,rectangle,fill=blue!20]
        {\strut Theorem~\thetheo:~#1};}}%
 }%
\mdfsetup{innertopmargin=10pt,linecolor=blue!20,%
       linewidth=2pt,topline=true,
       frametitleaboveskip=\dimexpr-\ht\strutbox\relax,}
   \begin{mdframed}[]\relax%
}
{\end{mdframed}}

\begin{document}
    \begin{theo}[Inhomogeneous Linear]
        \ExampleText
    \end{theo}
    \begin{theo}
        \ExampleText
    \end{theo}
\end{document}

enter image description here

All you have to do with above is type your content within begin{theo} and \end{theo} like

\begin{theo}[Inhomogeneous Linear]
    Your content here.   
\end{theo}

For example:

\begin{theo}[Inhomogeneous Linear]
    An \textit{inhomogeneous linear} differential equation has the form
        \begin{align}
            L[v] = f,
        \end{align}
    where $L$ is a linear differential operator, $v$ is the dependent
    variable, and $f$ is a given non-zero function of the independent
    variables alone.
\end{theo}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.