# Some TeX Developments

Coding in the TeX world

## LaTeX training: in demand

As part of my activity for UK-TUG, I and a couple of other members ran a training event last week in London: LaTeX for beginners. This is the third time we’ve run a similar course, and I think that this was the best presentation we’ve given to date. The slides and handouts seem to work pretty well, and the timing and so forth is now becoming a lot clearer!

Coming away from the event, what is most notable is the demand for LaTeX training. We’ve run the same course three times in just over a year, and I’ve currently got a waiting list which will easily fill the next presentation. At the same time, we get asked a lot about an intermediate-level course, and so we’ve made a start on assembling some slides for that, too.

On the course itself, we had a number of people from publishing backgrounds, and again there are more on the waiting list. So it’s clear that LaTeX continues to be a significant player, at least in the UK, in the publishing world.

Depending on availability of help, I’m hoping that we can run one course early in the new year, and another at around Easter. So this will be keeping me busy for a while!

Written by Joseph Wright

August 31st, 2011 at 8:26 pm

Posted in LaTeX

Tagged with

## LuaTeX category code tables

There are lots of very clever ideas in LuaTeX, and it’s easy to miss some of the good stuff there is. One that many people might miss is category code tables. As any TeX programmer rapidly becomes aware, category codes are central to TeX, and the construction

`\catcode`\<char> = <number>\relax`

is one you soon get used to. The problem comes when several people start altering the codes: there is no easy way to get back to a known position.

A good illustration of this is verbatim material. The way that something like LaTeX’s \verb macro works is by setting the category code for all of the ‘special’ characters to ‘other’:

```\let\do\@makeother
\dospecials```

where both `\@makeother` and `\dospecials` are provided by the LaTeX kernel. That works because `\dospecials` is defined as

`\do \ \do \\\do \{\do \}\do \\$\do \&\do \#\do \^\do \_\do \%\do \~`

and so maps the function `\@makeother` to all of the ‘special’ characters. Using that, a (simplified) verbatim command looks like

```\makeatletter
\newcommand*\stdverb{%
\begingroup
\let\do\@makeother
\dospecials
\@stdverb
}
\newcommand*\@stdverb[1]{%
\catcode`#1=\active
\lccode`\~=`#1%
\lowercase{\let~}\endgroup
\ttfamily
}
\makeatother```

In most cases, this works fine. However, if someone makes another character ‘special’ then things go wrong:

```\catcode`\+=\active
\newcommand+{oops}
\stdverb=#{+=```

Of course, you could loop over every character, which would be slow for 8-bit input but with UTF-8 input that becomes impractical. Of course, you could add each active character to `\dospecials`, but this is dependent on everyone sticking to good practice.

This is where category code table come in. These are pre-set lists of category codes, which can be applied in one go. Heiko Oberdiek’s `luatex` package provides a LaTeX interface for these, meaning we can do:

```\usepackage{luatex}
\makeatletter
\newcommand*\luaverb{%
\begingroup
\BeginCatcodeRegime\CatcodeTableOther
\@stdverb
}
\makeatother```

(reusing the same internal macro as before). now trying

```\catcode`\+=\active
\newcommand+{oops}
\luaverb=#{+=```

works as expected, as all of the category codes change in one go. Simple, clear and effective!

Written by Joseph Wright

August 16th, 2011 at 9:07 am

Posted in General

Tagged with ,