## Create letter-size PDF output with Dblatex (0.3.2)

Dblatex (http://dblatex.sourceforge.net/) is a great utility which takes as input a DocBook 4.5 XML file then produces as output a high-quality Adobe PDF file using the TeX/LaTeX typesetting engine.

A problem arises for users who prefer letter-size paper — Dblatex’s default output paper size is 21cm x 29.7cm. In Appendix A of Dblatex’s manual, it cites a parameter, latex.class.options, which (to those familiar with LaTeX) might suggest an easy change. Namely, by adding the following command to a Dblatex customization style sheet:

<xsl:param name="latex.class.options">letterpaper</xsl:param>

However, the above does not produce the desired result.

The solution is found by directly editing docbook.sty located in the latex/style directory of your Dblatex distribution.

 Note Dblatex provides a “proper” way to customize its LaTeX output (see the chapter on “Customization”). This likely involves copying docbook.sty to your own file; however, I’ve been too busy to implement the proper way, so I directly edit docbook.sty.

Locate the section of code in docbook.sty which contains the following:

% ################################
% ### Page Parameters
% ################################
\setlength{\paperwidth}{21cm}
\setlength{\paperheight}{29.7cm}
\setlength{\hoffset}{-1in}
\setlength{\voffset}{-1in}
\setlength{\oddsidemargin}{2cm}
\setlength{\marginparsep}{0cm}
\setlength{\marginparwidth}{0cm}
\setlength{\textwidth}{18cm}
\setlength{\topmargin}{0.5cm}
\setlength{\textheight}{24cm}
\setlength{\footskip}{1.5cm}

Comment out the above lines by prepending a percent character (%). Next, add the following just below the commented-out lines:

\usepackage[letterpaper,text={6.5in,8in},centering,includehead,includefoot,headsep=1.5cm]{geometry}

The geometry LaTeX package
(ftp://ftp.tex.ac.uk/tex-archive/macros/latex/contrib/geometry/geometry.pdf)
makes it very easy to adjust page-size-related parameters. I personally use the TeX Live distribution (http://www.tug.org/texlive/) which offers the geometry package.

Now, Dblatex produces 8.5 x 11 (lettersize) PDF output.

Because Dblatex hard-codes widths of header elements inside dbk_headfoot.sty, you’ll need to edit that file and change:

Personally, I’ve modified them to be defined as follows:

% Fancy header/footer for the first page

\lfoot[]{\@ifundefined{DBKpublisher}{}{\DBKpublisher}}
\rfoot[]{}
\cfoot[]{\textsf{\thepage{} / \getpagerefnumber{LastPage}}}

% Fancy header/footer for the front matter

}

% Fancy header/footer for the doc body

}

\rhead[]{}

Now, Dblatex produces 8.5 x 11 (lettersize) PDF output with headers/footers that are properly sized.