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
0
votes
0answers
48 views

How are class, package, document writers using modifications to \catcode

I'm thinking that the primary uses of changing \catcode in LaTeX are to: enable “private” macros (e.g., \makeatletter ... \@foo ... \makeatother or the expl3 syntax allow for verbatim-like commands/...
1
vote
1answer
22 views

Display blank lines at half-height in fancyvrb Verbatim environment

I'm typesetting code that includes lots of blank lines, like this: \documentclass{minimal} \usepackage{fancyvrb} \begin{document} \begin{Verbatim} def xyz(): """Some documentation. ...
1
vote
0answers
23 views

`\makeatletter` and `\makeatother` : the difference relationship and usage of [duplicate]

Can a MWE be given showing the difference, relationship and usage of \makeatletter and \makeatother ? The existing answer explain these commands but do not provide a useful MWE which would show the ...
0
votes
0answers
28 views

How to make brackets work like group separators?

I know that the following is not something you are usually supposed to do, but I ask anyway: I am getting quite tired of the fact that TeX does not treat the content of brackets [...] as groups like {....
0
votes
1answer
31 views

catcode in expl3 string

(Forgot where I saw this but should be some official doc): A TEX string (and thus an expl3 string) is a series of characters which have category code 12 (“other”) with the exception of space ...
0
votes
1answer
20 views

Misplaced \noalign following two newlines

Why does a \noalign command produce a ! Misplaced \noalign when it follows at least two newlines. For example, this code works : \documentclass[10pt,letterpaper]{article} \begin{document} \halign{\...
4
votes
1answer
79 views

Catcode change for command arguments

I want to write commands that can have arguments within <> by changing the catcode of the two signs. \documentclass{beamer} \newcommand{\mycommand}[3]{ This is #1. This is #2. This is #3. } \...
4
votes
3answers
317 views

About catcodes and active characters

I'm reading about catcodes and I want to play a bit with them. However, there's a point I don't really understand. When I want to define an active character, e.g., square brackets ([ and ]) I do the ...
1
vote
1answer
18 views

incompatibility of xparse e- and t-type argument with subscriptcorrection option of newtxmath

It appears that the subscriptcorrection option for newtxmath is incompatible with e- and t-type arguments of xparse that use _. Using examples adapted from egreg's answers here and here, the following ...
3
votes
1answer
194 views

Setting the backslash's catcode

For fun, I want to change the backslash's catcode from 0 to 12. However, I can't seem to make it work. Here's my current MWE, which gives an error "improper alphabetic constant": \catcode`\...
4
votes
0answers
47 views

amsart + \makeatletter + @ @ @ in a caption = disappear

In some circumstance adding @ into the caption will cause it to disappear. This can be solved by adding \makeatother at proper places. I just want to know why is this happening. \documentclass{amsart}...
1
vote
1answer
31 views

How can I increase catcode defs in a verbatim environment for transcribing handwritten documents?

Using verbatim (not Verbatim) for transcribing handwritten documents. I spend a lot of time transcribing wills, deeds, letters and other handwritten documents. In doing this I use the verbatim ...
0
votes
1answer
47 views

Journaling calls to a function taking inline code as argument / macro param in horizontal mode issue

In the code below \Foo evaluates inline code. \Baz is a 'journal-ed' version, meaning it writes calls to \Foo to a file. Reading the file fails (Hook 2) due to a "'macro parameter character #' in ...
1
vote
2answers
65 views

detokenize only active character

Few year ago, I asked a question about the best way to make active character inactive, in order to solve an issue with reledmac. inputenc, active catcode and \csnsame The answer was to use \...
2
votes
2answers
94 views

Setting \section Counter From First Letters of \jobname

related to Substring of filename in LaTeX and extract number from \jobname as counter . I am naming my filenames as 01-text1.tex, 02-something.tex, 03-blah.tex and so on. I would like to set my ...
3
votes
1answer
52 views

Double “#” (hash) char when using expl3 string

\documentclass{article} \usepackage{expl3} \ExplSyntaxOn \catcode`#=11 \str_set:Nn \l_tmpa_str {#} \tl_analysis_show:N \l_tmpa_str \str_set:Nn \l_tmpb_str {#} \tl_analysis_show:N \l_tmpb_str \...
2
votes
1answer
66 views

ConTeXt - escape percent sign in externalfigure

This fails during typesetting: {\externalfigure[https://images-na.ssl-images-amazon.com/images/I/41rVft84o%2BL._SX384_BO1,204,203,200_.jpg][book]}{} This typesets, but the image doesn't display (it ...
1
vote
1answer
55 views

Change catcode of @ in a tabular environment inside a beamer frame

In order to input data from a file into a tabular environment, the TeX macro \@@input has to be used (see this question), since \input is non-expandable. Why is it not possible to change the catcode ...
3
votes
1answer
58 views

Inside \ExplSyntaxOn/Off pair, \tl_set_rescan:Nnn gobbles every space input as ~

Inside \ExplSyntaxOn, ~ tilde char is set to have category code of 10 (space). But then \tl_set_rescan:Nnn gobbles every space input as ~. If category code of space char is restored to 10 and then ...
3
votes
1answer
61 views

Formatted date via directlua

I would like to get today's date formatted using \directlua. The % signs seem to be a problem. And I don't know how to get it to work. Both attempts in the following example throw errors: \...
1
vote
1answer
58 views

XeTeX: How to *globally* replace an ASCII character with another symbol?

A few months ago, I asked whether the “EB Garamond” font contains a short-arched version of the letter f. I have now found out how to access this letter because it actually exists. Writing \...
4
votes
2answers
72 views

What does the comment-pln code actually do?

The comment-pln code on CTAN (link) defines the plain TeX macros \begincomment and \endcomment, that ignore everything typed in between. The entire code base is included below: % Comment.tex % ...
0
votes
1answer
47 views

How to get catcode of a name defined with \let (or with \def)?

How do I get catcode of \tmpA and \tmpB? \documentclass[margin=5mm,varwidth]{standalone} \begin{document} \let\tmpA=a \def\tmpB{b} \the\catcode`a % 11, FINE; BUT WHAT ABOUT \tmpA AND \tmpA? \...
5
votes
1answer
46 views

Strange catcode setting at beginning of unravel package

At the beginning of the unravel package source code we can find some cryptic catcode settings: \begingroup\let\c\catcode\fam32\c\fam10\advance\fam5\c\fam14\c45 12 % \c54 12\c55 12\c56 12\c57 12\c58 ...
10
votes
1answer
185 views

What are the catcode 11 / letter codepoints in Xe(La)Tex?

I'm trying to write a (JavaScript) RegEx to turn arbitrary sequences of characters into (hopefully) unique command names. Part of the solution would be to replace everything that does not match /[a-...
5
votes
1answer
317 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
40 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
66 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
44 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 “^...
6
votes
1answer
198 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 ...
4
votes
1answer
172 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
91 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
108 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
166 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
90 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 ...
3
votes
1answer
150 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
73 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
43 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
39 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
173 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
235 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
36 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
144 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
58 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
425 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, ...
10
votes
3answers
309 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
54 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
261 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
637 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
274 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 ...

1
2 3 4 5 6