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}
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.-1in
fromtop
,inner
, andouter
is a great improvement, it doesn't go all the way :-/ And\setlength{\marginparpush}{1em}
is apparently not really related.top=8mm+0.709in-0pt
is about right. But it would be nice to know the root cause of that magic number