使用 czech babel 时 mdframed 和 amsthm 包之间的冲突

使用 czech babel 时 mdframed 和 amsthm 包之间的冲突

我希望在盒子里有定理。我正在使用 amsthm 和 mdframded 包(我使用 Legrand Orange 模板中使用的语法)。

它可以与不同的 Babel(英语、西班牙语、法语)配合使用,但使用捷克 Babel 时出现以下错误:

!软件包 mdframed 错误:mdframed 检测到软件包 amsthm 更改了 amsthm 的定理标头,失败(mdframed)

我该如何解决这个问题?谢谢。

\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}

答案1

mdframed软件包尝试修补\deferred@thm@head,但此宏的替换文本包含-babel-czech使用作为简写,因此修补失败。

临时解决方法:

\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}

在此处输入图片描述

相关内容