1

I want to vary my linespacing in my LaTeX document. I want the footer, headlines and other parts of the document to be at onehalfspacing, but the main text to be doublespacing.

My solution was to use setspace with \doublespacing in the text and also the footer to specify it for every text. Similar to this thread: https://tex.stackexchange.com/a/542102

\documentclass[fontsize = 12pt]{scrreprt}       
\usepackage{lmodern}                    % for different font style
\usepackage{lipsum}                     % for dummy text
\usepackage{tabularx}                   % for tabulars
\usepackage{booktabs}                   % for tabular functions
\usepackage{scrlayer-scrpage}           % for modifying footer
\clearpairofpagestyles                  % remove standard style (removes default pagenumbering)

\usepackage[onehalfspacing]{setspace} % change linespace to 2

% defining the footer \newcommand{\footerON} {
\ifoot[ % footer for even pages \onehalfspacing \begin{tabularx}{\textwidth}{m{0.79\textwidth}Xr} % create tabular over textwidth \midrule % horizontal line over footer A long title of my document which stretches over two lines created by KarateKlaus & &
\thepage % pagenumbering on the right \end{tabularx} \doublespacing ]
{ % same footer for odd pages \onehalfspacing \begin{tabularx}{\textwidth}{m{0.79\textwidth}Xr} \midrule A long title of my document which streches over two lines created by KarateKlaus & & \thepage \end{tabularx} \doublespacing } }
\newcommand{\footerOFF}{\ifoot[]{}}

\begin{document}

\footerON

\chapter{multiline chaptertitle to test the linespaceing}
    \doublespacing
    \lipsum[1-1]
    \par
    \onehalfspacing

\section{multiline sectiontitle to test the linespaceing in a section}
    \doublespacing
    \lipsum[1-3]
    \par
    \onehalfspacing

\end{document}

The problem with this methode seems to be that the horizontal line over the footer isn't the same height through the document. When a paragraph continues at the next side, the whole footer moves down just so slightly.

Is there a way to fixate the footer or at least counter my problem?

1 Answers1

1

Off topic: The comments in your code regarding \ifoot are wrong. The syntax of \ifoot is

\ifoot[<content for page style plain.scrheadings>]{<content for page style scrheadings>}

There is also a short version

\ifoot*{<content for both page styles plain.scrheadings and scrheadings>}


There is a spurious space before \onehalfspacing in your code. You have to comment these spaces:

\ifoot*{% <- removes spurious space!
  \onehalfspacing
  ...  
  \doublespacing
}

But you should remove \onehalfspacing and \doublespacing from \ifoot. Using

\KOMAoptions{onpsinit=\onehalfspacing}

you will get the desired spacing for page header and footer.

\documentclass[fontsize = 12pt,
  headheight=24pt,footheight=61pt% avoids the warning regarding head height and foot height
]{scrreprt}
\usepackage{lmodern}
\usepackage{lipsum}% only for dummy text
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{scrlayer-scrpage}
\clearpairofpagestyles% removes default header and footer content for both page styles plain.scrheadings and scrheadings

\usepackage[onehalfspacing]{setspace}

\KOMAoptions{onpsinit=\onehalfspacing}% header and footer use \onehalfspacing

% defining the footer \newcommand{\footerON} {% \ifoot{% <- removes spurious space! \begin{tabularx}{\textwidth}{m{0.79\textwidth}>{\raggedleft}X} \midrule A long title of my document which stretches over two lines created by KarateKlaus & \pagemark \end{tabularx} }% } \newcommand{\footerOFF}{\ifoot{}}

\begin{document} \footerON \chapter{multiline chaptertitle to test the linespaceing} \doublespacing \lipsum[1] \par \onehalfspacing

\section{multiline sectiontitle to test the linespaceing in a section} \doublespacing \lipsum[1-3] \par \onehalfspacing \end{document}

enter image description here

But maybe you can use

\documentclass[fontsize = 12pt,
  headheight=24pt,footheight=61pt% avoids the warning regarding head height and foot height
]{scrreprt}
\usepackage{lmodern}
\usepackage{lipsum}% only for dummy text
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{scrlayer-scrpage}
\clearpairofpagestyles% removes default header and footer content for both page styles plain.scrheadings and scrheadings

\usepackage[doublespacing]{setspace} % change linespace

\AddtoDoHook{heading/begingroup}{\useonehalfspacing}% headings should use \onehalfspacing \newcommand*\useonehalfspacing[1]{\onehalfspacing}

\KOMAoptions{onpsinit=\onehalfspacing}% header and footer use \onehalfspacing

% defining the footer \newcommand{\footerON} {% \ifoot{% <- removes spurious space! \begin{tabularx}{\textwidth}{m{0.79\textwidth}>{\raggedleft}X} \midrule A long title of my document which stretches over two lines created by KarateKlaus & \pagemark \end{tabularx} }% } \newcommand{\footerOFF}{\ifoot{}}

\begin{document} \footerON \chapter{multiline chaptertitle to test the linespaceing} \lipsum[1]

\section{multiline sectiontitle to test the linespaceing in a section} \lipsum[1-3] \end{document}

enter image description here

esdd
  • 85,675