{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

1
vote
0answers
28 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 ...
6
votes
1answer
57 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 ...
5
votes
1answer
79 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
35 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
241 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 ...
3
votes
1answer
61 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} ...
6
votes
1answer
92 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 ...
7
votes
1answer
134 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 ...
5
votes
3answers
77 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
54 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 ...
7
votes
1answer
98 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. ...
5
votes
2answers
53 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
109 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
137 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
45 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 ...
8
votes
2answers
137 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
58 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
119 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 ...
14
votes
2answers
188 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 ...
1
vote
0answers
55 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
132 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 ...
7
votes
1answer
75 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
130 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. ...
9
votes
3answers
227 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 " ...
6
votes
1answer
57 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
109 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 ...
10
votes
1answer
187 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
216 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
93 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
272 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
264 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
101 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 ...
7
votes
1answer
92 views

Difference between 11 and 12 catcodes

I can only define commands, consisting of catcode-11 symbols or single catcode-12. What is the point of this limitation? It would be convient for me to define commands, that include following, not ...
3
votes
1answer
69 views

TeX document allowing any byte sequence being inserted

Out of a hacker's interest, I looked for a TeX document into which an arbitrary byte sequence can be inserted without causing the TeX process to fail, but had a similar issue; I basically set all ...
19
votes
2answers
444 views

Outright impossible TeX byte sequence

Out of a hacker's interest, I am wondering if there is any byte sequence that can never occur in any valid TeX document before \end is processed. I thought of things like {\catcode`}=9\catcode`\=9 ...
13
votes
1answer
394 views

When does TeX execute the \catcode=`\… assignment?

TeX always scans the input and converts it into some tokens, then expands some tokens according to the latest definition of that command ... stomach -> lists -> page but when does TeX execute the ...
22
votes
2answers
389 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 ...
4
votes
2answers
142 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 ...
3
votes
1answer
147 views

How to override TeX dollars?

I've read about \renewenvironment and \let commands but they are intended to work with classic commands TeX commands that start with a slash. And I cannot find any example of overriding $ and $$ any ...
4
votes
3answers
133 views

How can I typeset a bibkey with &?

I would like to typeset a catalog of all my BibTeX entries. I have been using & in many bibkey's such as Author&Editor:2000. But I cannot \catcode38=12 globally. My question is: how can I ...
7
votes
2answers
553 views

\makeatletter explained

I am using the following code in my beamer document to make the frame title's appear in the table of contents: \documentclass{beamer} \usetheme{default} \usepackage{bookmark} \usepackage{etoolbox} ...
5
votes
2answers
138 views

Ignoring Punctuation during Comparison

I am trying to compare two strings and ignore punctuation during the comparison. I thought that catcode redefinition would be a good way to proceed. But, obviously, the use of \catcode has a great ...
4
votes
2answers
148 views

Substitute all 'A' with \textsc{a}

Can I use catcode to substitute all capital letters in my document to \textsc{\myletter}? EDIT: I would like to make this by a function, like: \thisismystring{BLABLABLA}, that converts into ...
6
votes
3answers
305 views

Why are some characters not allowed in command sequences

From my understanding a control sequence is ended by any non-alphabetic character such that \mycsA is one token, but \mycs1 is two tokens. This means things like starred commands \mycs* are actually ...
5
votes
1answer
156 views

Saving in macros plus \scantokens as an alternative to external files

I am generating a lot of TeX code automatically using Python scripts. I've been saving the TeX code to file, and then bringing those files into my documents at the appropriate places via \input. ...
3
votes
1answer
208 views

Expanding subscript and subscript capabilities

Well, I liked the idea expressed in the question alternative syntax of subscripts using tex. But I want it to work in a sightly different way. I just want to expand the usual _ and ^. How? So that ...
3
votes
1answer
203 views

Use catcode for alternative way of writing fractions

Writing fractions using different syntax would sometimes be useful, instead of using \frac{ab}{cd}, I would prefer to write something like \frac{ab⌂cd} where the Unicode ⌂ is the }{. n.b., I don't ...
8
votes
2answers
317 views

Why does LaTeX (contrarily to TeX) not allow catcode changes in footnotes?

In Plain TeX the following compiles with no error Hello\footnote*{\tt\catcode92=12 \world}! \bye The analog in LaTeX \documentclass{article} \begin{document} Hello\footnote{\ttfamily\catcode92=12 ...
20
votes
2answers
426 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]|} ...
4
votes
1answer
68 views

Breaking inline equation at several punctuation characters

I am trying to define a command which automatically allows linebreaks inside inline equations at several punctuation characters — I am aware of \allowbreak but don’t want to manually insert it; here, ...