The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [catcodes]

{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.

Filter by
Sorted by
Tagged with
5
votes
1answer
222 views

How TikZ uses $ for calculations of relative coordinates?

The following code \node at ($(tag-node) + (2.5,0)$) allows to place a node by calculating $(tag-node) + (2.5,0)$. Does TikZ do that by changing the catcode of $ ?
4
votes
1answer
34 views

What is the purpose of \l_char_special_seq in expl3?

When looking for a \dospecials version in expl3, I came across the predefined sequence \l_char_special_seq for which the documentation says: Used to track which tokens will require special handling ...
1
vote
1answer
56 views

Auto index complicated formulas with catcode

original post Below is the minimally working code for a program that I am working on. My problem is that when I used more complicated code, it doesn't index automatically at the end. \documentclass{...
2
votes
1answer
31 views

how make two carets/hats/circumflexes ^^ unspecial

I want to make ^ unspecial in a command definition, i. e. “^” in the input should give the “^” character in the output. Setting the catcode to 11 or 12 works—but not for “^^”. Instead LaTeX replaces “^...
3
votes
1answer
77 views

How to use colon (':') as part of tikz syntax while in \ExplSyntaxOn environment?

I want to create a simple tikz style highlight which will draw ellipse around the object and write label at requested position. To avoid providing the font through the text argument, I've placed it ...
1
vote
0answers
34 views

Accepting special characters in arguments passing them further

I would like to define a macro very similar to \url, that accepts more or less arbitrary strings (including hashes/#) and passes them to other commands (i.e., \href, \url, \nolinkurl). I have tried to ...
1
vote
1answer
69 views

Why catcode of dollar symbol is 12 in header and footer?

Normally, the catcode of dollar symbol ($) is 3 in text. But I found that the catcode of $ is 12 in the header and footer, and $ can still be used as math shift. Example: \documentclass{article} \...
1
vote
1answer
75 views

Fine tuning of an active character definition

I've developed a catcode with the help of this answer to make some characters of Devanagari script active. I want to redefine characters of Devanagari script as active characters, to result in a ...
5
votes
1answer
146 views

Changing escape character in \tl_set_rescan:Nnn

I'm playing around a bit with the \tl_set_rescan:Nnn function (originally to make this answer more concise), but I'm struggling to make even pretty simple uses of this function work. Say we want to ...
3
votes
1answer
48 views

Getting a list of active characters

There are some characters that are active in plain TeX (e.g. ~) and some packages like babel make additional characters active (e.g. "). Is there a way to get a list of all active characters from ...
1
vote
1answer
64 views

Tikzcd with Beamer: extremely simple code results in & ampersand catcode error

\documentclass{beamer} \usepackage{amsmath} \usepackage{tikz-cd} \begin{document} \begin{frame}[fragile, t]{My slides} \only<1>{ \begin{equation*} \begin{tikzcd} a \end{tikzcd} \end{equation*}...
2
votes
1answer
40 views

How can I strip the percent char of a number read by csvsimple?

I have a CSV table containing some numbers in percent with the percent char explictily written in the CSV data (that can’t be changes). Is there a (LaTeX3) way to strip the percent char and preceding ...
0
votes
0answers
26 views

New command and catcode [duplicate]

I have a command that may contain the ampersand charater: &. Sometimes, when I use this command, I want that ampersand interpreted as a space. This is why I wanted to use the TeX command \catcode. ...
1
vote
2answers
34 views

Is there a way to change the character a particular byte maps to?

TeX is amazingly customizable. I would never do this, but I am curious whether TeX possesses the following functionality: As I understand it, TeX reads in a stream of bytes, and assigns each a ...
4
votes
3answers
111 views

How to redefine characters as alignment tabs in a table

I have a pretty good understanding of LaTex, but I've spent a while now digging up information on catcodes, but because they're lesser known, I haven't seen any applicable examples that will help with ...
1
vote
2answers
114 views

Reading CSV file with quotes

I'm trying to read a CSV file into latex and produce a new page for every row in the file. Unfortunately, the file quotes every field, uses semicolons as delimiters, and contains underscores in the ...
0
votes
0answers
34 views

Print category codes of all 256 possible input bytes? [duplicate]

The title. Is there a way to print (to the log file) the category code of every single possible input byte, either in order, or in some tabular form?
5
votes
1answer
119 views

\scantokens not playing nice with \def or \gdef etc

I working in a context where I'm changing catcodes and need to rescan the tokens before proceeding to process the text. But, I'm running into problems. Even with this bare minimum code, I still have ...
4
votes
2answers
48 views

How to use & differently than normal inside an `align` environment?

I'm trying to write a macro to let me write logic formulae in a more natural syntax. I've come up with a working version which however has a problem when used inside align environments (and in tabular ...
6
votes
2answers
332 views

Change the catcode and then define a (Unicode) character

The motivation is that I sometimes have, e.g. % !TEX encoding = UTF-8 Unicode \catcode`¯=\active \def¯#1#2{\overline{#1#2}} $¯ab+¯bc=¯ac$ in my code. I thought it would be nice if there is a macro, ...
9
votes
3answers
276 views

Macro char `#` doubles when made letter?

If I make a command that takes one argument, and the argument should be allowed to take the unescaped default macro char: # as an argument and then treat it as a letter: \documentclass{article} \...
3
votes
0answers
47 views

Efficiently setting category code for a range of characters

I kept thinking about using Cyrillic characters in command names with PDFTeX engine. It looks to me so far that if I stay with 8-bit encoding and assign category code 11 to all Cyrillic letters ...
11
votes
2answers
239 views

Why not catcode11 (letter) but catcode12 (other) is used for verbatim?

What would happen if catcodes were changed to 11 (letter) instead of 12 (other) in verbatim environment or something similar? Will any problems happen? Or, are there any advantages to use catcode12 ...
8
votes
3answers
633 views

Redefining a letter to itself

I have no idea why anyone would actually want to do this, but I want to know how I would do it (for educational purposes). Say I make e and active token, and then make it print the character e. I ...
6
votes
1answer
251 views

How can I set underscore to be a letter for use in normal macro names?

I'd like to change the category code of the underscore _ to 11 from 8 temporarily in two places. Why doesn't my code work? It seems to work for @ when using \makeatletter. Once for the list of ...
2
votes
1answer
53 views

Duplicate input without freezing catcodes

Background: I am currently writing a document in which I want to typeset some sentences in braille (using the braille package) as well as in normal text. My first attempt was to just say \def\foo{...
1
vote
2answers
122 views

Why is this code not working?

On this post, one answer states that \obeylines is defined as \def\obeylines{\catcode`\^^M\active \let ^^M\par } However TeX complains when I try to compile the following code \def\obeylines{\...
0
votes
1answer
30 views

Replace ideographic fullstop with CJK package

A common method to replace the ideographic fullstop (。) with fullwidth fullstop (.) is to change the catcode: \catcode`\。 = \active \let。=. However, this method will break when using CJK package ...
4
votes
2answers
90 views

Comments with something else than percent sign/carriage return

AFAIK, LaTeX's comments are what is between a pair of characters with category code respectively: 14 (normally a %), 5 (normally an end of line). Is it possible to define another pair of characters ...
4
votes
1answer
119 views

Environment that treats words or groups as command arguments

How can I define an environment that would treat each word or group as an argument of a function? I am writing a handbook that contains calculator entries, which I would like to typeset as buttons. ...
2
votes
2answers
121 views

how to change the comma (,) to centerdot (\cdot) through the \active command (\catcode`\,=13)?

I want to modify the catcode of comma, with the following code \catcode`\,=13 \def,{$\cdot$} I get the following error message: ! Missing control sequence inserted. <inserted text> ...
1
vote
1answer
743 views

Missing number, treated as zero. \catcode

I can not fix the bug. I hope someone may help me out. Missing number, treated as zero. \catcode\string`@= Missing number, treated as zero. \catcode`\.= Missing number, treated as zero. \catcode`\p= ...
5
votes
1answer
161 views

Control symbol formed by escape character followed by return

Does the control symbol obtained by following the escape character by return (\<return>, catcode 0 then catcode 5) behave like the control space character (\<space>, catcode 0 then catcode ...
10
votes
2answers
408 views

When is \catcode executed?

According to the TeXbook, characters in a file are first converted to tokens with catcodes ("mouth") and then any nonexpandable commands are executed ("stomach"). \catcode is a nonexpandable command, ...
4
votes
1answer
166 views

Scantokens and Let

The package inputenc makes it possible, for example, to write ° to print a degree symbol. Simplifying a bit, it obtains that by making it an active character (catcode 13) and defining the ...
1
vote
2answers
62 views

How to retain certain LaTeX commands in a datatool database?

I'd like to create the following table using datatool: \documentclass{article} \begin{document} \begin{tabular}{ *{3}{r} } \bfseries FieldA & \bfseries FieldB & \bfseries FieldC \\ ...
3
votes
1answer
129 views

Peek ahead and process characters

I want to replace unicode character pairs in XeTeX similar to Country flags unicode char. I don't want to specify every option (every country code) and want to be flexible for other emoji (skin color ...
3
votes
1answer
191 views

DTLgetvalueforkey works, but DTLfetch doesn't

In the following example \DTLgetvalueforkey retrieves the information without problem, while \DTLfetch fails: \documentclass{article} \usepackage{filecontents} \begin{filecontents*}{data.csv} ...
6
votes
1answer
208 views

The character code of a catcode-10 token

Consider the following plain TeX manuscript \catcode`z=10 \newcount\charcode \charcode=`z \font\myfont=cmtt14\myfont character code = \the\charcode, category code = \the\catcode\charcode \end The ...
2
votes
1answer
231 views

How to change catcode in environment

I try to locally change catcode in environment \newenvironment{wse} { \catcode`^=\active% \def^{\mathchar\numexpr"7000+`\^\relax}% $ } { $ } but the next code \begin{wse} x^2 \end{wse} ...
1
vote
0answers
35 views

Extra space in menukey’s directory output with 'bslash' sep

A user of menukeys reported (GutHub issue #48) that there is an extra space before hyphens in a directory sequence, when the input separator is a back slash: \documentclass{article} \usepackage{...
4
votes
2answers
385 views

Is a left brace implicit or explicit in assignments, and what should its category code be?

I'm trying to understand what exactly a TeX assignment is according to the TeXbook (Addison-Wesley 1996), as specified on pp. 275-278. On p. 275 it is stated that an assignment is one of two ...
1
vote
0answers
74 views

Deactivating an active character

How do I deactivate an active character? The following works without the activizations in the preamble, but not with them, in spite of my attempt to reset the catcode of : to 12. \documentclass{...
3
votes
1answer
204 views

How can I efficiently make TeX read each visible letter as a word?

In other words, How can I allow breaks after any visible character? ...[such that lines are broken when the sum of the lengths of horizontal boxes equals \linewidth] How can I disable or influence ...
1
vote
1answer
64 views

How to capture a macro's ultimate expansion as a string?

I have a macro \a. I'd like to define a macro \b, whose replacement text, T, will satisfy the following requirements: The catcode of every token of T is in the range 10-12. Ignoring catcodes, T is ...
5
votes
2answers
312 views

Catcode change doesn't take effect

Why does the following TeX manuscript result in an error upon compilation with TeX Version 3.14159265 (TeX Live 2017)? \catcode`}=12}\bye The error is: ! Too many }'s. <recently read> } l.1 \...
5
votes
2answers
384 views

Viewing a character's catcode, and listing all characters with a given catcode

How can I view the catcode of a character given by its ASCII number? Is there a way to list all the characters (represented by their ASCII numbers) that are associated with a given catcode? For ...
2
votes
1answer
137 views

Change the comment character (%) for the doc class

When generating files from a *.dtx source, Docstrip discards lines starting with the comment character % (unless they contain guards %<guard>content). When typesetting the documentation with ...
2
votes
1answer
694 views

Special cents notation in currency

I made a code that has a special way to write the cents. Here's a MWE: \documentclass{article} \usepackage{graphicx} \makeatletter \newif\if@thecomma \def\normal@comma{,} { \catcode`\,=\active \...
6
votes
3answers
707 views

How to make powers without enclosing the exponent in a pair of curly braces?

We all know that it is possible to write a power, which depends on an argument, without using the braces. As an example: x^2=x^{2}. When working with polynomials of degree greater than 9, we can now ...