Stack Exchange

Author Archive

Control widows and orphans easily

2011-09-16 by Raphaël Pinson. 7 comments

In a question some time ago, I was trying to implement a wrapper around the \widowpenalties command in order provide an easier interface to limiting orphans and widows in LaTeX.

Thanks to Martin Scharrer’s answer, this question gave birth to a new package called nowidow, which is now available in TeXLive 2011.

Simple usage

To limit widows and orphans in your whole document, you can simply load the package with the all option. You can specify the default amount of minimal lines to be kept in the end (orphans) or beginning (widows) of pages (the default value is 2):

\usepackage[all,defaultlines]{nowidow}

Fine tuning

If you wish to set a specific penalty for a given paragraph, the \nowidow (the subject of the original question) and \noclub macros will help you. They both take an optional argument to override the default value:

This is a paragraph at the end of a page
which will look ugly if I don't set
a widow penalty to force 3 lines to appear
on the next page.
\nowidow[3]

The full documentation can be found on the CTAN.

Suggestions and bug reports are welcome!

A Short Journey with LaTeX

2011-08-30 by Raphaël Pinson. 8 comments

Like many open-source aficionados, I’ve used LaTeX for quite some time. I have at least used it to typeset my CV (using europecv and later moderncv) and church songs and hymns (using songbook and gchords). While I liked what LaTeX produced, I was under the idea (like many) that TeX was an old lady of a software, a bit rusted and certainly not very active. My recent experience with LaTeX proved me very wrong.

When I decided, a few months back, to start publishing books with LaTeX, little did I suspect to find such a vibrant, dynamic, active community with a fully alive software stack!

Back to basics with PDFTex

About 6 months ago, I started writing a book about Augeas. Following the example of the Git Pro book, I began writing the book in markdown to keep it simple. However, I soon had the need to typeset computer code with syntax highlighting for Augeas code, a syntax not supported by any known highlighter, so it brought me to use minted and define my own syntax. I then started adding index entries to the book.

After that was done, the amount of LaTeX embedded in the markdown code was just too much, and I simply switched the whole project to plain LaTeX and rendered it using pdflatex. I had never typeset more than a few pages in LaTeX, so that was my first big project using it.

Tikz and the CTAN

After gaining some confidence with the Augeas book (which has yet to be finished), I decided I could edit and publish a theology book I had been translating, as well as a daily devotional my pastor had translated. I naturally began rendering them with pdflatex. I happily discovered that the bibleref package could help me typeset Bible references in LaTeX and even generate automated indexes of Bible references.

For the devotional, I had a need to typeset thumbs with the month names on the border of all odd pages. With the help of the TeX.SX users, I was advised to turn to tikz for this, and thus created my very first CTAN package, fancytabs.

XeTeX

As the theology books were getting edited and prepared for printing, I wanted to adapt the fonts used. For one book in particular, I wanted to use proprietary truetype fonts that were used on the cover of the book (which is composed using Inkscape). So I was advised to turn to XeTeX, for its great capabilities to use system fonts. I then discovered about OTF fonts, and how it could achieve many of the OT1 features (such as ligatures) and more using OTF.

Playing with OTF fonts in XeTeX got me to publish the fontbook and babyloniannum packages (as answers to TeX.SX questions), and start a demo project using the EB Garamond open-source font’s OpenType capabilities to reproduce a 16th century Bible.

TeXLive and software packages

Being an Ubuntu developer, I tend to use only software packages to install anything on my systems, and package the software that are missing in the official archive. However, after switching to XeTeX, I had more and more needs for up-to-date LaTeX packages and rendering engines, and Ubuntu only had TexLive 2009. TeXLive is hard to package and split, so most Linux distributions are lagging behind on it. Packaging TexLive 2011 for my own need seemed like too much work (for now), so I gave up and installed TeXLive 2011 the traditional way.

LuaTeX

One thing that soon frustrated me with XeTeX was its lack of support for microtype features. Sure, there was a beta version of microtype with XeTeX support. It added font protrusion, but I still had to fix lots of overfull lines manually for the lack of font expansion. This is what brought me to LuaTeX.

So finally (for now), after migrating to TexLive 2011, I began converting my documents to LuaTeX. I had a few issues with font tracking and microtype, but all in all, I’m really quite happy to have gotten there (and I’m not even making use of Lua just yet).

This short journey with LaTeX has gotten me to use 3 rendering engines (in order of appearance), commit 4 new packages to the CTAN and contribute to one existing package. It has also gotten me to discover a vibrant, active and welcoming community of users and developers, and a collection of software which is all but dying. I’m looking forward to where TeX will take me next!

Putting colors in initials

2011-08-27 by Raphaël Pinson. 11 comments

The lettrine package is very useful to typeset initials (or drop caps) in LaTeX. However, in order to get very nice initials, you might want to add some colors to them.

Georg Duffner, the creator of the EB Garamond open-source font, while adding initials to EB Garamond using a 16th century French Bible, had the idea of creating two fonts to typeset initials: one font for the background ornaments, and one font for the foreground letters. This way, you could color them in different colors and typeset much fancier initials.

The letter A in the Initials F1 font

The letter A in the Initials F1 font

The letter A in the Initials F2 font

The letter A in the Initials F2 font

I then worked on a LaTeX package to make use of this technique and ease the typesetting of colored initials in LaTeX. By loading the two different fonts with fontspec and superimposing them with \rlap, it is easy to superimpose the two characters:

\newcommand{\eblettrine}[3][]{%
\renewcommand{\LettrineFontHook}{\EBLettrineBackFont}%
\lettrine[#1]{%
\rlap{\color{\EBLettrineBackColor} #2}%
{\EBLettrineFrontFont\color{\EBLettrineFrontColor} #2}}{#3}%
}

The fine-tuning can be done by using the lettrine.cfg configuration file:

\setcounter{DefaultLines}{3}
\renewcommand{\DefaultLoversize}{0.1}
\renewcommand{\DefaultLraise}{0.25}
\renewcommand{\DefaultFindent}{0.15em}
\renewcommand{\DefaultNindent}{0pt}

The font is far from finished. As of today, only 3 initials are ready to be used (A, G and T) and adding new initials requires a lot of work. The LaTeX package can be found on github and will be on CTAN once the alphabet is complete.

An example of colored initials in LaTeX

An example of colored initials in LaTeX