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
71 views

Increase the skip after a comma, in math mode

I want to define a command \widecomma, so that $\widecomma{a,b}$ looks the same as $a,~b$. The following is my attempt. \let\comma, \newcommand{\widecomma}[1]{\begingroup\catcode`,=\active\newcommand,...
1
vote
0answers
43 views

Create a new `catcodetable` in LuaLaTeX

The latest LaTeX versions incorporated the luatexbase package in the kernel. The package predefined a number of named catcode tables, which have now been absorbed in the kernel. These named tables can ...
4
votes
2answers
135 views

Consequences of setting \mathcode of letters and symbols to "8000?

I know this is not something that you’re supposed to do. But for fun, I played around with the idea of changing the \mathcode of all letters to "8000 and defining them as commands. Each such ...
1
vote
3answers
49 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 ...
3
votes
2answers
75 views

Force \endlinechar to reset before the end of last line

I am creating a macro which should write its argument as a literal string to an external file. This is its current state: \newcommand{\mycmd}{% \begingroup \let\do\@makeother \dospecials \...
3
votes
1answer
145 views

Why does space with catcode 12 yield a weird dash?

For fun, let’s change the category code of space to 12. Then we get the following weird dash instead of a space. Why? \documentclass{article} \begin{document} \begingroup \catcode` =12 Hello World,...
2
votes
1answer
65 views

Writing zeros with backslash natively

To avoid the general confusion with 0,O,o in general text, I am trying to define my own zero with a backslash within it (it also remains distinct from the \emptyset symbol or similar alphabets from ...
1
vote
1answer
29 views

datatool - How can you load database from .csv-file with values tokenized with same catcode-settings as are used by \verb|...|?

I plan to use the package datatool for loading a .csv-file as database: \DTLloaddb[<options>]{<db name>}{<filename>} How to achieve tokenizing values of that database under the same ...
2
votes
1answer
27 views

Hyperlink in a footnote containing a %

I want to write a link to a webpage into a footnote. Using the hyperref package, this works fine unless I have a % symbol in the link. This is the MWE (which is not working): \documentclass[12pt]{...
1
vote
1answer
62 views

What's the function of the @ symbol? [duplicate]

I'm sure that this is TeX basics and I'm just being a fool, but I can't figure out for what/how the @ symbol is used. All I can tell is that to make sure it works you have to put it between \...
0
votes
1answer
87 views

On the proper use of `\tl_rescan`

Looking at the code below, what would the setup in 6. have to be to return F? Also, why does 2. return F in other words how are \group_begin: and \c_group_begin_token different? \begin{enumerate} \...
1
vote
1answer
56 views

Prevent babel shorthands from interfering with catcode changes

I want to write an XML-like key-value-parser for LaTeX. That is, kv-pairs are separated by spaces, and values are separated from keys by = and encapsulated by double qoutes. The following minimal ...
3
votes
1answer
33 views

Non letter name in command definition

I'd like to define similar commands one with underscore the other — without. However such an approach throws me an error \def\Fix#1{\mathrm{Fix}(#1)} \def\Fix_#1#2{\mathrm{Fix}_{\,#1}(#2)} I tried to ...
825
votes
1answer
192k views

What do \makeatletter and \makeatother do?

Many LaTeX “hacks” begin with \makeatletter and end with \makeatother. What do these commands do?
1
vote
3answers
66 views

Reducing space only within parenthesis

I would like to reduce the spacing around relation symbols that appear within parenthesis from thickmuskip to thinmuskip. Here is what I have come up with: \documentclass{article} \usepackage{xcolor} \...
4
votes
1answer
95 views

Define \textunderscore to mimic look of standard underscore

I noticed that the look of the underscore _ differs greatly from the look of \textunderscore How can I redefine \textunderscore to look like the standard underscore of the set font? I want to avoid ...
1
vote
2answers
66 views

what do these commands do

Could anyone explain what the commands \@tempcntb \count@\@ne \@curtab For reference, I found them on How to produce a list of prime numbers in LaTeX i do understand that i can create new counts ...
3
votes
2answers
150 views

Default enumerate environment with easylist syntax

With the package easylist, we can create nested lists easily: \documentclass{article} \usepackage[at]{easylist} \begin{document} \begin{easylist} @ First % -> 1. First @@ Second % -&...
3
votes
1answer
62 views

How do I make a character active only in text mode?

I want to make the character > active only in text mode (to create markdown-style block quotes) but not in math mode. I know the \mathcode`>="8000 way to make a character active only in ...
4
votes
1answer
103 views

catcode 12 spaces

I would like to understand TeX's behaviour when the catcode of the space character is set to 12. The following two example input files differ in just one position: where the first has the character 4 ...
8
votes
1answer
434 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}{ \...
4
votes
1answer
119 views

Why does TeX have so many category codes?

When I look at the long list of category codes, I simply don’t understand why they are all needed. For instance: $, ^, _, and & could have easily been defined as active characters instead. ...
0
votes
1answer
45 views

Ask LuaLaTeX to ignore an active catcode previously written into aux file by pdflatex

I'm writing a package that loads babel and which users might run under either pdflatex or lualatex. When babel's french option is loaded, ":" is made active; and pdflatex writes the ...
16
votes
3answers
389 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 ...
0
votes
0answers
58 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
45 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
27 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
42 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
52 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 ...
4
votes
1answer
242 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 ...
0
votes
1answer
23 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
132 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
390 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
26 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
272 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`\...
9
votes
3answers
726 views

Make Characters Active via Macro in Math Mode

I am trying to make characters active in math mode, but can't seem to get past the most basic of examples. I would like to define a macro which is passed: the character to make active and the macro ...
4
votes
0answers
55 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}...
0
votes
1answer
57 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
82 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
116 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
58 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
111 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
71 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 ...
4
votes
2answers
735 views

Save and restore the makeatletter/makeatother state

When posting snippets of latex code that define or modify commands containing @, one commonly includes the \makeatletter...\makeatother wrapper that's necessary if pasting the snippet into an ordinary ...
10
votes
2answers
218 views

Splitting macros to individual tokens/characters, with catcode (to debug conditionals)?

Consider this MWE, modified from ifthenelse equal string comparison fails: \documentclass{article} \edef\test{german\relax} \edef\curentry{\string german\relax} \typeout{test: \meaning\test, ...
7
votes
1answer
145 views

Save an active colon from within expl3

Is there a preferred way to realize the following without having to leave expl3 syntax? \documentclass{article} \usepackage{expl3} \usepackage[french]{babel} \begin{document} \ExplSyntaxOn % suppose ...
3
votes
1answer
69 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
78 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
69 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 \...
11
votes
3answers
334 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} \...

1
2 3 4 5 6