![困难的 mdframed 示例](https://linux22.com/image/305505/%E5%9B%B0%E9%9A%BE%E7%9A%84%20mdframed%20%E7%A4%BA%E4%BE%8B.png)
我想做这个 mdframed 模型:
这是该pdf第21和22页的示例6:http://texdoc.net/texmf-dist/doc/latex/mdframed/mdframed.pdf
我的问题是它是否正确,如果正确,哪些包是我需要的,因为我用空格复制它,把所有的包都放在pdf中,但它不起作用(我也复制了ExampleText)。
我编译时显示的错误如下:
- 缺少数字,视为零 \protect - 计量单位非法(插入 pt)
答案1
以下是可编译的代码:
\documentclass{article}
\usepackage{amsmath}
\usepackage[framemethod=TikZ]{mdframed}
%% the following is commaon for all examples in mdframed manual
\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.
}
%%% upto here
\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}[Inhomogeneous Linear]
\ExampleText
\end{theo}
\begin{theo}
\ExampleText
\end{theo}
\end{document}
将其与您组装的代码进行比较,看看缺少什么。
有一件事我忘了提,而 Karl 提醒了我,那就是−
in −\ht
(frametitleaboveskip=\dimexpr−\ht\strutbox\relax
准确地说)是一个 Unicode 符号(U+2212 字符,感谢 Karl 提供代码),应该是减号。