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}

在此輸入影像描述

相關內容