1

I'm trying to indent all my contents except for all headings. I tried using the method described in this method for indenting all the normal text. However, if I combine it with either a \title command or a titlepage (as shown below), I get an additional blank page before the titlepagestarts. (If I apply foot and head elements, those elements are shown on the empty page)

My guess is, that the abovelinked method adds some sort of blank spacing which moves the whole titlepage, but I can't get it to work properly.

\documentclass[english,liststotoc]{scrartcl}
\usepackage{helvet}
\renewcommand{\familydefault}{\sfdefault}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\setlength{\parskip}{\medskipamount}
\setlength{\parindent}{0pt}
\usepackage{float}

\usepackage{titlesec}

%% https://tex.stackexchange.com/questions/79521/indent-all-the-normal-text
\newcommand*{\LeftMargin}{0.5cm}%
\newcommand*{\RightMargin}{0.0cm}%

\def\ChangeMargin#1#2{\list{}{\rightmargin#2\leftmargin#1}\item[]}%
\let\endChangeMargin\endlist%
\AtBeginDocument{\ChangeMargin{\LeftMargin}{\RightMargin}}
\AtEndDocument{\endChangeMargin}

\titlelabel{\hspace*{-\LeftMargin}\thetitle~}

\begin{document}

\begin{titlepage}

TEST

\end{titlepage}

CONTENT

\end{document}

2 Answers 2

0

With a KOMA-Script class you can redefine \sectionlinesformat to shift the section numbers in the margin. To enlarge header and footer you have to use a package for header and footer.

scrlayer-scrpage

The recommended header and footer package for usage with KOMA-Script classes is scrlayer-scrpage.

\documentclass[
  english,
  listof=totoc,
  %twoside,
  parskip=half- % using parskip instead parindent
]{scrartcl}[2015/10/03]
\usepackage{blindtext}% dummy text

\usepackage{helvet}
\renewcommand{\familydefault}{\sfdefault}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{babel}

\newcommand\LeftMargin{.5cm}
\renewcommand*\sectionlinesformat[4]{%
  \ifstr{#3}{}{}{\hspace*{-\LeftMargin}}% unnumbered sections are not shifted
  #3#4%
}
\usepackage[
  headwidth=\the\textwidth+\LeftMargin:-\LeftMargin:\LeftMargin% enlarge the headwidth
  ,headsepline% to make the header visible
  ,footwidth=head:-\LeftMargin:\LeftMargin% enlarge the footwidth
  ,footsepline% to make the footer visible
]{scrlayer-scrpage}

\begin{document}

\begin{titlepage}
TEST
\end{titlepage}

\tableofcontents
\blinddocument
\end{document}

Result:

enter image description here


scrpage2

Note that scrpage2 is outdated. Its successor is scrlayer-scrpage. The following example does not work für twosided documents because scrpage2 does not know different offsets for odd and even pages.

\documentclass[
  english,
  listof=totoc,
  parskip=half- % using parskip instead parindent
]{scrartcl}[2015/10/03]
\usepackage{blindtext}% dummy text

\usepackage{helvet}
\renewcommand{\familydefault}{\sfdefault}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{babel}

\newcommand\LeftMargin{.5cm}
\renewcommand*\sectionlinesformat[4]{%
  \ifstr{#3}{}{}{\hspace*{-\LeftMargin}}% unnumbered sections are not shifted
  #3#4%
}
\usepackage[headsepline,footsepline]{scrpage2}
\pagestyle{scrheadings}
\setheadwidth[-\LeftMargin]{\dimexpr\textwidth+\LeftMargin\relax}
\setfootwidth[-\LeftMargin]{head}

\begin{document}

\begin{titlepage}
TEST
\end{titlepage}

\tableofcontents
\blinddocument
\end{document}

fancyhdr

Here is also a suggestion for fancyhdrthat works with both onesided and twosided documents.

\documentclass[
  english,
  listof=totoc,
  %twoside,
  parskip=half- % using parskip instead parindent
]{scrartcl}[2015/10/03]
\usepackage{blindtext}% dummy text

\usepackage{helvet}
\renewcommand{\familydefault}{\sfdefault}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{babel}

\newcommand\LeftMargin{.5cm}
\renewcommand*\sectionlinesformat[4]{%
  \ifstr{#3}{}{}{\hspace*{-\LeftMargin}}% unnumbered sections are not shifted
  #3#4%
}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhfoffset[L]{\LeftMargin}
\renewcommand\footrulewidth{.4pt}% to make the footer visible

\begin{document}

\begin{titlepage}
TEST
\end{titlepage}

\tableofcontents
\blinddocument
\end{document}
4
  • When trying your solution, I get an error ! LaTeX Error: Command \scr@fnt@headtopline already defined. Or name \end... illegal, see p.192 of the manual. However, this error seems strange since there is no headtopline command whatsoever in my preamble
    – PSC
    Commented Apr 11, 2016 at 16:10
  • (I'm leaving the comment above for others with the same problem). I had a clash with the scrpage2-package. Removing it and changing the footwidth in the same way as you suggested for the headwidth solved my problem. Thanks!
    – PSC
    Commented Apr 11, 2016 at 16:20
  • @user102410 See my updated answer. scrpage2 is outdated. Its successor is scrlayer-scrpage. But I have added an example for scrpage2 (only for onesided documents) and an example for fancyhdr.
    – esdd
    Commented Apr 12, 2016 at 8:40
  • Awesome, thanks, I'm sticking to scrlayer-scrpage from now on
    – PSC
    Commented Apr 12, 2016 at 8:44
2

NB: I am not yet allowed to comment, so I write this as an answer (even though it is not a solution to the problem). If that is a problem, I'll delete this.


You are right: the problem seems to be that the text is basically put into a list environment with an item without any label. You can show that this is a reason by writing something like \item[Here is an item]in the definition and a Here is an item will show up on the first page. (Code for this for quick copy&paste below).

I am not sure if there is a solution to fix this specific way of achieving the indentation of all the normal text. I haven't looked into the reasons for why it was done the way it was suggested in the answer you linked to.

Code to make the problem visible

\documentclass[english,liststotoc]{scrartcl}
\usepackage{helvet}
\renewcommand{\familydefault}{\sfdefault}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\setlength{\parskip}{\medskipamount}
\setlength{\parindent}{0pt}
\usepackage{float}

\usepackage{titlesec}

%% https://tex.stackexchange.com/questions/79521/indent-all-the-normal-text
\newcommand*{\LeftMargin}{0.5cm}%
\newcommand*{\RightMargin}{0.0cm}%

\def\ChangeMargin#1#2{\list{}{\rightmargin#2\leftmargin#1}\item[Here is an item]}%
\let\endChangeMargin\endlist%
\AtBeginDocument{\ChangeMargin{\LeftMargin}{\RightMargin}}
\AtEndDocument{\endChangeMargin}

\titlelabel{\hspace*{-\LeftMargin}\thetitle~}

\begin{document}

\begin{titlepage}

TEST

\end{titlepage}

CONTENT

\end{document}

Edit:

Maybe the answer to this question which followed from the one you linked to provides a good starting point for you as well.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .