{catcodes} is about "category codes" — an integer number from 0–15 associated to each of the 256 character codes. The category codes indicate the role of a character.

learn more… | top users | synonyms

8
votes
1answer
68 views

SplitArgument on colon doesn't work under expl3 syntax

\documentclass{article} \usepackage{xparse} \DeclareDocumentCommand\TestA{>{\SplitArgument{1}{:}}m}{% \Example #1 } \ExplSyntaxOn \DeclareDocumentCommand\TestB{>{\SplitArgument{1}{:}}m}{ ...
32
votes
2answers
1k views

How can I make a TeX file executable?

Under UNIX, to my knowledge, any regular file can be made executable with the addition of a shebang: #! /path/to/executing-program --with --options How can I apply the same principle to a TeX file ...
8
votes
2answers
142 views

Active space character without definition?

In the code below, why does the space character not produce an 'Undefined control sequence' error as the dot character does: \catcode` =\active \catcode`.=\active a b a.b \bye
0
votes
0answers
16 views

Macro that feeds its argument to an environment that changes the catcodes

Suppose an environment that reads its contents with changed catcodes (verbatim, CJK, etc). I want to write a macro that invokes this environment on its single apparent argument. The argument is ...
4
votes
1answer
93 views

Patch \insertshorttitle in beamer

In this answer @cfr showed me how to preserve short title color in beamer while allowing hyperlinks to work. His solution was to modify the \insertshorttitle command (defined in beamerbasetitle.sty) ...
3
votes
1answer
65 views

Active Delimiters to get correct delimiter size

I once read in "Die Texnische Komödie 1/2011" that it is possible to make the round delimiters () active, so you don´t need do use \left(\right) any more. The code is: \makeatletter ...
22
votes
5answers
735 views

Typesetting hashtags with natural syntax

I'm using an online conversation in my document and I've made an environment to use for it. The thing is, there are many #hashtags in each post (that I'd like to color appropriately). To make it ...
7
votes
2answers
113 views

Define a macro changing category code of number sign (namely \makenumbersignletter)

Under Typesetting hashtags with natural syntax Joseph Wrigh ask me to ask a new question: In LaTeX, \makeatletter is short for changing the category code of @. But something like ...
8
votes
1answer
92 views

Unwanted space in path for `\addbibresource`

I wanted to store a part of a path to a bib-file in a command. But if I run this example (neither the bib-file nor the bib-entry is needed to see the problem) I get an unwanted space in the path: ...
0
votes
3answers
110 views

Replace character defined by ASCII code (by something else)

I am trying to replace, in a given string, some characters. The characters to be replaced is given by its ASCII code. So for example, in abc, I want to replace character 97 (which is a, but I don't ...
1
vote
0answers
32 views

How to allow curly braces in command option

I need to store an URL parameter like &path=weigth:5|color:orange|enc:okydHa}peAXOHi@jANv@A@kJJmFAiDJuAHmDXcBb@cC`@gC^_DV}CJaCF{APaBVkBdAyEf@qC`@{B\aDSwB with later reencoding to utf8 and passing ...
4
votes
1answer
340 views

Generating a catcode table in Latex (with \typeout to terminal)?

I often need to look up a catcode table, and quick searches on the web are rarely satisfying. So I thought, it must be (in the long term) easier to use a Latex function of sorts, to loop through all ...
6
votes
1answer
77 views

Redefine @ for tabular inter-column specification within \makeatletter \makeatother

I need to use a tabular with a @ inter-column specification within a \makeatletter and \makeatother environment. I. e. I something like \makeatletter %code that uses @ as letter ...
6
votes
1answer
96 views

How can I give active characters definitions with expl3?

It's very much glossed over in texdoc interface3… \documentclass{article} \usepackage{xparse} \ExplSyntaxOn \NewDocumentCommand \Digits { m m }{ \group_begin: \char_set_catcode_active:N ; ...
1
vote
1answer
52 views

gb4e breaks math subscripts in \caption

As @egreg notes in this answer to Can't compile XeLaTeX document with biblatex and gb4e together, the package gb4e makes _ and ^ active to be able to use subscripts and superscripts in ordinary ...
8
votes
2answers
258 views

Use a character other than the backslash for commands

I happen to author LaTeX code in an environment that makes entering the backslash tedious¹. Can I somehow tell LaTeX: From now on, treat, | (or another rarely used character) as if it were a \, so ...
7
votes
1answer
112 views

Unicode, right to left characters in command names

What is the status, in terms of category codes, of all the Unicode letters above ASCII in XeTeX (using XeLaTex+fontspec) and LuaTeX (using ConTeXt)? Can I define a macro using Unicode characters (ex. ...
3
votes
1answer
76 views

convert string to active character

in my book I will have to itemize a lot of things in different lists. That's why I want to reduce my commands to a minimum. This script is just part of a bigger macro. \documentclass{book} ...
287
votes
1answer
40k views

What do \makeatletter and \makeatother do?

Many TeX “hacks” begin with \makeatletter and end with \makeatother. What do these commands do?
6
votes
1answer
132 views

Active characters in linguistics

What are the pros and cons of using active characters instead of macros in text? Would it make sense to implement a “simplified markup” parser in Latex to make code more readable? Rationale ...
20
votes
4answers
2k views

Underscore in textmode vs mathmode

I use _ character often in text mode, so I changed category of underscore: \catcode\_=12, but that applies also to mathmode and now I'm unable to make subscripts with underscore in mathmode. Is there ...
20
votes
2answers
481 views

Incompatibility between verbatim and tabu? (Danger of using \scantokens in a package)

With the following MWE \documentclass{article} \usepackage{verbatim} \usepackage{tabu} \makeatletter \renewcommand\verbatim@processline {% \begin{tabu}to\textwidth{|l|X[-1,l]|} ...
7
votes
1answer
145 views

Defining HTML-like tags as TeX macros

I have to admit, my catcode skill are not that good. I'm working with some templates that will be filled in by a programme (HTML::Template, made for HTML but very handy for LaTeX as well). I'd like ...
14
votes
2answers
196 views

What is the easiest way to modify catcodes in a string?

Assume that a token register contains a sequence of letter tokens, each having a catcode of 12. I want to store in a second token register the same sequence of letter token, altering some catcodes on ...
5
votes
3answers
84 views

catcodes vs. autonum

I'm trying to make certain equations with large amounts of special characters more readable by playing with catcodes. This works: \documentclass[12pt]{book} \begin{document} $$ \catcode`X\active ...
4
votes
0answers
67 views

\makeatletter within a beamer frame: how?

Within a beamer frame (not outside) makeatletter (or \catcode\@=11`) does not work. \documentclass{beamer} \makeatletter \def\my@command{My at command} \def\myatcommand{\my@command} \makeatother ...
5
votes
2answers
66 views

Reset an active character in \href

In my document, the symbol / is active. This leads to the problem with links. Instead of the slash they contain expansion of the slash. Wanted: http://aaa/ggg/ddd/ Got: ...
11
votes
2answers
114 views

Determine whether the first non-space character of #1 is a letter?

Let's say I have a class file with \title command, and I want to check that the title starts with a letter, and not with math or a number or a symbol. How can I do that? This is my MnWE, the syntax ...
11
votes
1answer
147 views

Is it reasonable to expect an expl3-compatible release of TikZ/PGF in the future? / Workarounds for using TikZ under expl3 syntax

Keeping in mind: TikZ uses space tokens significantly, and expl3 syntax completely disregards whitespace and will only become more prevalent, is it reasonable to expect a future version of TikZ ...
3
votes
1answer
46 views

Is there a way to provide a starred variant of a (xkeyval) boolean (class) option

I'd like to define, for a class I'm working on, two boolean keys rather similar and, instead of giving them different names, I'd like to let the latter be a starred variant of the former. Let me give ...
9
votes
2answers
219 views

Adding newlines while writing text to a file

Within a custom command, I'm doing the following to write to a file: \newcommand\mycommand[1]{ \newwrite\file \immediate\openout\file=foobar.tex \immediate\write\file{ foo bar #1 ...
10
votes
1answer
65 views

Is there some reason I can't change catcodes inside a command?

I have a very simple question. When I do this: \catcode`\@=0 \catcode`\\=11 @mycommand{a} @catcode`@\=0 \catcode`\@=11 It works perfectly and calls \mycommand correctly. However, when I try to ...
11
votes
1answer
130 views

Replacing # characters with luatex

The minimal example below should replace all # characters with another symbol. This works well if I use \# to escape it, but the user should later be able to enter it directly, e.g. to enter hash ...
1
vote
0answers
57 views

Would I use \catcode, tokens, or look outside of tex for a markdown-like parser solution?

My use case: a LaTeX template for courseware designed in a beamer presentation style. The template I'm designing is company-specific and the specificity of the company's presentation guidelines limits ...
7
votes
3answers
163 views

Trouble defining a macro that typesets underscore characters as _

I want to define a macro that typesets its argument in typewriter font and allows for underscore characters in its argument. Within a group, I make _ active, I define \_ to be typeset as an ...
8
votes
1answer
85 views

Modifying alltt

I want to create an environment which wraps alltt in such a way that the character ' is replaced by \textquotesingle wherever it occurs inside the environment but is as normal elsewhere. I have tried ...
9
votes
1answer
148 views

How can I create a better cryptogram environment?

I put together a macro that takes two arguments. The first argument is a string of letters which defines a cipher. The second argument is a message to be encrypted using this cipher. ...
12
votes
3answers
293 views

Read strings from file that contains the special character #

I need to read some values from data files as given in the sample code. The problem arises when the files contain # character. Then I get " ! Illegal parameter number in definition of \@xs@call " ...
4
votes
2answers
190 views

Inserting automatic vertical space between blocks when \obeylines is active

Sometimes as I write a manuscript in LaTeX for speaking, I want to format parts of it as \obeylines and \obeyspaces permit, so that a single coherent thought is expressed compactly on each line, and ...
8
votes
3answers
9k views

Percent signs - “comment” and “active” both at once?

I convert documents from Word a lot, and I often forget to escape %, which leads to pieces of text missing. So I would like the following to happen in the main document body: escaped \% working as ...
6
votes
1answer
62 views

Scanning l3key with document catcodes?

Similar to the way TikZ attempts to use unknown keys as values for the color key, I would like to interpret an unknown key as the value for one of my own keys, decoration (not to be confused with the ...
5
votes
1answer
119 views

About catcodes and Family in LaTeX3/expl3

This is not so much the display of an issue or problem I'm facing out of my wish to use as much LaTeX3/expl3 as possible in my TeX-based work, as a request for advice on the proper ways in that ...
29
votes
5answers
2k views

Using indentation to automatically begin and end itemize environments

This is a question one might answer with "Why the hell would you want to do it?!", sort of an experiment. What I am looking for is a way to write lists with many levels of nestings (notes for school) ...
22
votes
2answers
494 views

What is the differences between mathcode and catcode and how can I use mathcode?

The command \catcode is often used to change some internals. E.g. the command \makeatletter changes the catcode @. But what is \mathcode and how does it work? catcodes are well explained here: Wiki ...
10
votes
1answer
267 views

Tweak with '%' (percent) symbol's catcode

I have the following code in my main.tex \catcode`\%=11 \immediate\write18{git log -1 --pretty=format:"%h%x3b%ad" --date=short > \jobname.info} \catcode`\%=14 which extracts the version ...
15
votes
1answer
222 views

Behavior of \\ in Plain TeX

According to \show, the pre-defined control sequence \\ is supposed expand to its argument without the suffix "pt": This is TeX, Version 3.1415926 (TeX Live 2012/Debian) **\show\\ > \\=macro: ...
5
votes
1answer
122 views

Active characters inside commands

I'm trying to ease my typesetting of phonetics with tipa by creating a custom command myipa which is supposed to substitute some common characters for the corresponding tipacodes. A much simplified ...
10
votes
2answers
327 views

Understanding LaTeX packages syntax

I've been using LaTeX for a few years for typesetting maths documents but I kind of feel there are two "kinds" of latex: the one I write my documents in and the one packages are written. My goal is ...
16
votes
3answers
284 views

Can I convert a string to catcode 11?

In the TeX FAQ there's a way to test if the jobname is equal to something (comparing the jobname). The difficulty of the naïve test is that the contents of the \jobname primitive are catcode 12 so to ...
4
votes
2answers
107 views

Test for a character, no matter if active or not (futurelet token)

I'd like to test for a character, irrespective its current catcode (i.e. active or not). This is very similar to How do I test for a character, irrespective of catcode?, however I cannot use ...