[Tex/LaTex] Difficult mdframed example

boxesmdframedpdftex

I want to do this mdframed model:

theo

Which is the example 6 of the page 21 and 22 of this pdf: http://texdoc.net/texmf-dist/doc/latex/mdframed/mdframed.pdf

My question is if it is correct or not, and if it's correct, which packages are the ones that I need, because I copy it with the blankspaces, putting all packages in the pdf, and it doesn't work (I copied the ExampleText too).

The mistakes that are shown when I compile says:

-Missing number, treated as zero \protect
-Illegal unit of measure (pt inserted)

Best Answer

Here is the compilable code:

\documentclass{article}
\usepackage{amsmath}
\usepackage[framemethod=TikZ]{mdframed}
%% the following is commaon for all examples in mdframed manual
\mdfsetup{skipabove=\topskip,skipbelow=\topskip}
\newrobustcmd\ExampleText{%
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.
}
%%% 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

Compare it with the code you have assembled to see what is missing.

One thing which I forgot to mention and reminded by Karl, is the in −\ht (frametitleaboveskip=\dimexpr−\ht\strutbox\relax to be precise) which is a unicode symbol (U+2212 char, thanks to Karl for the code) which should be minus sign.