Typography with TeX and LaTeX

## iTeX

Juli 3rd, 2010 by Stefan Kottwitz

I’ve read in a post by Jürgen to TeX-D-L tonight: at the TUG 2010 Donald E. Knuth announced the successor to TeX: iTeX. Read more on slashdot and science.slashdot.org. Don’t take it too seriously.

Update: the recording of the “earthshaking announcement” can now be seen on River Valley TV.

Category: TeX User Group, News, Events, plain TeX | No Comments »

## Using \expandafter for macro redefinitions

Oktober 26th, 2008 by Stefan Kottwitz

Sometimes I want to redefine a macro of a class or package but want to use its original definition. Instead of copy&paste one could use the original macro directly:

1. come up with a new macro, ensure that it’s not defined yet,
2. save the definition of the original macro to the new macro,
3. redefine the original macro using the new macro with the saved original code,

I will give a very simple example for a demonstration. Today a LaTeX Community member said that he’s using the quote environment but wants the enclosed text to have a smaller size. A straightforward solution is to use \renewenvironment copying the original code, let’s say from article.cls, and to make a small modification:

\renewenvironment{quote} {\list{}{\rightmargin\leftmargin}% \item\relax\small} {\endlist}

Just the \small was added. This solution needs the writer to examine the class source, that may also be changed later.

The second solution is the method I’ve described above:


The \newcommand line may be omitted, I’ve just used it to ensure that an error would be raised if a macro with that name was already defined by somehing else.
The last code works like the first solution, but respects the original class code and it will also respect further changes of the class, therefore I’m preferring it.

But the third solution is similar, shorter and doesn’t need the creation of another macro. It’s doing the same job but uses the original macro directly, avoiding a recursion problem by using \expandafter:

\expandafter\def\expandafter\quote\expandafter{\quote\small}

You can find the same method applied in my comment to a previous blog post.

If you want to know how expandafter works you will find explanations in TeX books and documentations. Further there’s an extensive tutorial by Stephan v. Bechtolsheim (TUGboat, Volume 9, 1988), old but still valid of course.

This topic was discussed in the LaTeX Community Forum and on Matheplanet.com.

Category: LaTeX General, plain TeX | 4 Comments »

## Around the Bend

Juli 26th, 2008 by Stefan Kottwitz

Recently Michael Downes collection of TeX challenges “Around the Bend“, originally in ASCII format, has been typeset in pdf format by Peter Wilson and has now been released on CTAN.
The document contains exercises posing a problem and one or several solutions.

Category: plain TeX | No Comments »

## TeX by Topic: back in print

Juli 12th, 2008 by Stefan Kottwitz

The very recommendable book TeX by Topic by Victor Eijkhout, originally published by Addison-Wesley 1991, is now available printed and bound from lulu.com. The author himself announced it today in the usenet group comp.text.tex.

The book has been published under GNU Free Documentation License 2007 and will remain downloadable from savannah.nongnu.org. It’s also available on the author’s homepage.

Even if it’s freely available I recommend to purchase this really great book to support the author. And of course to have a printed version. Its 319 pages are paperback bound to keep the price low at €11.30.

Category: plain TeX | No Comments »

## Beamer: frame number in split theme footline

Juli 12th, 2008 by Stefan Kottwitz

Yet again somebody in the mrunix forum asked for an advice how to put the frame number into the footline of his beamer presentation. He was using the “Warsaw” outer theme. The first solution

\setbeamertemplate{footline}[frame number]

will just overwrite the “Warsaw” footline.

Possible solutions are: to use a different outer theme or to change the “Warsaw” footline. “Warsaw” uses the split outher theme, a workaround for insertion of the frame number should consider that and will be usable for other themes like “Copenhagen”, “Luebeck” and “Malmoe”. Inspection of the file beamerouterthemesplit.sty reveals that the footline uses the \insertshorttitle macro in its right part. So a quick workaround could be to redefine that macro:


If you want to see more details you could look at example source code and its pdf output.

This topic was discussed on mrunix.de and in the Matheplanet forum.

Category: Presentations, plain TeX | 17 Comments »

## pdfTeX 1.40.8 released

Juli 11th, 2008 by Stefan Kottwitz

The new stable release of pdfTeX 1.40.8 has been released. pdfTeX is an extended TeX version with the ability to create pdf files directly from TeX source files supporting pdf specific features. Changes include:

• Implementation of SyncTeX,
• incorporated the new TeX version 3.1415926,
• use of the current public release libpng 1.2.29,
• bugfixes.

Category: plain TeX | No Comments »

## Hyphenation patterns in UTF-8 released

Juni 21st, 2008 by Stefan Kottwitz

The package hyph-utf8 has been released today. It contains hyphenation patterns that have been converted into UTF-8, addressing the need for appropriate patterns by native UTF-8 engines such as XeTeX.

Category: plain TeX | No Comments »

## Hack: change starred command into unstarred

Juni 17th, 2008 by Stefan Kottwitz

Some packages like nomencl, glossary and environments like thebibliography in standard LaTeX classes use the starred sectioning forms \chapter* and \section*. Even if they provide an option to let them added to the table of contents it may be required to use numbered sectioning. In that case you could look at the corresponding source code (article.cls, nomencl.sty, glossary.sty, …) and redefine thebibliography by \renewenvironment or redefine thenomenclature of the nomencl package etc.

Here I will show a way without redefining certain internal environments. I will use the TeX commands \def and \let to temporarily change the meaning of \section:

\let\stdsection\section \def\section*#1{\stdsection{#1}} \printnomenclature % \printglossary \let\section\stdsection

If you are interested in testing it by yourself you can find complete examples here.

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

Category: Sectioning, plain TeX | No Comments »

## Full justification with typewriter font

Mai 14th, 2008 by Stefan Kottwitz

In a typewriter font aka monospaced font each character is given the same width. Monospaced fonts are frequently used by programmers to increase the readability of source code, but long text passages with monospace typeface are considerably less readable than those with variable-width fonts.

The space between words is fixed too, that prevents justification, and hyphenation may be disabled too. That’s useful for presenting source code, but sometimes a typewriter font is wanted but justification is required. This post will give some information how to fulfill that. We will use the Computer Modern Typewriter font (cmtt) you get by default when using \ttdefault, \ttfamily, \texttt.

The following code prints some of the font properties:

\documentclass[a4paper,10pt]{article} \renewcommand*\familydefault{\ttdefault} \begin{document} \begin{description} \item[slant] \the\fontdimen1\font \item[interword space] \the\fontdimen2\font \item[interword stretch] \the\fontdimen3\font \item[interword shrink] \the\fontdimen4\font \item[extra space] \the\fontdimen7\font \item[xspaceskip] \the\xspaceskip \item[hyphenchar] \the\hyphenchar\font \end{description} \end{document}

The font cmtt10 is used, the result is:
slant 0.0pt interword space 5.24995pt interword stretch 0.0pt interword shrink 0.0pt extra space 5.24995pt xspaceskip 0.0pt hyphenchar -1

The space between words is 1em, the same is valid for the extra space following the end of a sentence. Zero stretch and shrink means the space between the words will always be 1em. The hyphenchar is set to -1, that’s why hyphenation is disabled. Let’s look how a normal text is set when typewriter is used:

\documentclass{article} \usepackage[english]{babel} \usepackage{blindtext} \renewcommand*\familydefault{\ttdefault} \begin{document} \section{Test} \begin{minipage}{0.7\textwidth} \blindtext \end{minipage} \end{document}

Output:

To get justification I just modify some of the font parameters above, that the spaces may be stretched and shrinked. I use the everysel package to ensure that my changes are applied every time the font is selected. Further I set the \hyphenchar to the - symbol.

\documentclass{article} \usepackage[english]{babel} \usepackage{blindtext} \usepackage{everysel} \renewcommand*\familydefault{\ttdefault} \EverySelectfont{% \fontdimen2\font=0.4em% interword space \fontdimen3\font=0.2em% interword stretch \fontdimen4\font=0.1em% interword shrink \fontdimen7\font=0.1em% extra space \hyphenchar\font=\-% to allow hyphenation } \begin{document} \section{Test} \begin{minipage}{0.7\textwidth} \blindtext \end{minipage} \end{document}

This is the justified result:

We get full justification and a good grayness of the paragraph. One line shows that hyphenation is active though it was rarely necessary.

This topic was discussed on CQF.info. In the LaTeX Community Forum we talked about similar issues with font dimensions.

Category: Layout, Fonts and Symbols, plain TeX | 6 Comments »

## Changing margins for just one paragraph

Mai 2nd, 2008 by Stefan Kottwitz

If you want to indent a paragraph just by a certain length but the standard LaTeX environments don’t meet the requirements you could use the TeX primitive \leftskip. To limit its effect it can be enclosed in \begingroup … \endgroup. The equivalent for the right margin is \rightskip. Here’s an example:

\documentclass[a4paper,10pt]{article} \usepackage[english]{babel} \usepackage{blindtext} \parindent0em \parskip\baselineskip \begin{document} \blindtext \par \begingroup \leftskip4em \rightskip\leftskip \blindtext \par \endgroup \blindtext \end{document}`

A downscaled screenshot of the output:

This topic was discussed on Matheplanet and ChemieOnline.

Category: Layout, plain TeX | 1 Comment »