3

I have an old package that sets up a Swedish paper format (S5) with a page layout with margins and such. From what I understand it only sets the mediabox correctly only with pdflatex.

To me this looks like an excellent time to use the geometry package. But my attempt to translate the code to package options doesn't work. Also, I can't see \marginparpush in the documentation to geometry.

Can you help?

s5paper.sty

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{s5paper}[2006/08/28 author: Pedher Johansson]
\RequirePackage{calc}
\RequirePackage{keyval}

% Paper size
\newdimen\extra@margin
\extra@margin0pt
\define@key{s5paper}{margin}{\setlength{\extra@margin}{#1}}

\def\ProcessOptionsWithKV#1{%
  \let\@tempc\relax
  \let\@tempa\@empty
  \@for\CurrentOption:=\@classoptionslist\do{%
    \@ifundefined{KV@#1@\CurrentOption}%
    {}%
    {%
      \edef\@tempa{\@tempa,\CurrentOption,}%
      \@expandtwoargs\@removeelement\CurrentOption
        \@unusedoptionlist\@unusedoptionlist
    }%
  }%
  \edef\@tempa{%
    \noexpand\setkeys{#1}{%
      \@tempa\@ptionlist{\@currname.\@currext}%
    }%
  }%
  \@tempa
  \let\CurrentOption\@empty
  \AtEndOfPackage{\let\@unprocessedoptions\relax}}
\ProcessOptionsWithKV{s5paper}


\setlength\paperheight {242mm}          %Modified by Ettore from 238
\setlength\paperwidth  {165mm}%
\advance\paperheight2\extra@margin
\advance\paperwidth2\extra@margin
\hoffset 0in
\voffset 0in
\topmargin 8mm
\advance\topmargin -1in
\advance\topmargin\extra@margin
\oddsidemargin 24mm
\advance\oddsidemargin -1in
\advance\oddsidemargin\extra@margin
\evensidemargin 21mm
\advance\evensidemargin-1in
\advance\evensidemargin\extra@margin
\headheight 10mm
\headsep 8mm
\footskip 9mm
\marginparwidth 17mm
\marginparsep 2mm
\marginparpush 1em

\setlength{\textheight}{190mm}
\setlength{\textwidth}{\paperwidth-2in-\hoffset-\oddsidemargin-\evensidemargin}%

\ifx\pdftexversion\undefined\else
  \setlength{\pdfpagewidth}{\paperwidth}
  \setlength{\pdfpageheight}{\paperheight}
\fi

My attempt

\documentclass{book}
% \usepackage{s5paper}
\usepackage{calc}
\usepackage[
  paperheight=242mm+0pt*2,
  paperwidth=165mm+0pt*2,
  layouthoffset=0mm,
  layoutvoffset=0mm,
  top=8mm-1in-0pt,
  inner=24mm-1in-0pt,
  outer=21mm-1in-0pt,
  headheight=10mm,
  headsep=8mm,
  footskip=9mm,
  marginparwidth=17mm,
  marginparsep=2mm,
  height=190mm,
  width=120mm,
]{geometry}
\usepackage{blindtext}
\begin{document}
  \chapter{Test}
  \blindtext[2]
\end{document}

Result with s5paper

Result with my flawed geometry settings

3
  • 1
    geometry does the -1in for the offset of TeX's paper origin automatically. So you have to omit it. \marginparpush can be and needs to be set manually, because it is not really a page layout parameter but parameter of consecutive margin notes.
    – cabohah
    Commented Nov 15, 2022 at 17:19
  • @cabohah While removing the -1in from top, inner, and outer is a great improvement, it doesn't go all the way :-/ And \setlength{\marginparpush}{1em} is apparently not really related.
    – Fredrik P
    Commented Nov 15, 2022 at 17:28
  • @cabohah Eyeballing gives that top=8mm+0.709in-0pt is about right. But it would be nice to know the root cause of that magic number
    – Fredrik P
    Commented Nov 15, 2022 at 19:31

1 Answer 1

1

As @cabohah pointed out

  • "geometry does the -1in for the offset of TeX's paper origin automatically"
  • \marginparpush is not part of the page layout and so needs to be set separately

Finally, the magic number 0.709in was simply \headheight+\headsep as this is included in geometry's definition of the header (as per Figure 1 in the documentation).

\documentclass{book}
\usepackage{calc}
\newdimen\extramargin% Take care of the `s5paper` package's option `margin`
\extramargin0pt
\usepackage[
  paperheight=242mm+2\extramargin,
  paperwidth=165mm+2\extramargin,
  layouthoffset=0mm,
  layoutvoffset=0mm,
  top=8mm+10mm+8mm+\extramargin,% Add \headheight and \headsep
  inner=24mm+\extramargin,
  outer=21mm+\extramargin,
  headheight=10mm,
  headsep=8mm,
  footskip=9mm,
  marginparwidth=17mm,
  marginparsep=2mm,
  height=190mm,
  width=120mm,
]{geometry}
\setlength{\marginparpush}{1em}
\usepackage{blindtext}
\begin{document}
  \chapter{Test}
  \blindtext[2]
\end{document}

You must log in to answer this question.

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