5

The TikZ manual has this little gem of wisdom in its description of the \foreach command (emphasis mine):

In the easiest case, ‹variables› is a single TeX command like \x or \point. (If you want to have some fun, you can also use active characters. If you do not know what active characters are, you are blessed.)

The LaTeX wikibook has a few paragraphs about them, and they appear to be a perculiar quirk of Plain TeX, but outside of the example given, I can't think of any sane reason to use them. While I'd consider myself somewhat proficient with LaTeX, I'm a novice when it comes to Plain TeX and understanding how the whole thing actually works.

What is the purpose of active characters, and why would you use them? I'm curious as to why the TikZ manual authors may have written that statement.

2

1 Answer 1

8

The classic example is ~ which in plain tex and latex is a macro (also known as \nobreakspace in LaTeX) that makes a non breakable space.

In LaTeX every character (byte) above 127 is active to implement the inputenc handling of input encodings.

Basically an active character is set up to expand to a macro replacement in exactly the same way as a command name, and may be defined via \def in the same way.

They are particularly useful for setting Christmas carols with few \ commands visible.

The other main use of active characters in laTeX are babel "shorthands" eg typically " is made active expanding to an accent command so "o is a short form of \"{o}

2
  • So how do multilingual documents using utf-8 (or another multibyte) encoding get around this? If "ლ" is an active character, what happens when someone wants to type a document in Georgian?
    – Robbie
    Feb 25, 2020 at 11:58
  • 5
    @Robbie well that's rather the point, to pdflatex ლ is not a character, it is the three characters (bytes) E1 83 9A character E1 is active defined as a macro expecting a three byte UTF-8 sequence so it grabs the following two tokens 83 and 9A as arguments, does the UTF-8 arithmetic and looks up whether there is a definition for that character or gives the U+10DA not set up error message if nothing has been declared. Feb 25, 2020 at 12:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .