自訂環境的兩個實例之間的空間

自訂環境的兩個實例之間的空間

我為我的練習創造了一個環境。現在的問題是,如果我有不同的練習(練習 1、練習 2 等),它們之間總是有一點空間。我有一個背景顏色,但它被中斷了,所以它看起來很愚蠢。我希望沒有中斷,這樣顏色就不會中斷。我怎樣才能做到這一點?我不知道如何修改我的環境的定義來教 LaTeX 不要在它之間做任何空格...

這是我的程式碼:

\documentclass{book}
\usepackage{geometry}
\geometry{left=4cm,right=3cm, top=2cm, bottom=2cm} 
\usepackage[ngerman]{babel}
\usepackage[final]{pdfpages} 
\usepackage{xcolor,bookmark}         
\usepackage{graphicx}  
\usepackage{multicol} 
\usepackage[bottom]{footmisc}
\usepackage{shadethm}
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{paralist}
\usepackage{amssymb}
\usepackage[framemethod=tikz]{mdframed}

\definecolor{aufgaben}{rgb}{0.9333,0.93333,0.933333}

\newtheoremstyle{mystyle2}
  {\topsep}{\topsep}{}{}%
  {\bfseries}{}{.5em}{}%

\theoremstyle{mystyle2}

\newmdtheoremenv[hidealllines=true,
backgroundcolor=aufgaben,skipabove=\topsep,
skipbelow=\topsep]{aufgabe}{Aufgabe}


\begin{document}
text\\ a lot of text\\
\begin{aufgabe}
the excercise
\end{aufgabe}
%no space here! please!
\begin{aufgabe}
the next excercise
\end{aufgabe}
text\\
ext\\
ext\\ really a lot of text\\ text\\ text\\
ext\\ text\\ text\\
\end{document}

(我知道 LaTeX 根據文本量來設定練習,而且,如果頁面充滿文本,文本之間仍然有一點空間,我不想在文本之間有任何空間!)

答案1

\topsep正如芭芭拉注意到的,您在程式碼中使用了四次。您必須刪除其中兩個 \newtheoremstyle才能獲得

\newtheoremstyle{mystyle2}
  {}{}{}{}%
  {\bfseries}{}{.5em}{}%

因此,您不會獲得不必要的空間(陰影區域內)。此外,在 中的其他兩個實例中\newmdtheoremenv,您應該使skipaboveskipbelow等於0ptlike

\newmdtheoremenv[hidealllines=true,
backgroundcolor=aufgaben,skipabove=0pt,
skipbelow=0pt]{aufgabe}{Aufgabe}

它有效。

在此輸入影像描述

相關內容