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
3 votes
1 answer
100 views

Using a command to generate a table row in tabularray

I have a command that generates a table row for insertion into a tblr environment as shown below: \documentclass{book} \usepackage{tabularray} \begin{document} \newcommand\MyRow[2]{ #1 & #2 \\...
1 vote
1 answer
53 views

what is definition of "\@nobreaktrue"? [duplicate]

I find it difficult to find the definition of commands starting with @. Where and how is \@nobreaktrue defined?
1 vote
2 answers
64 views

How to use catcodes in a macro/environment

I want to use catcodes in an environment and the catcodes shall be changed for a very short part in the document. MnWE: \documentclass[a5paper, 11pt]{scrartcl} \usepackage{environ} \NewEnviron{Lied}[...
  • 2,268
1 vote
3 answers
98 views

LaTeX macro for topic sentences (square bracket "[" and "]" active character catcode)

When writing a document, I usually write "topic sentences" (i.e. outline sentences) between square brackets like so: [in here is the main idea of the next paragraph] Here I write a polished ...
1 vote
1 answer
33 views

12 catcode for UNDERSCORE and character printed

Does a LaTeX3 version of the following code could be simpler? I understand the logic, but I dislike the code... \documentclass[12pt]{article} \usepackage{color} % Source: https://tex.stackexchange....
  • 12.7k
0 votes
1 answer
39 views

Spacing between \cdots and binary operators

I use \cdots to denote omitted terms in my sum, and expect it to have the same amount of spacing around it as if it were a usual term. Yet things are working a little differently from what I expect. ...
1 vote
2 answers
61 views

LuaTeX change the catcode of numbers

I'm trying to check if a label is defined with \ifdefine \r@labelname. The label is a hexadecimal number like 215Bh and this does not work. So I tried to change the catcodes of the numbers to 11 But I'...
  • 13
0 votes
2 answers
60 views

How to print a vertical bar if it is \active?

I'm trying to print a vertical bar symbol, but it's \active in the ltxdoc document style (this code doesn't compile): \documentclass{ltxdoc} \begin{document} This is a vertical bar: |\|| \end{document}...
  • 11.2k
5 votes
4 answers
305 views

strlen in TeX Language

Trying to implement a simple algorithms in TeX language, I've tried to implement a string length function (potentially a token counter function). I know spacing in TeX engine has a different mean from ...
3 votes
2 answers
192 views

How to check whether some \catcode is \active?

I'm going to change a catcode to active and then implement my own formatting of small verbs: \if-not-active \catcode`|=\active \def|#1|{\foo{#1}} \fi I want to make this non-intrusive and check ...
  • 11.2k
4 votes
2 answers
108 views

Understanding this example of modifying category code

There was a question about automatically adding space after the periods and commas. An answer to it included modifying category code. It is shown below. \documentclass{article} \usepackage{expl3} \...
  • 767
1 vote
1 answer
36 views

Detecting if an argument to a macro is just a string

Let's say I construct a macro like \keywords{this, that, other} that accepts an argument, but I want to reject any argument that contains macros or anything besides space, newline, and characters (...
  • 137
0 votes
1 answer
48 views

Defining unicode character in the context of another (pdfLaTeX)

This is a bit of a strange question. Suppose for some unknown reason I want the character ɲ (U+0272, 0xc9 0xb2) to say "bye", the character ɳ (U+0273, 0xc9 0xb3) to say "aww", and ...
0 votes
1 answer
49 views

How to revert the effect of \obeylines and \obeyspaces for \input content?

This is my file a.tex: \begin{tikzpicture} \node[] (v) {hi}; \end{tikzpicture} \endinput This is main.tex: \documentclass{article} \usepackage{tikz} \NewDocumentEnvironment{foo}{b}{ % here I ...
  • 11.2k
2 votes
1 answer
60 views

How to redefine symbols inside my custom environment?

I'm trying to create my own foo environment, which would be used like this: \documentclass{article} \begin{document} \begin{foo} a -> b [ c => d ] \end{foo} \end{document} I'm expecting it to ...
  • 11.2k
0 votes
2 answers
70 views

Using hyphen as a letter in command names

I am using hyphen as a letter for command names. But I allow users to rename them if necessary. Then use \catcode`-=11. Suppose I keep the hyphen as a letter in command names, I wonder if users ...
  • 337
2 votes
2 answers
67 views

How to define a new character while avoiding clashes with existing character definitions?

I want to define a new character. For context, in particular, my new character would act similar to the ^ character for superscripts, but would put parentheses around the context of the superscript. ...
  • 121
5 votes
2 answers
164 views

First character of \ref{<label>}

Practically, I would like to decide if a reference to a label begins 1 or not. The question has some relevance in Hungarian. The idea was to use xstring package: \documentclass{article} \usepackage{...
  • 115
7 votes
5 answers
486 views

Use : colon character in weird argument — expl3

Since \ExplSyntaxOn changes catcode of : it makes command with weird argument break when using the macro outside. \documentclass{article} \begin{document} \ExplSyntaxOn \cs_set:Npn \my_foo:w #1:#2\...
  • 3,992
0 votes
2 answers
50 views

Change the font of apostrophe inside a command

I can universally change the font of apostrophe ' using \def\myprime{{\usefont{T1}{ppl}{m}{n}\symbol{39}}} \catcode`'=\active \def'{\myprime} But, what I really wanna do is to change it only inside a ...
1 vote
2 answers
74 views

Is it possible to redefine the character code of space?

If I execute the code \tt\catcode` =12\relax test I get: I also can emulate the same effect using \char32 in place of <space>. Is it possible to change the character code of <space>, so ...
  • 670
4 votes
3 answers
221 views

How would I define a character to start and end an environment in plain TeX?

In TeX, starting and ending math mode is done with the same symbol, namely $. Suppose I would like to start and end an environment like this, perhaps with the text italic, using the character *, as ...
  • 670
6 votes
3 answers
471 views

How to use \catcode in a command?

I would like to define the character @ as follows: \def @#1#2{\catcode`#1=13\def #1{#2}} so that when I type @xy x, TeX typesets y. However, when I run this, I get an error. I have seen other answers ...
  • 670
3 votes
1 answer
198 views

pdflatex stops when both german and hungarian languages are set in babel

This is a MWE: \documentclass{article} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage[german,hungarian]{babel} \begin{document} babel test \end{document} When I run pdflatex on ...
  • 869
5 votes
1 answer
153 views

Why is the underscore OK inside of a `\cite` command?

The underscore character _ has a category code of 8, because it has special meaning in TeX and a special role. Including an underscore in the main body of a LaTeX document will generally cause a ...
  • 1,534
1 vote
0 answers
41 views

What is the right way of cascading styles using nested environments/macros, while each environment/macro might partially stylize its embedded content?

I have asked similar to this question before, but I think I have to describe it in another way. Need What is the right way of cascading styles using nested environments/macros (much like the way CSS ...
  • 365
0 votes
0 answers
38 views

How to make \endlinechar act exactly like a(n) (active) space? [duplicate]

I know that, in normal circumstances, an endlinechar (=13) of input gets converted into white-space. But, in this MWE, I make the charcode 32 space character active and replace it with a ...
0 votes
0 answers
5 views

csvsimple problem: csvreader reads > as?, what can I do? [duplicate]

I'm a beginner using LaTex. Currently I'm doing my thesis project and I need to do a table from a csv. However, csvreader from the csvsimple package is giving me problems because it reads > as ¿ ...
1 vote
1 answer
46 views

How can I run scantokens with modified environment, but use the normal environment within the scanned code?

For example if I run %! TEX program = lualatex \documentclass{article} \begin{document} {% prepare a token list <a> (assume this is provided by user) \catcode 13=12\relax % 12:other \global\...
  • 5,116
0 votes
2 answers
126 views

Make a char behave like a 'space', in math mode

Some may find it a terrible idea, but I have tried to use the dot . to behave like a space in math mode. The idea is to be able to write \cos.x or, more generally, \macro.x rather than \macro{x} or \...
  • 21
2 votes
2 answers
43 views

How to return a filename containing underscore from a switch-case function (like ifEqualCase) as a parameter into a function like addplot?

When plotting and iterating through a list of filenames, I wanted to call them from a switch-code and apply them in \addplot. I used the switch-function \IfEqCase from the xstring package. However, ...
1 vote
1 answer
41 views

How to well convert underscore with catcode=12 with make4ht?

I have the following 'MWE.tex' file where I defined underscore with \catcode'_=12: \documentclass{article} \catcode`_=12 \begin{document} Text containing underscore between parenthesis (_) \end{...
2 votes
1 answer
162 views

How to avoid redefining ampersand & globally?

In my attempt to make my library zx-calculus based on tikz & tikzcd compatible with tikz externalize (to save compilation time), I've basically been using this solution https://tex.stackexchange....
  • 5,559
3 votes
0 answers
54 views

Defining an environment with markdown in a tcolorbox

This works in Overleaf: \begin{tcolorbox} \begin{markdown} - Foo - Bar \end{markdown} \end{tcolorbox} But I can't define a new environment that does this with a single environment declaration (...
  • 131
3 votes
3 answers
765 views

What's the alternative for the standard verbatim environment that can be used inside argument/does not change catcode?

How can I get something to typeset the output identical to that of a verbatim environment, e.g. of this code \documentclass[12pt]{article} \begin{document} before \begin{verbatim} 123456_789$^% \end{...
  • 5,116
1 vote
1 answer
328 views

Adjust space between words in \mathrm

I defined the following command: \newcommand{\mymathrm}[1]{\operatorname{\mathrm{#1}}} The problem is that $\mymathrm{A B}$ gives something like AB, which does not typeset the space between A and B. ...
1 vote
0 answers
158 views

TeX or LaTeX file with a hidden pasword

This question is inspired by this one: Convert PDF to PDF of images? As the author does have the code, creating a LaTeX version that is difficult to decrypt seems to be a good solution. Certainly, it ...
1 vote
1 answer
62 views

What is causing punctuation to appear around my matrices?

I have an input file called mathchar.tex, which I rely on pretty heavily: \mathchardef\Gamma="7400 \mathchardef\Delta="7401 \mathchardef\Theta="7402 \mathchardef\Lambda="7403 \...
  • 267
2 votes
1 answer
97 views

redefining & within an environment

I've been following the solution here to get tikzcd and the externalisation library to play nicely with each other. One step of this redefines &. However, at the moment, it does this for the whole ...
3 votes
2 answers
50 views

Are there any significant differences between letter and other catcode in stored token lists?

While parsing input, the catcode 11 (letter) and 12 (other) are different (that the latter cannot appear as a part of a multi-character control sequence). However, when they're already parsed it doesn'...
  • 5,116
2 votes
2 answers
330 views

Automatically change l to \ell in a math mode

I want to find a way how to automatically change "l" into "\ell" in a math mode. I tried to do it using \catcode, but it's quite difficult for me. I want it to change "l" ...
1 vote
1 answer
121 views

How to load amsfonts/umsa.fd

I changed the catcode of F to active in my environment and now I can't use math mode. The problem is this: (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/umsa.fd ! Undefined control sequence. l.29 \...
  • 97
7 votes
2 answers
203 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
0 answers
76 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
2 answers
274 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 ...
  • 12k
3 votes
2 answers
99 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 \...
user avatar
3 votes
1 answer
177 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,...
  • 12k
2 votes
1 answer
141 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 ...
  • 497
1 vote
1 answer
90 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
1 answer
336 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]{...
  • 383

1
2 3 4 5
7