4

I am preparing a template, in which I need: (1) a custom title page (generated separately) (2) a custom abstract page with very big footer and no page number (3) the rest of the document with fancy footer (in particular, including page number) and header.

To achieve (2), I used \newgeometry and \restoregeometry. However, the page number is placed in correct position only from page 4 onwards, but page 3 has 'wrong' bottom margin size. Any attempts to fix it only wrosen the situation (e.g. align ALL page numbers with the 'incorrect' one). Here is my MWE (at least I hope it's minimal):

\documentclass[11pt,a4paper,twoside=semi]{scrartcl}

\usepackage{graphicx}
\usepackage[top=4.79cm, bottom=2.5cm, left=1.5cm, right=1.5cm]{geometry}
\usepackage{eso-pic}
\usepackage{afterpage}
\usepackage[automark]{scrlayer-scrpage}
\usepackage{lipsum}

\begin{document}
\title{Some stuff on title page}
\maketitle

\clearpage
\afterpage{
\newgeometry{bottom=8cm}
    \pagenumbering{gobble}
\newcommand{\FooterDisclaimer}{%
    {\parbox[c][5cm]{\textwidth}
        {very long message in footer    
        }
    }
        }   
    \chead{}
    \cfoot{\FooterDisclaimer}
Some stuff on the second page with different footer
\restoregeometry
}

\clearpage
\thispagestyle{scrheadings}
\pagenumbering{arabic}
\setcounter{page}{3}
\clearpairofpagestyles

\cfoot{\pagemark}

\section{Test}  
\lipsum[1-20]   
\end{document}
Sebastiano
  • 54,118
Joanna F
  • 143
  • Everything in this comment is untested! No need to use \afterpage, instead use \clearpage\newgeometry{bottom=8cm}<contents of your abstract>\clearpage\restoregeometry – Skillmon May 14 '18 at 07:22
  • If I don't use \afterpage, in fact ALL page numbers are placed wrong :) With \afterpage at least I limit the problem to one page, namely page 3. – Joanna F May 14 '18 at 07:24
  • Unrelated: Are the margins required to be that small? Your lines get very long and are hard to read because of that. – Skillmon May 14 '18 at 08:25
  • Unfortunately yes. I'll double-check the requirements, but apparently they should be small. – Joanna F May 14 '18 at 08:31
  • 1
    If you put the \restoregeometry after the closing bracket, i.e. three rows down, page 3 seems to look ok. – Fredrik Johansson May 14 '18 at 08:32
  • I don't know if you haven't noticed or it is wanted: On your title page there is a page number in the bottom right corner. – Skillmon May 14 '18 at 08:53
  • Only in the MWE, so I don't mind ;) – Joanna F May 14 '18 at 08:54
  • @FredrikJohansson comment is important - one cannot do this, for example, at the end of an environment. \restoregeometry has to be called in\AfterEndEnvironment for example. – mforbes Mar 20 '22 at 08:31

2 Answers2

5

The problem is, that KOMA script adjust the \footheight for your very large footer on page 2. \restoregeometry doesn't set that length back, but only changes the other lengths. The result is a very large footer on the following pages.

To remedy that, put a \recalctypearea before \restoregeometry, which sets the \footheight back to normal (basically this sets everything to the sizes KOMA would use without geometry). The \restoregeometry resets geometry's sizes.

In code:

\documentclass[11pt,paper=a4,twoside=semi]{scrartcl}

\usepackage[automark]{scrlayer-scrpage}
\usepackage[top=4.79cm, bottom=2.5cm, left=1.5cm, right=1.5cm]{geometry}
\usepackage{lipsum}

\begin{document}
\title{Some stuff on title page}
\maketitle

%% Your second page
\clearpage
  \newgeometry{bottom=8cm}%
  \pagenumbering{gobble}
  \newcommand{\FooterDisclaimer}
    {%
      \parbox[c][5cm]{\textwidth}
        {\lipsum[1]}%
    }   
    \chead{}
    \cfoot{\FooterDisclaimer}
Some stuff on the second page with different footer

\lipsum[2-5]
\clearpage
%%

\recalctypearea % reset footer height
\restoregeometry % reset page margins
\pagenumbering{arabic}
\setcounter{page}{3}
\clearpairofpagestyles
\cfoot{\pagemark}

\section{Test}  
\lipsum[1-20]   
\end{document}
Skillmon
  • 60,462
2

Here is another suggestion which avoids the recalculation of footheight (and the warning regarding this recalculation):

\documentclass[twoside=semi]{scrartcl}
\usepackage[top=4.79cm, bottom=2.5cm, left=1.5cm, right=1.5cm,
  showframe% to show the page layout
]{geometry}
\usepackage[automark]{scrlayer-scrpage}
\clearpairofpagestyles
\cfoot{\pagemark}

\newcommand{\FooterDisclaimer}{%
  \parbox[c][5cm]{\textwidth}{%
    Nam dui ligula, fringilla a, euismod sodales, sollicitudin vel, wisi.
    Morbi auctor lorem non justo.
    Nam lacus libero, pretium at, lobortis vitae, ultricies et, tellus.
  }%
}

\newcommand\StartDisclaimerPages
  {%
    \newgeometry{bottom=8cm}\begingroup
    \cfoot{\raisebox{\dimexpr-\height+\ht\strutbox\relax}
      [\ht\strutbox][\dp\strutbox]{\FooterDisclaimer}}%
  }
\newcommand\EndDisclaimerPages
  {\clearpage\endgroup\restoregeometry}

\usepackage{lipsum}% only for dummy text
\begin{document}
\title{Some stuff on title page}
\author{Author}
\maketitle

\StartDisclaimerPages
\lipsum[1-4]
\EndDisclaimerPages

\section{test}
\lipsum[5-20]
\end{document}

Note that I have removed \pagestyle{gobble} and the manuel setting of page number 3.

enter image description here


You could also use a new layer pagestyle for the disclaimer page:

\documentclass[twoside=semi]{scrartcl}

\usepackage[top=4.79cm, bottom=2.5cm, left=1.5cm, right=1.5cm,
  showframe% to show the page layout
]{geometry}
\usepackage[automark]{scrlayer-scrpage}
\clearpairofpagestyles
\cfoot{\pagemark}

\newcommand{\FooterDisclaimer}{%
  \parbox[c][5cm]{\textwidth}{%
    Nam dui ligula, fringilla a, euismod sodales, sollicitudin vel, wisi.
    Morbi auctor lorem non justo.
    Nam lacus libero, pretium at, lobortis vitae, ultricies et, tellus.
  }%
}
\DeclareNewLayer[
  foreground,
  foot,
  contents={%
    \usekomafont{pageheadfoot}\usekomafont{pagefoot}%
    \FooterDisclaimer
  }
]{disclaimer.foot}
\DeclareNewPageStyleByLayers{disclaimer}{disclaimer.foot}

\newcommand\StartDisclaimerPages
  {\newgeometry{bottom=8cm}\begingroup\pagestyle{disclaimer}}
\newcommand\EndDisclaimerPages
  {\clearpage\endgroup\restoregeometry}

\usepackage{lipsum,blindtext}% only for dummy text
\begin{document}
\title{Some stuff on title page}
\author{Author}
\maketitle

\StartDisclaimerPages
\lipsum[1-4]
\EndDisclaimerPages

\section{test}
\lipsum[5-20]
\end{document}
esdd
  • 85,675