mdframed 示例抛出错误

mdframed 示例抛出错误

我正在尝试mdframed包装文档工作(mdframed-example-default第 5 页),但它引发了以下错误

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

并在打印环境内容之前显示一个奇怪的“pt”,标题框的位置太低。如何解决这个问题?标题框应该位于顶行的中间。

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

导致

在此处输入图片描述

答案1

线路

frametitleaboveskip=\dimexpr−\ht\strutbox\relax

在其之前有一个奇怪的字符(可能是复制粘贴过程的结果),\ht必须用标准减号替换:

frametitleaboveskip=\dimexpr-\ht\strutbox\relax

代码:

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

在此处输入图片描述

相关内容