3

My question concern the line numbers when using the dinbrief package. I want to have page numbers like page 1 of 2 and so on. I tried also the LastPage package, but without success. The dinbrief package is quite old and seems not be maintained... but I love it.

Question: How to get managed the page numbering?

If you have any hints or optimizations, they will be appreciated.

% vim: ts=4 syntax=tex tenc=utf8 fenc=utf8
\NeedsTeXFormat{LaTeX2e}
\documentclass[10pt]{dinbrief}

\usepackage[a4paper, left=2.5cm, width=12.5cm, height=26cm, marginparwidth=5cm, marginparsep=.1ex]{geometry}

\usepackage{fontspec, xunicode, xltxtra}
\usepackage{polyglossia}
\usepackage{lipsum}
\usepackage{fancyhdr}
\usepackage{color}
\usepackage{setspace}

\usepackage[final,protrusion=true]{microtype}

\fancypagestyle{default}{%
   \renewcommand{\headrulewidth}{0pt}%
   \fancyhf{}%
   \fancyfoot[C]{\footnotesize Seite \thepage\ von \pageref{lastpage}}%
}

\setmainfont[Numbers={OldStyle},Ligatures={Common}]{OfficinaSansITCStd}

\setmainlanguage{german}

\definecolor{markcolor}{cmyk}{0.8,.55,0,0.6}
\definecolor{black}{rgb}{.0,.0,.0}
\newcommand{\markkey}[1]{\color{markcolor}{\bfseries\ #1}\color{black}\hspace{1ex}}

\newcommand{\normalspacing}{\setstretch{1.5}}%
\newcommand{\bkbrk}{|\hspace{1ex}}

\backaddress{Vorname Nachname\hspace{2ex}\bkbrk\\Straße 1\hspace{2ex}\bkbrk\\11000 City}

\newcommand\marginalien{
    \vspace{7em}
    \scriptsize
    \raggedleft
    %\normalspacing
    %\raggedright
    Vorname Nachname\\
    Straße 1\\
    11000 City\\[1em]
    \markkey{E-Mail}name@domain.com\\
}

\nobackaddressrule
\signature{Vorname Nachname}
%\place{City}
%\date{2007-10-11}
%\yourmail{}
%\sign{unsere zeichen, unsere Nachricht von}
%\phone{tel}
% \writer{Sachbearbeiter}
\centeraddress
\bottomtext{bottom text}
\nowindowrules
%\windowrules
% Faltmarkierungen
%\nowindowtics
\windowtics
% entsprechend DIN 676 von 1976
%\disabledraftstandard
% entsprechen DIN 676 vom 1991
\enabledraftstandard
%\setaddressllcorner{abstand vom linken rand}
%\setaddressllhpos{abstand vom linken rand}
%\setaddressvpos{abstand vom oberen rand}
%\addresshigh
\addressstd

\subject{\bfseries{Ein Subjekt}}

\begin{document}
\normalspacing
\begin{letter}{Company\\Street 1\\11000 City}
\pagestyle{default}
\marginpar{\marginalien}

\opening{Sehr geehrter Herr Mustermann,}

\lipsum[1]

\closing{Mit freundlichen Grüßen}

\end{letter}
\label{lastpage}
\end{document}

enter image description here

  • Which exactly should be the position for the page numbers? Please describe the position in case it is the first page and for successive pages. Should it be the same for all the pages? Should the first page be treated differently? – Gonzalo Medina Jan 23 '14 at 22:40
  • Look at the tex file: \fancyfoot[C]{\footnotesize Seite \thepage\ von \pageref{lastpage}}%, yes the same for all pages – user42138 Jan 23 '14 at 22:50
2

The quickest solution is to \let some predefined page styles used for the class to be the defined default page style. Add the following lines

\makeatletter
\let\ps@plain\ps@default
\let\ps@first@page\ps@default
\makeatother

just after the definition of the default page style and then use

\pagestyle{plain}

instead of

\pagestyle{default}

for your document.

Also, \label{lastpage} has to be placed before \end{letter}. A complete example:

% vim: ts=4 syntax=tex tenc=utf8 fenc=utf8
\NeedsTeXFormat{LaTeX2e}
\documentclass[10pt]{dinbrief}

\usepackage[a4paper, left=2.5cm, width=12.5cm, height=26cm, marginparwidth=5cm, marginparsep=.1ex]{geometry}

\usepackage{fontspec, xunicode, xltxtra}
\usepackage{polyglossia}
\usepackage{lipsum}
\usepackage{fancyhdr}
\usepackage{color}
\usepackage{setspace}

\usepackage[final,protrusion=true]{microtype}

\fancypagestyle{default}{%
   \renewcommand{\headrulewidth}{0pt}%
   \fancyhf{}%
   \fancyfoot[C]{\footnotesize Seite \thepage~von~\pageref{lastpage}}%
}
\makeatletter
\let\ps@plain\ps@default
\let\ps@first@page\ps@default
\makeatother
%\setmainfont[Numbers={OldStyle},Ligatures={Common}]{OfficinaSansITCStd}

\setmainlanguage{german}

\definecolor{markcolor}{cmyk}{0.8,.55,0,0.6}
\definecolor{black}{rgb}{.0,.0,.0}
\newcommand{\markkey}[1]{\color{markcolor}{\bfseries\ #1}\color{black}\hspace{1ex}}

\newcommand{\normalspacing}{\setstretch{1.5}}%
\newcommand{\bkbrk}{|\hspace{1ex}}

\backaddress{Vorname Nachname\hspace{2ex}\bkbrk\\Straße 1\hspace{2ex}\bkbrk\\11000 City}

\newcommand\marginalien{
    \vspace{7em}
    \scriptsize
    \raggedleft
    %\normalspacing
    %\raggedright
    Vorname Nachname\\
    Straße 1\\
    11000 City\\[1em]
    \markkey{E-Mail}name@domain.com\\
}

\nobackaddressrule
\signature{Vorname Nachname}
%\place{City}
%\date{2007-10-11}
%\yourmail{}
%\sign{unsere zeichen, unsere Nachricht von}
%\phone{tel}
% \writer{Sachbearbeiter}
\centeraddress
\bottomtext{bottom text}
\nowindowrules
%\windowrules
% Faltmarkierungen
%\nowindowtics
\windowtics
% entsprechend DIN 676 von 1976
%\disabledraftstandard
% entsprechen DIN 676 vom 1991
\enabledraftstandard
%\setaddressllcorner{abstand vom linken rand}
%\setaddressllhpos{abstand vom linken rand}
%\setaddressvpos{abstand vom oberen rand}
%\addresshigh
\addressstd

\subject{\bfseries{Ein Subjekt}}

\begin{document}
\normalspacing
\begin{letter}{Company\\Street 1\\11000 City}
\pagestyle{plain}
\marginpar{\marginalien}

\opening{Sehr geehrter Herr Mustermann,}

\lipsum

\closing{Mit freundlichen Grüßen}

\label{lastpage}
\end{letter}
\end{document}

An image of the bottom of the first page:

enter image description here

An image of the bottom of the second page:

enter image description here

  • Gonzalo: Thanks a lot! Could you please explain the expression between makeatletter/makeatother? I'd also appreciate if you could post some links on how it works. – user42138 Jan 24 '14 at 18:40
  • ps@<name> is the internal name of a page style called <name>; a line like \let\ps@plain\ps@default simply assigns to the page style plain the definitions used by the page style default. Analogously, \let\ps@first@page\ps@default assigns to the page style first@page (the style used by the class for the first page) the definitions used by the page style default. \makeatletter, simply allow you to treat the character @ (original defined as "other" (catcode 12)) as a "letter" (catcode 11); \makeatotherrevert those settings, so @ will have again catcode 12. – Gonzalo Medina Jan 24 '14 at 19:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy