Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm trying to get the following mdframedexample from the package documentation to work (mdframed-example-default page 5), but it's throwing the following errors

Missing number, treated as zero T
Illegal unit of measure (pt inserted) T

and displays a peculiar "pt" before printing the environment contents with the title box positioned too low. How to fix this? The title box should be just on the middle of the top line.

\documentclass{article}

\usepackage{tikz,mdframed}

\begin{document}

\mdfsetup{skipabove=\topskip,skipbelow=\topskip}
\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{theo}
    This is an example theorem
    %
    \begin{equation}
        a^2 + b^2 = c^2
    \end{equation}
\end{theo}

\end{document}

resulting in

enter image description here

share|improve this question

1 Answer 1

up vote 3 down vote accepted

The line

frametitleaboveskip=\dimexpr−\ht\strutbox\relax

has a strange character (probably a result of the copy-paste process) just before \ht that must be replaced by a standard minus sign:

frametitleaboveskip=\dimexpr-\ht\strutbox\relax

The code:

\documentclass{article}

\usepackage{tikz,mdframed}

\mdfsetup{skipabove=\topskip,skipbelow=\topskip}
\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}
test
    \begin{equation}
        a^2 + b^2 = c^2
    \end{equation}
\end{theo}

\end{document}

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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