考虑以下 MWE:
\documentclass{article}
\usepackage[framemethod=TikZ]{mdframed} % noteboxes, boxes, etc.
\usepackage{calc}
\newcommand{\definebox}[2]{%
\newcounter{#1}
\newenvironment{#1}[1][]{%
\stepcounter{#1}%
\mdfsetup{%
frametitle={%
\tikz[]
\node[rectangle,fill=white]
{\strut \MakeUppercase#1~\csname the #1\endcsname\ifstrempty{##1}{}{:~##1}};}}%
\mdfsetup{innertopmargin=1pt,linecolor=#2,%
linewidth=2pt,topline=true,
frametitleaboveskip={\dimexpr (\ht\strutbox)*-1\relax},}%
\begin{mdframed}[]\relax%
}{\end{mdframed}}%
}
\definebox{definition}{}
\begin{document}
\section{Cats}
Warm kitty, sweet kitty, little ball of fur. Warm kitty, sweet kitty, purr, purr, purr.
\begin{definition}[Kitten.]
A kitten is a baby cat.
\end{definition}
\end{document}
它产生如下输出:
如果我更改frametitleaboveskip={\dimexpr (\ht\strutbox)*-1\relax}
为frametitleaboveskip={\dimexpr (\ht\strutbox)*-2\relax}
,输出将如下所示:
但如果将其改为frametitleaboveskip={\dimexpr (\ht\strutbox)*-1.99\relax}
,输出似乎与相同,frametitleaboveskip={\dimexpr (\ht\strutbox)*-1\relax}
只是pt
出现了一个神秘的情况:
我怎样才能将frametitle
盒子向上移动实际的量?
答案1
参见这个解释:https://tex.stackexchange.com/a/126359/47927
简而言之,你必须重新排序
\dimexpr (\ht\strutbox)*-1.99\relax
到
\dimexpr -1.99\ht\strutbox\relax