1

The following is the code I downloaded from the Internet: a ordinary environment of theorem.

\documentclass{ctexart}
\usepackage{xcolor}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{amsthm}
%%%%%%%% Theorem %%%%%%%%
\newcounter{theo}[section] \setcounter{theo}{0}
\renewcommand{\thetheo}{\arabic{section}.\arabic{theo}}
\newenvironment{theo}[2][]{%
\refstepcounter{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,%
%skipabove=1\baselineskip,
%skipbelow=1\baselineskip,
frametitleaboveskip=\dimexpr-\ht\strutbox\relax
}
\begin{mdframed}[]\relax%
\label{#2}}{\end{mdframed}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
Hello World!    
    \begin{theo}[Pythagoras' theorem]{thm:pythagoras}
    In a right triangle, the square of the hypotenuse is equal to the sum of 
the squares of the catheti.
    $$a^2+b^2=c^2$$
\end{theo}
Hello World!
\begin{theo}[Pythagoras' theorem]{thm:pythagoras}
    In a right triangle, the square of the hypotenuse is equal to the sum of the squares of the catheti.
    $$a^2+b^2=c^2$$
\end{theo}
\end{document}

Here is the result: enter image description here

And this is the result showing in the example: enter image description here

To make the problems stand out I deliberately put the same theorems together. As you can see, half of the title disappears and the gap in the context between the paragraphs is not so satisfying as in the example unless I add the code

skipabove=1\baselineskip,
skipbelow=1\baselineskip,

and the linewidth also don't matches the parameter. I compiled it on both texlive 2015 and 2017 with various editors such as Texstudio, TexWork and so on but all failed.What is wrong with my code? Please help me, thx.:D

P.S. :I tried the code in the intro of mdframed package but failed too. Σ(゚д゚lll)

closed as unclear what you're asking by Troy, Phelype Oleinik, Kurt, egreg, Stefan Pinnow May 18 '18 at 3:29

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    (1) welcome, (2) have you considered switching from mdframed to tcolorbox, which has many many more features out of the box. – daleif Jan 29 '18 at 10:20
  • Your code works sort-of fine here. That is, I do get an error about the fontsetup when compiling with pdflatex, but the output is actually fine. No error with xelatex, and also correct output. I have TeX Live 2017, nearly up to date. – Torbjørn T. Jan 29 '18 at 10:24
  • Thx a lot for ur timely advice, and I still want to solve the problem to acquire a knowledge of mdframed package. (◕ܫ◕) – Alex B Jan 29 '18 at 10:25
  • The code is ok, (it worked for me too), so your system or your compilation method is faulty. Check the log-file for outdated packages. And like daleif I advise you to drop mdframed. tcolorbox is much better (and it is actively maintained). – Ulrike Fischer Jan 29 '18 at 10:45

Browse other questions tagged or ask your own question.