# \hspace before \section?

I have tried:

\hspace[*]{5pt}\setkomafont{section}{\fontsize{45}{40}\selectfont
\fontspec{Mathilde}}


unsuccessfully. I realise that Latex usually discards white space at the start of a line e.g. a section heading.

I would appreciate any pointers how I may achieve a space before a section heading of 0.5 inches.

\documentclass[11pt,english,british,twoside,openany]{scrbook}
\usepackage{mystyle}

\begin{document}

\title{\mytitle}
\author{}
\date{}

\frontmatter
\maketitle
\begin{titlepage}
\begin{flushright}
{\huge \mytitle}
\par\end{flushright}{\huge \par}
\end{titlepage}

\begin{titlepage}
\noindent\includegraphics[width=4in,height=2in]{../img/titr_ben_sig}
\vspace*{0.5in}
\begin{flushright}
\Huge{Tears in the Rain}
\par\end{flushright}{\Huge \par}

\clearpage
\thispagestyle{empty}

\begin{center}
\end{center}
\begin{center}
\end{center}
\vspace*{0.5in}
\begin{center}
\begin{minipage}[t]{0.5\paperwidth}
\end{minipage}
\end{center}
\vspace*{0.5in}
\begin{center}
ISBN:
\end{center}
\vspace*{0.2in}
\begin{center}
A CIP Record for this book is available from the British
Library.
\end{center}
\vspace*{0.1in}
\begin{center}
Typeset in \LaTeXe
\end{center}
\end{titlepage}

\pagenumbering{gobble}% Remove page numbers (and reset to 1)
\tableofcontents

\input{matter.tex}

\end{document}[/MWE]

My style file is:

[MWE]
\ProvidesPackage{mystyle}
\usepackage{lettrine}
%\usepackage{blindtext}
\usepackage{microtype}
\usepackage{ragged2e}
\usepackage{graphicx}
\graphicspath{ {../img/} }
\usepackage{wrapfig}
\usepackage[british]{babel}
\ofoot{} %Author Name
\ifoot{} % Chapter Number
\setkomafont{section}{\textit}{\normalsize}
\renewcommand\thepart{\Alph{part}}
\usepackage{fontspec}
\parindent=0.25in
\parskip=2pt
%removes overrun on outside margin
\usepackage{hyphenat}
\tolerance=1000
\hyphenpenalty=1000
\setmainfont{Linux Libertine O} %clear font, typographers quote marks
\renewcommand*{\partpagestyle}{empty}
\usepackage{geometry}
\geometry{paperwidth=5.06in,paperheight=7.81in,
verbose,
tmargin=0.75in,
bmargin=0.75in,
inner=0.75in,
outer=0.5in,
footskip=0.45in,
twoside}
\newcommand{\mytitle}{Tears in the Rain}
\newcommand{\emptx}[1]{\textit{#1}}

\usepackage{titlesec}

\titleformat{\chapter}[display]
{\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\normalsize}
\titlespacing*{\chapter}{0pt}{25pt}{1pt}%Second number changes space
%amount

\hspace[*]{5pt}\setkomafont{section}{\fontsize{45}{40}\selectfont
\fontspec{Mathilde}}
\setkomafont{subsection}{\small}
\setkomafont{subsubsection}{\small}
\setkomafont{paragraph}{\normalsize}
\setkomafont{subparagraph}{\normalsize}

• I think you have your numbers reversed for \fontsize. But what about \renewcommand*{\sectionformat}{\hspace*{0.5in}\thesection\autodot\enskip}? (Note that I don't often use the KOMA classes, even though I always tell myself I should.) – jon Sep 23 '15 at 22:01
• No luck - nothing changes.... – Mike Sep 24 '15 at 11:41
• Hi, I have tried various combinations of your solution but, the 'section' remains fixed as before. Am I right in thinking that it is possible to override the LaTeX default behaviour of ignoring changes to section commands if they fall at the start of a line? – Mike Sep 25 '15 at 12:43
• Don't all new sections 'fall at the start of the life'? I don't really understand what you mean. The line in the above example that starts \hspace[*]{5pt} is not correct, and should not be used in the preamble. The command \fontsize has the numbers in the wrong order. The code you have provided includes no \section command that I can see. Most of the code you have provided is completely irrelvant to the problem of getting the \sections properly spaced for your layout. "No luck - nothing changes" is unfortunately not very helpful: we need to see a complete example to understand better. – jon Sep 26 '15 at 4:00

Use \RedeclareSectionCommand to set the indent of the section title. Using this command you can also change the font:

\RedeclareSectionCommand[
indent=.5in,
font=\fontsize{45}{40}\selectfont\mdseries\mathilde
]{section}


Note that I have reduced your code for the following example:

Code:

\documentclass{scrbook}
\usepackage{lipsum}

\setlength\parindent{.25in}

\usepackage{fontspec}
\newfontfamily\mathilde{Mathilde}

\RedeclareSectionCommand[
indent=.5in,
font=\fontsize{45}{40}\selectfont\mdseries\mathilde
]{section}

\begin{document}
\section{Section}
\lipsum[1-20]
\end{document}


• It is not recommended to use titlesec with a KOMA-Script class. You will get warnings. Use \RedeclareSectionCommand and other KOMA-Script possibilities instead.
• Do not set a \parskip manually. KOMA-Script classes know a parskip option with different values. Note that it is unusual to use a \parindent and a \parskip. If you really want set \parindent to 2pt use the KOMA-Script command \setparsizes{.25in}{2pt}{0pt plus 1fil}. But this \parskip may cause your problem in Book Layout in Latex.
• Use \addtokomafont and \setkomafont to change the font of the header and the page number in the header.
• First, Thank you all for your help! I've now solved my problem with the book layout thanks, largely to your support and help. Secondly, May I take this opportunity to wish you all a Very Happy and Peaceful New Year! Mike – Mike Jan 3 '16 at 19:28

i'm not a user of the koma classes, but the structure of the sectioning commands is generally parallel across document classes.

this is the definition of \section for scrbook:

\newcommand\section{\@startsection{section}{1}{\z@}%
{-3.5ex \@plus -1ex \@minus -.2ex}%
{2.3ex \@plus.2ex}%
{\ifnum \scr@compatibility>\@nameuse{scr@v@2.96}\relax
\setlength{\parfillskip}{\z@ plus 1fil}\fi
\raggedsection\normalfont\sectfont\nobreak\size@section}%
}


what you want to do is change the argument {\z@} after the {1} to be 5pt (or whatever amount of indentation you want). this can be done either with \renewcommand or by using the "patch" mechanism as described in Please tutor the usage of patchcmd and xpatch.

edit: as requested by the op, here are the details of the two change methods. first, redefining the complete command:

\renewcommand\section{\@startsection{section}{1}{5pt}%
{-3.5ex \@plus -1ex \@minus -.2ex}%
{2.3ex \@plus.2ex}%
{\ifnum \scr@compatibility>\@nameuse{scr@v@2.96}\relax
\setlength{\parfillskip}{\z@ plus 1fil}\fi
\raggedsection\normalfont\sectfont\nobreak\size@section}%
}


here, the change is made by a patch; this form requires an additional package:

\usepackage{xpatch}

\xpatchcmd{\section}
{{1}{\z@}}
{{1}{5pt}}
{}{}


5pt seems very small to me. the width of the usual paragraph indentation for this class is 1em which, for 10pt text, would typically be 10pt.

• Hi - thanks for your answer. Unfortunately, I do not understand your advice. I am an author, publishing with LaTeX, and have very little knowledge of the finer points of LaTeX :-). Could you explain a little more please? – Mike Sep 25 '15 at 12:41
• AFAIK this is not the definition of \section in KOMA-Script version 3.19a (current on CTAN). – esdd Jan 1 '16 at 20:48