TeXblog

 Typography with TeX and LaTeX

Archive for the 'Layout' Category

Geometry package updated

18 February 2010 by Stefan Kottwitz

Hideo Umeki has published the version 5.1 of the geometry package. 5.1 brings just a bugfix for the pass option, but the version 5, released a few days earlier on Feb 12th, provides some new and very useful features:

  • The page dimensions can be changed now even in the middle of a document. This very often requested feature has been provided by the gmeometric package before. Now you could write \newgeometry{…} similar to \geometry except that all geometry options used in the preamble would be disabled and the paper-size options like paper=a4paper, landscape, portrait etc. too. Those preamble settings can be restored by \restoregeometry.
  • The current page dimensions can be saved by \savegeometry and loaded by \loadgeometry.
  • There’s a new set of options to specify the layout area: layout, layoutsize, layoutwidth,
    layoutheight etc. They help to print the specified layout to paper of a different size. For example the geometry package would use A5 layout for calculation of margins but with the paper size A4 if you use a4paper together with layout=a5paper.
  • The new driver option xetex has been added and is strongly recommended with XeLaTeX. The driver auto-detection routine has been improved, the workaround with geometry.cfg in TeX Live is no longer necessary.
  • Papersize presets b0j to b6j for JIS (Japanese Industrial Standards) B-series have been added.
  • If the margin would not be completely specified version 5 behaves differently now in order to determine the unspecified margin, documented in the manual.
  • The option showframe will cause the page frames to be shown on every page.
  • The new option showcrop would print cropmarks showing the corners of the layout on every page.
  • Loading geometry.cfg precedes now the processing of the class options in contrary to the previous versions.
  • The options compat2 and twosideshift have been removed because version 5 is no longer compatible with previous versions.

For more information visit


This text is available in German. Dieser Text ist auch in Deutsch verfügbar.

Category: News, Layout | No Comments »

Full Justification: pdfLaTeX vs. LaTeX

13 April 2009 by Stefan Kottwitz

Once in a while there are discussions if pdfLaTeX would be preferable to LaTeX. There are some reasons, here I will just point out the effect of the micro-typographic extensions of pdfTeX, in particular font expansion and character protrusion. Using it you could get better margin adjustment and more even interword spacing. The package microtype is providing an interface to those extensions, you could see an effect already if you would just load the package without any options. The effect will be most notable if you need to typeset text with small columns like in tables.

Let’s test this very small example:

\documentclass[a4paper,10pt]{article}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{microtype}
\begin{document}
\begin{minipage}{3.7cm}
\blindtext
\end{minipage}
\end{document}

After compilation with LaTeX I’ve got 12 bad/underfull boxes. Using pdfLaTeX I’ve got 0 bad boxes. You could test it yourself. Btw. without microtype I’ve got 10 underfull boxes with both LaTeX and pdfLaTeX. Let’s bring the results of fLaTeX and pdfLaTeX face to face, just compare the first four lines or even more:

               [LaTeX] 12 badboxes               [PDFLaTeX] 0 badboxes

justification comparison

Without microtype the text will also look like the left one, the line breaks will be the same.

Microtype provides even more features that are not enabled by default, like additional kerning, spacing, tracking/letterspacing and allows you to fine-tune its capabilities. For more information have a look into its documentation.

To conclude I recommend to use pdfLaTeX if the situation allowed it, especially if you are using tables with cells or columns containing text. If you think you couldn’t use pdfLaTeX because it cannot embed eps images, consider to convert those images to pdf format.

This topic was discussed on apfeltalk.de, LaTeX Community, MatheBoard and Matheplanet.

Category: Layout | 1 Comment »

New package: zwpagelayout

28 December 2008 by Stefan Kottwitz

On December 26th Zdenêk Wagner has released the zwpagelayout package, dealing with page layout in general, like the well known geometry package.
It may not provide as many features as geometry but it brings additional tools, for instance it’s supporting cropmarks.

The package can be loaded by:

\usepackage[options]{zwpagelayout}

All options have to be set in the preamble, either by this line or given to the document class.
Options may be paper sizes (by name or by lengths), orientation (portrait, landscape), margins, text dimensions (also concerning head and foot), cropmark related options and options concerning the design of book covers like spine and flap.

There are even options to reflect pages horizontally or vertically, that are intended for printing but shouldn’t be used for documents providing hyperlinks.

Further the package is capable of calculating missing page layout dimensions if enough dimensions are already given.

zwpages comes well documented on 16 pages. For more information and download visit:

Category: News, Layout | 2 Comments »

Fancy chapter headings with TikZ

11 October 2008 by Stefan Kottwitz

A question on LaTeX-Community.org inspired me to try pgf/TikZ together with titlesec to produce fancy chapter headings. The result is this small compilable demonstration example:

\documentclass[svgnames]{report}
\usepackage{tikz}
\usepackage{kpfonts}
\usepackage[explicit]{titlesec}
\newcommand*\chapterlabel{}
\titleformat{\chapter}
  {\gdef\chapterlabel{}
   \normalfont\sffamily\Huge\bfseries\scshape}
  {\gdef\chapterlabel{\thechapter\ }}{0pt}
  {\begin{tikzpicture}[remember picture,overlay]
    \node[yshift=-3cm] at (current page.north west)
      {\begin{tikzpicture}[remember picture, overlay]
        \draw[fill=LightSkyBlue] (0,0) rectangle
          (\paperwidth,3cm);
        \node[anchor=east,xshift=.9\paperwidth,rectangle,
              rounded corners=20pt,inner sep=11pt,
              fill=MidnightBlue]
              {\color{white}\chapterlabel#1};
       \end{tikzpicture}
      };
   \end{tikzpicture}
  }
\titlespacing*{\chapter}{0pt}{50pt}{-60pt}
 
\begin{document}
\tableofcontents
\chapter{Introduction}
Text
\chapter{Main}
\section{Section}
Text
\begin{thebibliography}{99}
\bibitem{Test} test reference
\end{thebibliography}
\end{document}

Screenshot:

TikZ fancy chapter headings

See also pdf output of this test & demo file.

Category: pgf/TikZ, Sectioning, Layout | 49 Comments »

Centering wide tables or figures

17 September 2008 by Stefan Kottwitz

When you want to include an image or a table that’s wider than the text width, you will notice that even when \centering or the center-environment is used this wide object will not be centered in relation to the surrounding text. It will be placed at the left margin but go into the right margin. Its frequently requested that wide figures or tables should overlap at both sides in equal measure.

It can easily achieved by putting the table or picture inside a box, giving the box the width of the text, by the \makebox command. Here is a compilable example, where I’m centering a table having 1.5 times the width of the text:

\documentclass[a4paper,10pt]{article}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{tabularx}
\begin{document}
 
\blindtext
\bigskip
 
\noindent\makebox[\textwidth]{%
\begin{tabularx}{1.5\textwidth}{XX}
  \blindtext & \blindtext
\end{tabularx}}
 
\bigskip
\blindtext
 
\end{document}

I’ve used \noindent to suppress the paragraph indentation, otherwise I would get an overfull \hbox. As you may notice there’s no \centering necessary because the width of the box equals \textwidth.

This topic was discussed in the LaTeX Community Forum, on CQF.info and on mrunix.de.
.

Category: Figures and Tables, Layout | 16 Comments »

Paper sizes with pdfTeX

12 September 2008 by Stefan Kottwitz

I’m frequently noticing questions regarding problems with paper size and pdfLaTeX, for instance Bug 215561 and Bug 244043 on Launchpad, yesterday on mrunix.de and also yesterday on matheplanet.com.
If you manually change \paperwidth or \paperheight or use the landscape option of LaTeX classes like for instance article it could happen that the paper size of the resulting pdf differs.
A solution is to adjust the \pdfpagewidth and \pdfpageheight values:

\setlength{\pdfpagewidth}{\paperwidth}
\setlength{\pdfpageheight}{\paperheight}

To use the geometry package could correct it too. But if you use it together with gmeometric, it may still be necessary to adjust the pdf page size like written above, see for instance goLaTeX.de.

Category: TeX Live, Layout | No Comments »

blowup: new package for scaling pages

23 June 2008 by Stefan Kottwitz

Today CTAN Announcements informed that the package blowup has been released. It can be used to upscale or downscale all pages of a document. For a first test I created this short a5paper document:

\documentclass[pdftex,a5paper,10pt]{article}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{hyperref}
\begin{document}
\tableofcontents
 
\section{One}
\blindtext[3]
 
\section{Two}
\blindtext[4]
 
\end{document}

It’s pdf output can be opened here. The pdfinfo tool printed:
Page size: 419.528 x 595.276 pts

Now I used the \blowUp macro to upscale the document pages to fit a4 paper size:

\documentclass[a5paper,10pt]{article}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{hyperref}
\usepackage{blowup}
\blowUp{paper=a4}
\begin{document}
\tableofcontents
 
\section{One}
\blindtext[3]
 
\section{Two}
\blindtext[4]
 
\end{document}

The new pdf output can be opened here. pdfinfo output:
Page size: 595.276 x 841.89 pts (A4)

Of couse you could inspect the paper sizes by using the Adobe Reader.

The blowup package includes several source code examples. During the test I’ve noticed one small mistake in the documentation, the user-level macro \blowUp is described as \blowup, that will cause an error. But I’m sure this will be corrected soon, at least I will report it to the package author.

Category: Tools for LaTeX, Layout | 1 Comment »

Modifying plain page style

21 June 2008 by Stefan Kottwitz

In documents using the book or report class the first page of a chapter will have the page style plain, the page number will appear at the bottom of the page. If you want to remove the number you could write \thispagestyle{empty} on each of those pages, or you could force the plain page style to be empty:

\makeatletter
\let\ps@plain\ps@empty
\makeatother

If you use the headings or fancy pagestyle and you want that pagestyle for opening pages of chapters too, you can write similar for instance

\let\ps@plain\ps@fancy

and all plain pages will look like the fancy style.

This topic was discussed in the LaTeX Community Forum on mrunix.de and on CQF.info.

Category: Layout | No Comments »

Starting chapters on even-numbered pages

13 June 2008 by Stefan Kottwitz

In documents using the book class chapters start by default on a right-hand, odd-numbered page (recto page), corresponding to option openright. This may be changed by specifying the option openany to use the next available page, which is set default in the case of the report class.
But the LaTeX standard classes don’t provide an openleft option. The memoir class accepts openleft and enables chapters to start on left-hand pages (verso pages).

The book and report class use \cleardoublepage (defined in latex.ltx) to ensure that chapters start on odd-numbered pages. The opposite could be specified by redefining the \cleardoublepage command:

\makeatletter
\renewcommand*\cleardoublepage{\clearpage\if@twoside
  \ifodd\c@page \hbox{}\newpage\if@twocolumn\hbox{}%
  \newpage\fi\fi\fi}
\makeatother

This topic was discussed on mrunix.de.

Category: Layout | 3 Comments »

center vs. \centering

13 June 2008 by Stefan Kottwitz

A frequently seen mistake is to use \begin{center} … \end{center} inside a figure or table environment. This center environment can cause additional vertical space. If you want to avoid that just use \centering instead like in this example:

\begin{figure}[ht]
\centering
\includegraphics{filename}%
\caption{text}%
\end{figure}

The additional space of the center environment is caused by a trivlist environment. Its defined by latex.ltx:

\def\center{\trivlist \centering\item\relax}
\def\endcenter{\endtrivlist}

As you can see \center calls \centering too. By directly using \centering you could omit that trivlist.

Inside normal text \begin{center} … \end{center} is useful of course to center and to generate vertical space between the centered text and the surrounding text.

Concerning \centering it’s advisable to limit its scope by grouping. Inside a figure or table environment it’s already limited, but inside normal text you should use curly braces or \begingroup\centering … \endgroup:

{\centering Text
 
}

As you can see I set an empty line before closing the centered group. If I do not end the paragraph by a paragraph break or the line by \\ then the following text outside the group will be centered too. \centering is also defined by latex.ltx:

\def\centering{%
  \let\\\@centercr
  \rightskip\@flushglue\leftskip\@flushglue
  \parindent\z@\parfillskip\z@skip}

It’s using \leftskip and \rightskip to flush left and right.

This topic was discussed in the LaTeX Community Forum, on mrunix.de and on ubuntuusers.de .

Category: Layout | 2 Comments »