1

This question is a follow-up question to my question here. @karlkoeller's answer fully answered my question. However in my document I have some places where the itemized list is placed directly after a \subsection. This leads to the spacing around subsections not being uniform. I would like to mach the spacing around the The Bee's Knees heading so that the other \subsections set the same spacing. Here an illumination of my problem and MWE below.

New ununiformness

\documentclass{article}

% insert vertical space between paragraphs
\setlength{\parskip}{\baselineskip} 

% Modifies itemized lists with enumitem http://www.ctan.org/pkg/enumitem
\usepackage{enumitem}
\setlist[itemize]{noitemsep, topsep=0pt, before={\vspace*{-\baselineskip}}} 

 % http://tug.ctan.org/tex-archive/macros/latex/contrib/blindtext/blindtext.pdf
\usepackage{blindtext} 

\begin{document}

\section*{\centering{New ununiformness}}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam ornare diam vitae nisl pharetra, quis tincidunt augue finibus. Etiam dignissim lectus eu odio viverra tincidunt. Nulla ultricies finibus magna, et rutrum nisi volutpat quis. Praesent eget eros sapien. 

\noindent
This is the things cancel each other out:
\begin{itemize}
\item dummy first item
\item insert vertical space between paragraphs
\item \verb|[topsep=0pt]| in \verb| \usepackage{enumitem} |
\item dummy last item
\end{itemize}

\subsection*{\centering{Not too funky situation in my actual document}}

Nulla ultricies finibus magna, et rutrum nisi volutpat quis. Praesent eget eros sapien. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam ornare diam vitae nisl pharetra, quis tincidunt augue finibus. Etiam dignissim lectus eu odio viverra tincidunt. 

\subsection*{\centering{The Bee's Knees}}
% spacing I like and would like to copy to my other \subsection
\begin{itemize}
\item dummy first item, that is a bit longer to illustrate how close to the subsection heading compared to above.
\item dummy last item
\end{itemize}

\subsection*{\centering{Random Randomness}}

Aliquam ornare diam vitae nisl pharetra, quis tincidunt augue finibus. Etiam dignissim lectus eu odio viverra tincidunt. Nulla ultricies finibus magna, et rutrum nisi volutpat quis. Praesent eget eros sapien. 

\end{document}
  • Have you tried compiling it? \test is just a marker, visually showing the distance between the base line of \section and the first line of text after it. Try running it and see what happens if you set \parskip to 0pt. – daleif Feb 19 '15 at 15:37
  • @daleif, I have, that was the first ting I did. It is however a bit more advanced then what I can handle, I am simply trying to solve my concrete problem for now. If I let people have a working example that mimics my case they are also free to suggest alternative solutions. – uT5r Feb 19 '15 at 16:28
4

First of all, to obtain centered titles don't do things like

\subsection*{\centering{Not too funky situation in my actual document}}

but load the package sectsty and issue

\allsectionsfont{\centering}

Then, to achieve what you want, first of all, change your \setlist to

\setlist[itemize]{noitemsep, topsep=0pt, before={\ifdim\lastskip>0pt\vspace*{-\baselineskip}\fi}}

load the package titlesec and define

\titlespacing*{\subsection}{0pt}{3.25ex plus 1ex minus .2ex}{-1ex plus .2ex}

MWE:

\documentclass{article}

% insert vertical space between paragraphs
\setlength{\parskip}{\baselineskip}

% Modifies itemized lists with enumitem http://www.ctan.org/pkg/enumitem
\usepackage{enumitem}
\setlist[itemize]{noitemsep, topsep=0pt, before={\ifdim\lastskip>0pt\vspace*{-\baselineskip}\fi}}

\usepackage{sectsty}
\allsectionsfont{\centering}

\usepackage{titlesec}
\titlespacing*{\subsection}{0pt}{3.25ex plus 1ex minus .2ex}{-1ex plus .2ex}

\begin{document}

\section*{New ununiformness}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam ornare diam vitae nisl pharetra, quis tincidunt augue finibus. Etiam dignissim lectus eu odio viverra tincidunt. Nulla ultricies finibus magna, et rutrum nisi volutpat quis. Praesent eget eros sapien.

\noindent
This is the things cancel each other out:
\begin{itemize}
\item dummy first item
\item insert vertical space between paragraphs
\item \verb|[topsep=0pt]| in \verb| \usepackage{enumitem} |
\item dummy last item
\end{itemize}

\subsection*{Not too funky situation in my actual document}

Nulla ultricies finibus magna, et rutrum nisi volutpat quis. Praesent eget eros sapien. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam ornare diam vitae nisl pharetra, quis tincidunt augue finibus. Etiam dignissim lectus eu odio viverra tincidunt.

\subsection*{The Bee's Knees}
% spacing I like and would like to copy to my other \subsection
\begin{itemize}
\item dummy first item, that is a bit longer to illustrate how close to the subsection heading compared to above.
\item dummy last item
\end{itemize}

\subsection*{Random Randomness}

Aliquam ornare diam vitae nisl pharetra, quis tincidunt augue finibus. Etiam dignissim lectus eu odio viverra tincidunt. Nulla ultricies finibus magna, et rutrum nisi volutpat quis. Praesent eget eros sapien.

\end{document} 

Output:

enter image description here

|improve this answer|||||
  • Amazing! Thanks. (@daleif have a look at this) – uT5r Feb 19 '15 at 18:31
  • @uT5r You're always welcome! – karlkoeller Feb 19 '15 at 18:36
  • I just found out that it is possible to simply. I can add \titleformat{\subsection}[block]{\large\bfseries\filcenter}{}{0em}{} and then you do not load the package sectsty. Is there a good reason why you did not do that? – uT5r Feb 19 '15 at 18:56
  • @uT5r With sectsty it is automatic for all sectioning commands. With titlesec you have to make a declaration for each one. – karlkoeller Feb 19 '15 at 19:01
  • @uT5r Anyway, if you don't want to load sectsty add also \titleformat{\section}[block]{\Large\bfseries\filcenter}{}{0em}{}. I don't know if you're also using \subsubsections... – karlkoeller Feb 19 '15 at 19:04

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.