删除 postheadhook thmtools 后的空白

删除 postheadhook thmtools 后的空白

我想去掉后面愚蠢的空白postheadhook \newline (参见之前

在以下示例中:

    %!TEX TS-program = XeLaTeX
%!TEX encoding = UTF-8 Unicode


% DEFINITIONS ===================================================
\documentclass[
    12pt,
    a4paper,
    twoside,
    headings=normal,
    titlepage=true
]{scrreprt}


\usepackage[centertags]{amsmath}
\usepackage[framemethod=TikZ]{mdframed}
\usepackage{amsthm}
\usepackage{thmtools}

\usepackage{lipsum}


\newlength{\spacingtheorem}
\setlength{\spacingtheorem}{2mm}
\declaretheoremstyle[%
        headfont=\bfseries,%
        notebraces={(}{)},%
        bodyfont=\normalfont,%
        notefont=\itshape,%
        headpunct={:},%
        postheadspace=0mm,%
        postheadhook={\hspace{0mm}\newline},%{\textcolor{red}{\rule[.6ex]{\linewidth}{0.4pt}}\\},%
        spacebelow=0mm,%
        spaceabove=0mm,%
        mdframed={%
          frametitlealignment=\raggedright,%
          linecolor=black,%
          middlelinewidth=1pt,%
          innertopmargin=0.5\baselineskip,%
          innerbottommargin=0.5\baselineskip,%
          innerleftmargin=10pt,%
          innerrightmargin=10pt,%
          skipbelow=\dimexpr-\parskip+\spacingtheorem\relax,%
          skipabove=\spacingtheorem,%
          font=\upshape%
        }%
]{myFramedTheoremStyle}%

\declaretheorem[
    style=myFramedTheoremStyle,
    name=Theorem,
    numberwithin=chapter
]{theorem1}

\declaretheorem[
    style=myFramedTheoremStyle,
    name=Definition,
    numberwithin=chapter
]{example1}

% Basic Command
\ExplSyntaxOn
    \NewDocumentEnvironment{example} { o o }
     {%
      \IfNoValueTF{#1} {\begin{example1}}{ \begin{example1}[#1] }%                                 
      \IfNoValueTF{#2} {}{\label{#2}}%
     }%
     {%
      \end{example1}%
     }%
\ExplSyntaxOff



\begin{document}
\raggedbottom

\setlength{\parskip}{0mm}
\setlength{\parsep}{0mm}
\setlength{\parindent}{0mm}
\lipsum[1]
\begin{example}[asd][asd]
asdasd
\end{example}
\lipsum[1]
\end{document}  

我怎样才能实现这个目标?

在此处输入图片描述

答案1

这是由于插入 造成的\label。我在插入后添加了\ignorespaces,这似乎消除了虚假的间距:

在此处输入图片描述

\documentclass[
  12pt,
  a4paper,
  twoside,
  headings=normal,
  titlepage=true
]{scrreprt}


\usepackage[centertags]{amsmath}
\usepackage[framemethod=TikZ]{mdframed}
\usepackage{amsthm}
\usepackage{thmtools}

\usepackage{lipsum}


\newlength{\spacingtheorem}
\setlength{\spacingtheorem}{2mm}
\declaretheoremstyle[%
  headfont=\bfseries,%
  notebraces={(}{)},%
  bodyfont=\normalfont,%
  notefont=\itshape,%
  headpunct={:},%
  postheadspace=0mm,%
  postheadhook={\hspace{0mm}\newline},%{\textcolor{red}{\rule[.6ex]{\linewidth}{0.4pt}}\\},%
  spacebelow=0mm,%
  spaceabove=0mm,%
  mdframed={%
    frametitlealignment=\raggedright,%
    linecolor=black,%
    middlelinewidth=1pt,%
    innertopmargin=0.5\baselineskip,%
    innerbottommargin=0.5\baselineskip,%
    innerleftmargin=10pt,%
    innerrightmargin=10pt,%
    skipbelow=\dimexpr-\parskip+\spacingtheorem\relax,%
    skipabove=\spacingtheorem,%
    font=\upshape%
  }%
]{myFramedTheoremStyle}%

\declaretheorem[
  style=myFramedTheoremStyle,
  name=Theorem,
  numberwithin=chapter
]{theorem1}

\declaretheorem[
  style=myFramedTheoremStyle,
  name=Definition,
  numberwithin=chapter
]{example1}

% Basic Command
\NewDocumentEnvironment{example} { o o }
  {%
   \IfNoValueTF{#1} {\begin{example1}}{ \begin{example1}[#1] }%                                 
   \IfNoValueTF{#2} {}{\label{#2}\ignorespaces}%
  }%
  {%
   \end{example1}%
  }%



\begin{document}
\raggedbottom

\setlength{\parskip}{0mm}
\setlength{\parsep}{0mm}
\setlength{\parindent}{0mm}
\lipsum[1]
\begin{example}[asd][asd]
asdasd
\end{example}
\lipsum[1]
\end{document}  

答案2

我不确定你为什么要在框架前后留出如此狭窄的空间。postfoothook不过,钥匙可以提供帮助。后面的垂直空间mdframed通常很奇怪。

当然,example为了避免\label发出虚假空格而使用两个可选参数进行定义是错误的。

也许从的文档中看不清楚thmtools,但postheadspace可以接收值,因为它实际上是一个接受它\newline的间距参数的接口(参见其定理风格的定义)。amsthmbreak

环境名称周围的括号应该是直立的,所以我在定义中使用了\textup(和。\textup)

\documentclass[
    12pt,
    a4paper,
    twoside,
    headings=normal,
    titlepage=true
]{scrreprt}


\usepackage[centertags]{amsmath}
\usepackage[framemethod=TikZ]{mdframed}
\usepackage{amsthm}
\usepackage{thmtools}

\usepackage{lipsum}


\newlength{\spacingtheorem}
\setlength{\spacingtheorem}{2mm}
\declaretheoremstyle[
  headfont=\bfseries,
  notebraces={\textup(}{\textup)},
  bodyfont=\normalfont,
  notefont=\itshape,
  headpunct={:},
  postheadspace=\newline,
  spacebelow=0mm,
  spaceabove=0mm,
  postfoothook=\vspace{-.7\baselineskip},
  mdframed={
    frametitlealignment=\raggedright,
    linecolor=black,
    middlelinewidth=1pt,
    innertopmargin=0.5\baselineskip,
    innerbottommargin=0.5\baselineskip,
    innerleftmargin=10pt,
    innerrightmargin=10pt,
    skipbelow=\dimexpr-\parskip+\spacingtheorem\relax,
    skipabove=\spacingtheorem,
  },
]{myFramedTheoremStyle}

\declaretheorem[
    style=myFramedTheoremStyle,
    name=Theorem,
    numberwithin=chapter
]{theorem1}

\declaretheorem[
    style=myFramedTheoremStyle,
    name=Definition,
    numberwithin=chapter
]{example}

\begin{document}
\raggedbottom

\lipsum[1]
\begin{example}[asd]\label{asd}
asdasd
\end{example}
\lipsum[1]
\end{document}  

在此处输入图片描述

相关内容