[Tex/LaTex] newcommand titlespacing

sectioningspacing

To generate space between \section i am using \titlespacing*{\section}{0cm}{1cm}{0.5cm}, doing the same for subsection. Is it possible to generate titlespacing between own commands? I need three blank lines before "Notes" and one after "Notes"

\documentclass[10pt]{scrbook}
\usepackage{lipsum} % dummy text
\usepackage[english,ngerman]{babel}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{times}
\usepackage{helvet}
\usepackage{endnotes}
\usepackage{titlesec}


% Spacing between section and text
% Syntax: \titlespacing*{<command>}{<left>}{<before-sep>}{<after-sep>}
\titlespacing*{\subsection}{0cm}{1cm}{0.5cm}
\titlespacing*{\section}{0cm}{1cm}{1cm}


 %ENDNOTENLAYOUT%
\renewcommand\enoteformat{\noindent\setlength\hangindent{0.5cm}\makebox[0.5cm][l]{\theenmark\,}}
\def\enotesize{\footnotesize}
\renewcommand{\notesname}{\normalsize\textit{Notes}}
\let\footnote=\endnote


\pagestyle{plain}
\begin{document}


\section{Beispiel}
\lipsum[1]


\subsection*{Endnotes}
\footnote{\lipsum[1]}\lipsum[2]
\footnote{\lipsum[1]}
\lipsum[1]

\theendnotes

\end{document}

enter image description here

Best Answer

Note that it is not recommended to use titlesec together with a KOMA-Script class. So I will use \RedeclareSectionCommand to change the skips before and after the section titles.

\enoteheading uses \section* for the note heading. So you can prepend a \RedeclareSectionCommand to get the desired result. Note that I am not sure if \enoteheading should be really on the same sectioning level as \section? But because of the star there is no TOC entry and no section number. So maybe it is not a problem.

\usepackage{xpatch}
\xpretocmd\enoteheading{%
  \RedeclareSectionCommand[
      beforeskip=3\baselineskip,
      afterskip=\baselineskip,
      font=\normalsize\itshape
    ]{section}%
  }{}{\PatchFailed}
\renewcommand{\notesname}{Notes}

enter image description here

Code:

\documentclass[10pt]{scrbook}
\usepackage{lipsum} % dummy text
\usepackage[english,ngerman]{babel}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{times}
\usepackage{helvet}
\usepackage{endnotes}

\RedeclareSectionCommand[
  beforeskip=-1cm,
  afterskip=1cm
]{section}

\RedeclareSectionCommand[
  beforeskip=-1cm,
  afterskip=.5cm
]{subsection}

 %ENDNOTENLAYOUT%
\renewcommand\enoteformat{\noindent\setlength\hangindent{0.5cm}\makebox[0.5cm][l]{\theenmark\,}}
\def\enotesize{\footnotesize}

\usepackage{xpatch}
\xpretocmd\enoteheading{%
  \RedeclareSectionCommand[
      beforeskip=3\baselineskip,
      afterskip=\baselineskip,
      font=\normalsize\itshape
    ]{section}%
  }{}{\PatchFailed}
\renewcommand{\notesname}{Notes}

\let\footnote=\endnote

\pagestyle{plain}
\begin{document}
\section{Beispiel}
\lipsum[1]
\subsection*{Endnotes}
\footnote{\lipsum[1]}\lipsum[2]
\footnote{\lipsum[1]}
\lipsum[1]

\theendnotes
\end{document}

If you have a really old KOMA-Script version (3.14 or older) then ist is easier to use titlesec

\documentclass[10pt]{scrbook}
\usepackage{lipsum} % dummy text
\usepackage[english,ngerman]{babel}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{times}
\usepackage{helvet}
\usepackage{endnotes}
\usepackage{titlesec}

% Spacing between section and text
% Syntax: \titlespacing*{<command>}{<left>}{<before-sep>}{<after-sep>}
\titlespacing*{\subsection}{0cm}{1cm}{0.5cm}
\titlespacing*{\section}{0cm}{1cm}{1cm}

 %ENDNOTENLAYOUT%
\renewcommand\enoteformat{\noindent\setlength\hangindent{0.5cm}\makebox[0.5cm][l]{\theenmark\,}}
\def\enotesize{\footnotesize}
%
\usepackage{xpatch}
\xpretocmd\enoteheading{%
  \titlespacing*{\section}{0cm}{3\baselineskip}{1\baselineskip}%
}{}{\PatchFailed}
\renewcommand{\notesname}{\normalsize\textit{Notes}}
\let\footnote=\endnote

\pagestyle{plain}
\begin{document}
\section{Beispiel}
\lipsum[1]
\subsection*{Endnotes}
\footnote{\lipsum[1]}\lipsum[2]
\footnote{\lipsum[1]}
\lipsum[1]

\theendnotes
\end{document}