[Tex/LaTex] Memoir class — Displayed heading for subsubsection

memoirsectioningtitlesec

I am trying to make a subsection heading with the memoir class.
The problem is the following:

I want to have a displayed heading for my subsubsection. The text should begin right after the subsubsec heading as a new line, and NOT as a new paragraph.

Memoir sets as a vertikal space after the headings the lenghts
afterskip + \parskip(of heading font) + \baselineskip(of text font).
To solve the problem, it would be plausible to set afterskip to -parskip. But, if afterskip becomes a negative value, the heading will turn into a run-in style.

I made my tests with the following minimal example:

\documentclass[11pt]{memoir}
\parskip9pt
\parindent0pt

\setcounter{secnumdepth}{2}
\setbeforesubsubsecskip{9pt}
\setaftersubsubsecskip{1pt}

\setsubsubsecheadstyle{\scshape}
\begin{document}

\subsubsection{lorem ipsum}
lorem ipsum

lorem ipsum 
\end{document}

I used before the titlesec package, and it was excelent, till I not tried to use \titleref… This \titleref doesn't work with this package only for the chapters. If I dont't use titlesec, the references for sections working also good.

Best Answer

Here is a temp fix

\makeatletter
\renewcommand{\@startsection}[6]{%
  \@nameuse{#1block}%
  \ifraggedbottomsection\if@nobreak\else
    \vskip\z@\@plus\bottomsectionskip
    \penalty\z@
    \vskip\z@\@plus -\bottomsectionskip
  \fi\fi
  \def\m@msecn@me{#1}%
  \if@noskipsec \leavevmode \fi
  \par
  \@tempskipa #4\relax
  \@afterindenttrue
  \ifdim \@tempskipa <\z@
    \@tempskipa -\@tempskipa \@afterindentfalse
  \fi
  \if@nobreak
    \everypar{}%
  \else
    \addpenalty\@secpenalty%
    \addvspace\@tempskipa
    \addvspace{-\parskip}% <--- added
  \fi
  \@ifstar
    {\@ssect{#3}{#4}{#5}{#6}}%
    {\@trplargoom{\M@sect{#1}{#2}{#3}{#4}{#5}{#6}}}}

\def\@xsect#1{%
  \@tempskipa #1\relax
  \ifdim \@tempskipa>\z@
  \par
  \nobreak
  \vskip \@tempskipa
  \vskip-\parskip% <--- added
  \@afterheading
  \else
  \@nobreakfalse
  \global\@noskipsectrue
  \everypar{%
    \if@noskipsec
     \global\@noskipsecfalse
     {\setbox\z@\lastbox}%
     \clubpenalty\@M
     \begingroup \@svsechd \endgroup
     \unskip
     \@tempskipa #1\relax
     \hskip -\@tempskipa
     \else
    \clubpenalty \@clubpenalty
    \everypar{}%
     \fi}%
   \fi
  \ignorespaces}
\makeatother
Related Question