3

I use title format to change the look of my section commands and so on, after making a new section for some reason the spacing used by itemize is being ruined and it is not leaving the proper amount of white space. Ive left a picture of what I'm talking about below and the code needed to recreate it. Any help fixing this issue would be greatly appreciated.

enter image description here

\documentclass{book}
%Packages 
\RequirePackage[dvipsnames]{xcolor}
\RequirePackage{geometry}
\RequirePackage{titling}
\RequirePackage{fancyhdr}
\RequirePackage[many]{tcolorbox}
\RequirePackage{titlesec}
\RequirePackage{enumitem}


\definecolor{r}{rgb}{0.9,.3,.5}

\newtcbtheorem[number within=section]{thrm}{Theorem}%
{enhanced, breakable,
colback=r!7, colbacktitle=r!17, coltitle=RedViolet,
frame hidden, parbox=false,
arc=1.85pt, titlerule=0pt, toptitle=2pt, bottomtitle=2pt,
fonttitle=\bfseries,separator sign= : \hspace{0.005cm},
segmentation style={solid, draw=r!55, line width=1pt}}{th}
%\begin{thrm}{Rank-Nullity Theorem}{env}

\titleformat{\section}[hang]{\LARGE}{\fbox{\thesection}}{12pt}{}

\begin{document}
    test
\chapter{awd}

\section{adww}
\begin{thrm}{w}{w}
woluygfouyesgvfuyesvfkluYSv
\begin{itemize}
  \item awd   
  \item dwa
\end{itemize}
\end{thrm}

\begin{thrm}{w}{w}
  woluygfouyesgvfuyesvfkluYSv
  \begin{itemize}
    \item awd   
    \item dwa
  \end{itemize}
  \end{thrm}
\end{document}

2 Answers 2

2

You want to set \@nobreakfalse at the beginning of the environment. If the thrm environment directly follows a sectional title, \if@nobreak returns true and this has the bad effect on the inner itemize.

\documentclass{book}
%Packages 
\usepackage[dvipsnames]{xcolor}
\usepackage{geometry}
\usepackage{titling}
\usepackage{fancyhdr}
\usepackage[many]{tcolorbox}
\usepackage{titlesec}
\usepackage{enumitem}


\definecolor{r}{rgb}{0.9,.3,.5}

\newtcbtheorem[number within=section]{thrm}{Theorem}{
  enhanced,
  breakable,
  colback=r!7,
  colbacktitle=r!17,
  coltitle=RedViolet,
  frame hidden,
  parbox=false,
  arc=1.85pt,
  titlerule=0pt,
  toptitle=2pt,
  bottomtitle=2pt,
  fonttitle=\bfseries,
  separator sign={ : },
  segmentation style={solid, draw=r!55, line width=1pt},
  before upper=\csname @nobreakfalse\endcsname
}{th}

\titleformat{\section}[hang]{\LARGE}{\fbox{\thesection}}{12pt}{}

\begin{document}

\chapter{awd}

\section{adww}
\begin{thrm}{w}{A}
woluygfouyesgvfuyesvfkluYSv
\begin{itemize}
  \item awd   
  \item dwa
\end{itemize}
\end{thrm}

\begin{thrm}{w}{B}
  woluygfouyesgvfuyesvfkluYSv
  \begin{itemize}
    \item awd   
    \item dwa
  \end{itemize}
  \end{thrm}
\end{document}

enter image description here

3
  • Thanks man! Any way I can generalize this to chapter, subsection levels?
    – xyz04
    Commented Jun 15, 2023 at 20:46
  • Update this seems like it may already be generalized to other section levels, would you be able to confirm that?
    – xyz04
    Commented Jun 15, 2023 at 20:54
  • 1
    @xyz04 It should work with every level.
    – egreg
    Commented Jun 15, 2023 at 21:01
0

I dont know why but if You add something after section command like this:

\section{adww}
    
    \textcolor{r}{text}\\
    \color{r}
    \rule{\textwidth}{4pt}
    \color{black}
    text

or simply this:

\section{adww}
    
    text

You dont have any trouble on vertical spacing.

With the correction proposed You ha what requested:

enter image description here

1
  • I do know that this is an option, but the purpose of asking the question was to find a possible solution so I can circumnavigate this option.
    – xyz04
    Commented Jun 14, 2023 at 8:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .