0

I defined a personalized theorem environment, such that, there should be a vertical left bar aligned with the environment and the length of the vertical bar should be exactly as long as the text inside the environment, i.e., the length of the vertical bar should not continue before or after the environment.

The problem is: when the environment split between two pages, the next line after the environment stick to the environment without space whereas when the environment is entirely in one page the next line out of environment is correctly spaced with the environment.

Please see the figures 1 & 2. The line right after "Properties 0.0.1: XXXA" is correctly spaced whereas when the environment split between two pages first line after the environment stuck to the end of the environment

enter image description here

enter image description here

Here are my codes,

%% document class
\documentclass[a4paper, 12pt]{book}
\usepackage{blindtext}
\usepackage{amsthm} %needed for theorem enviorment
\usepackage{amsmath} % needed for command eqref
\usepackage{amssymb} % needed for math fonts
\usepackage[framemethod=tikz]{mdframed} %needed for the left vertical line
\usepackage{etoolbox} %needed to add qed
\renewcommand\qedsymbol{$\blacksquare$} % Make qedsymbole black
\newcommand{\setparskip}{.3em}
\setlength{\parskip}{\setparskip}
% Used to remove extra space from top and bottom of the theorem enviorment
\makeatletter
\def\thm@space@setup{\thm@preskip=0pt
\thm@postskip=0pt}
\makeatother

% Used to activate skipbelow in the mdframed enviorment
\usepackage{xpatch}
\makeatletter
\xpatchcmd{\endmdframed}
  {\aftergroup\endmdf@trivlist\color@endgroup}
  {\endmdf@trivlist\color@endgroup\@doendpe}
  {}{}
\makeatother

\usepackage{framed}

%Theorem style
\newtheoremstyle{break}% name: break
  {} %Space above
  {} %Space below
  {\normalfont} 
  {} %Indent amount
  {\bfseries} % Theorem head font
  {{\vspace{\setparskip}}} %Punctuation after theorem head + space
  {\newline} %Space after theorem head
  {\thmname{#1}\thmnumber{ #2}:\thmnote{ #3}} % Manually specify head (headspec)

% Change theoremstyle to break (personalized theorem style)
\theoremstyle{break}

% Enviorment
\newtheorem{properties}{Properties}[section]
\surroundwithmdframed[outerlinewidth=0.4pt,
  innerlinewidth=0.4pt,
  middlelinewidth=1pt,
  middlelinecolor=white,
  innerbottommargin=0pt,
  %innertopmargin=0pt,%
  %nobreak=true,%
  skipbelow={0pt},
  skipabove={2.5\parskip},
  bottomline=false,topline=false,rightline=false]{properties}
\AtEndEnvironment{properties}{\null\hspace*{\fill}\mbox{\qedsymbol}}

\begin{document}
\begin{properties}[XXXA]
\blindtext
\end{properties}
this line is not stuck 

\begin{properties}[XXXB]
\blindtext
\blindtext
\blindtext
\end{properties}
this line is stuck

\begin{properties}[XXXC]
\blindtext
\end{properties}
this line not stuck

\begin{properties}[XXXD]
\blindtext
\end{properties}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.