# make new environment

I found a Code in the internet that makes an environment and I can't solve the error. Please help me.

% arara: xelatex
\documentclass[twoside]{book}
\usepackage{TikZ}
\usepackage{xcolor,mdframed}
%\usepackage{xepersian}
%\settextfont{XB Niloofar}

\begin{document}
\chapter{ftjfyg}
\section{sdg}
\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.
}

\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}[Inhomogeneous Linear]
\ExampleText
\end{theo}
\begin{theo}
\ExampleText
\end{theo}
\end{document}

• What is the error? :) Jan 11, 2017 at 10:05
• Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. Thank you for posting a working example! At the same time, much of your code does not seem to be relevant to the question you're asking here. Please limit the example to only the code required for your issue to appear. You can have a look at this guide for how to prune your code for this purpose. Jan 11, 2017 at 10:26
• Please, bear in mind, that it makes more sense, to define new commands and environments in the preamble, than rather in the document. So move the code up before \begin{document}.
– Jan
Jan 11, 2017 at 13:08

There are two mistakes in your code.

1. The package is named tikz, not TikZ.

frametitleaboveskip=\dimexpr−\ht\strutbox\relax


is not a regular hyphen but MINUS SIGN (U+2212). As a minus sign in TeX dimensions only the regular hyphen is allowed, i.e.

frametitleaboveskip=\dimexpr-\ht\strutbox\relax


(You might notice that the hyphen - is a bit shorter than −)

However, I think you should use the builtin support for theorems of mdframed.

\documentclass{article}
\usepackage{amsmath}
\usepackage{mdframed}
\usepackage{xcolor}

\mdtheorem
[linecolor=blue!20,linewidth=2pt,
frametitlebackgroundcolor=blue!20,
skipabove=1ex,skipbelow=1ex]
{theo}
{Theorem}

\begin{document}

\def\ExampleText{%
An \emph{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.%
}

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

\begin{theo}
\ExampleText
\end{theo}

\end{document}


• Thank you very much. How can I chang the color of the background of this environment box? Jan 11, 2017 at 11:48
• @FarshadGholami Add backgroundcolor=<color> to the options of \mdtheorem. See the documentation for more info. Jan 11, 2017 at 15:30