3

I would like to have theorems in boxes. I am working with amsthm and mdframded packages (I use the syntax utilized in Legrand Orange template).

It works well with different babels (english, spanish, french) but with czech babel I get following error:

! Package mdframed Error: mdframed detected package amsthm changed the theorem header of amsthm failed (mdframed)

How can I fix that? Thank you.

\documentclass[10pt,twoside,openright]{book}

\usepackage[utf8]{inputenc}
\usepackage[czech]{babel}


\usepackage{amsthm}
\usepackage{xcolor} % Required for specifying colors by name
\definecolor{ocre}{RGB}{243,102,25} % Define the orange color used for highlighting throughout the book


\usepackage{amsmath,amsfonts,amssymb,amsthm} % For math equations, theorems, symbols, etc

%Theorem style
\newtheoremstyle{ocrenumbox}% % Theorem style name
{0pt}% Space above
{0pt}% Space below
{\normalfont}% % Body font
{}% Indent amount
{\small\bf\sffamily\color{ocre}}% % Theorem head font
{\;}% Punctuation after theorem head
{0.25em}% Space after theorem head
{\small\sffamily\color{ocre}\thmname{#1}\nobreakspace\thmnumber{#2} % Theorem text (e.g. Theorem 2.1)
\thmnote{\nobreakspace\the\thm@notefont\sffamily\bfseries\color{black}---\nobreakspace#3.}} % Optional theorem note
\renewcommand{\qedsymbol}{$\blacksquare$}% Optional qed square


\theoremstyle{ocrenumbox}
\newtheorem{theoremeT}[section]{Theorem}


\RequirePackage[framemethod=default]{mdframed} % Required for creating the theorem, definition, exercise and corollary boxes

% Theorem box
\newmdenv[skipabove=7pt,
skipbelow=7pt,
backgroundcolor=black!5,
linecolor=ocre,
innerleftmargin=5pt,
innerrightmargin=5pt,
innertopmargin=5pt,
leftmargin=0cm,
rightmargin=0cm,
innerbottommargin=5pt]{tBox}

\newenvironment{theorem}{\begin{tBox}\begin{theoremeT}}{\end{theoremeT}\end{tBox}}


\begin{document}
\chapter{Chapter one}
\section{Section one}

\begin{theorem}
something
\end{theorem}

\end{document}
3

The mdframed package tries to patch \deferred@thm@head, but the replacement text of this macro contains -, which babel-czech uses as shorthand, so the patch fails.

Temporary workaround:

\documentclass[10pt,twoside,openright]{book}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[czech]{babel}

\usepackage{xcolor} % Required for specifying colors by name
\usepackage{amsmath,amsfonts,amssymb,amsthm} % For math equations, theorems, symbols, etc
\usepackage[framemethod=default]{mdframed} % Required for creating the theorem, definition, exercise and corollary boxes

\makeatletter
\AtBeginDocument{%
\@ifpackageloaded{amsthm}%
 {%
  \renewrobustcmd\mdf@patchamsthm{%
   \chardef\kludge@catcode@hyphen=\catcode`\-
   \catcode`\-=12
   \let\mdf@deferred@thm@head\deferred@thm@head
   \pretocmd{\deferred@thm@head}{\@inlabelfalse}%
      {\mdf@PackageInfo{mdframed detected package amsthm ^^J%
                        changed the theorem header of amsthm\MessageBreak}%
      }{%
       \mdf@PackageError{mdframed detected package amsthm ^^J%
                         changed the theorem header of amsthm
                         failed\MessageBreak}%
       }%
   \catcode`\-=\kludge@catcode@hyphen
     }%
 }{}%
}
\makeatother

\definecolor{ocre}{RGB}{243,102,25} % Define the orange color used for highlighting throughout the book

%Theorem style
\newtheoremstyle{ocrenumbox}% % Theorem style name
  {0pt}% Space above
  {0pt}% Space below
  {\normalfont}% % Body font
  {}% Indent amount
  {\small\bfseries\sffamily\color{ocre}}% % Theorem head font
  {\;}% Punctuation after theorem head
  {0.25em}% Space after theorem head
  {\small\sffamily\color{ocre}\thmname{#1}\nobreakspace\thmnumber{#2} % Theorem text (e.g. Theorem 2.1)
   \thmnote{\nobreakspace\the\thm@notefont\sffamily\bfseries\color{black}---\nobreakspace#3.}} % Optional theorem note
\renewcommand{\qedsymbol}{$\blacksquare$}% Optional qed square


\theoremstyle{ocrenumbox}
\newtheorem{theoremeT}[section]{Theorem}



% Theorem box
\newmdenv[
  skipabove=7pt,
  skipbelow=7pt,
  backgroundcolor=black!5,
  linecolor=ocre,
  innerleftmargin=5pt,
  innerrightmargin=5pt,
  innertopmargin=5pt,
  leftmargin=0cm,
  rightmargin=0cm,
  innerbottommargin=5pt
]{tBox}

\newenvironment{theorem}{\begin{tBox}\begin{theoremeT}}{\end{theoremeT}\end{tBox}}

\makeatletter
\show\deferred@thm@head
\makeatother

\begin{document}
\chapter{Chapter one}
\section{Section one}

\begin{theorem}
something
\end{theorem}

\end{document}

enter image description here

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.