Skip to main content

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
1 answer
33 views

Parsing colon-delimited macro argument (with possible catcode changes)

I try to define a macro taking as an argument either a number or a colon-delimited range of numbers, e.g. \macro{3.14} or \macro{2:5}. I can parse the colon easily using a simple trick: \def\macro#1{ ...
Circonflexe's user avatar
3 votes
1 answer
78 views

Robustness of \peek_analysis_map_inline:n with changed catcode

Background Following my previous question I try to make compatible the redefinition of the circumflex ^ catcode with the active prime ' defined in vanilla LaTeX or by the package unicode-math. The ...
jlab's user avatar
  • 4,246
1 vote
0 answers
46 views

Redefine commands, changing a catcode

Background I'm the author of the altsubsup package, which set to 12 (other) the catcode of the circumflex ^ char. As it, expressions as x''^2 raise a Double superscript error because the latex ...
jlab's user avatar
  • 4,246
2 votes
1 answer
120 views

Automatically substitute hyphen(-) with \ensuremath{-} inside of the table environment

Because, in my usage, most of hyphens(-) used inside of the table environment represent the minus sign, I would like to substitute them with \ensuremath{-}. Here's my try: \documentclass[10pt]{article}...
user182849's user avatar
0 votes
1 answer
19 views

How can I use escapeinside within a minted environment with the bash lexer?

The escapeinside functionality doesn't work properly with the bash lexer. Is there any way to fix this? MWE: \documentclass{article} \usepackage{minted} \begin{document} \begin{minted}[escapeinside=|...
OpenAI was the last straw's user avatar
3 votes
2 answers
84 views

Changing a catcode of WolframAlpha output character

Sometimes I exploit WolframAlpha to do some simple calculations and then insert results in my latex code. But I find annoying to adapt the output given by WA to the LaTeX syntax. When the output is a ...
Antonio's user avatar
  • 107
2 votes
1 answer
54 views

verbatim mode and carriage return character tokens

This question refers to how the program TeX creates tokens after reading a line of a .tex-file. It does actually not refer to writing macros or doing typesetting work which takes place in stages after ...
user avatar
2 votes
3 answers
183 views

Can't compare clist item with string

I can't compare comma list item with string. \clist_a is a temp var. \documentclass[12pt]{article} \usepackage{expl3} \begin{document} \ExplSyntaxOn \clist_new:N \clist_a \keys_define:nn { mymodule } ...
zpding's user avatar
  • 447
0 votes
1 answer
36 views

Preserving newlines and spaces while writing argument to a file

I am making a function that should write its argument to a file (for further processing by Python) From the following question I get something that mostly works. Adding newlines while writing text to ...
Atnas's user avatar
  • 497
2 votes
1 answer
107 views

htlatex breaks down when using siunitx

I have a manuscript that is written in LaTeX. After a couple of rejections and modifications, the new journal seems to only accept .docx files. I plan to convert my manuscript to a .odt as the editor ...
Miloop's user avatar
  • 982
0 votes
0 answers
71 views

Starting command using “/“ instead of “\”

This seems like a very random question, but I just got the Apple Magic Keyboard for iPad Air 5th generation. The key “\” is half of the size of that of “/“. The “\” key is placed also in the edge and ...
William Sun's user avatar
0 votes
3 answers
160 views

How can I change the catcode within a command, then reference input using the new catcode?

pdfTeX: I am attempting to define a command which takes an input, redefines the catcode and function of a character, and prints the input using the new character definition. I recognize that this is ...
Jeff Buffkin's user avatar
4 votes
2 answers
388 views

Show carriage return by changing its catcode in TeX?

On page 46 of The TeXbook, there is TEX deletes any space characters (number 32) that occur at the right end of an input line. Then it inserts a return character (number 13) at the right end of the ...
Y. zeng's user avatar
  • 2,115
0 votes
1 answer
75 views

"\escapechar" vs category 0 in TeX

In TeX, \catcode`\|=0 will make escape character to be |, to |TeX will output But at the penultimate paragraph of page 40 of The TeXbook, it says that \escapechar is normally TeX's internal code for ...
Y. zeng's user avatar
  • 2,115
1 vote
1 answer
123 views

To make "\" to category 12, why should convert it to category 13 in TeX?

Exercise 7.5 on page 40 of The TeXbook asks to make \ to category 12. The answer of this question is {\catcode‘/=0 \catcode‘\\=13 /message{/string\}} Why should assign the \ to 13 not 12? The ...
Y. zeng's user avatar
  • 2,115
0 votes
2 answers
77 views

Need add a space before character in changing category of character?

At the bottom of page 307 of The TeXbook, it says TEX always reads the token following a constant before evaluating that constant. So, {\catcode‘\>=2 > is different from {\catcode\`>=2> ...
Y. zeng's user avatar
  • 2,115
0 votes
2 answers
75 views

Remove all instances of {} interior to argument to a command

Is it possible to remove all instances of {} which are passed as parts of an argument to a command? I would like to use the Tensor package with LyX. The problem is that LyX always puts subscripts ...
Mike Pugh's user avatar
  • 329
5 votes
1 answer
133 views

Why does a \catcode-changed underscore work in math mode also without \mathcode set to "8000?

Something is puzzling me... consider %\begingroup %\catcode`\_=13 %\gdef_{\sb} %\endgroup \catcode`\_=11 \def\foo_bar{Foo bar} \foo_bar\ $a_b$ \bye Uncommenting the commented code yields (One can ...
campa's user avatar
  • 32.6k
9 votes
7 answers
592 views

Detect catcode of next character?

I use only lualatex, but I suspect this is a general question, having something to do with core TeX. Is there such a thing as \ifnextcatcode ? Pseudo-code: \def\wanted{\ifnextcatcode{12}{\dothis}{\...
user avatar
2 votes
0 answers
35 views

How can I get exactly one space in .idx? I know how to get two or none, but not just one

Consider the following MWE: \documentclass{ltxdoc} \makeatletter \newcommand*\myindex[3]{% \doc@providetarget \index{#1:\levelchar#2\actualchar{\ttfamily#3}\doc@handleencap{usage}}% } \...
cfr's user avatar
  • 211k
2 votes
2 answers
72 views

Compute depth without using any macro

For a library robust-externalize, write in a new file something like: \newsavebox\boxRobExt% \savebox{\boxRobExt}{% my content }% \usebox{\boxRobExt}% % some code to write `\the\dp\boxRobExt` into ...
tobiasBora's user avatar
  • 9,116
1 vote
0 answers
259 views

Middle point in ConTeXt

In French, we sometimes use the middle point "·" as a way to write gender-neutral names (in the same spirit as the use of they/them pronouns in English), e.g : "Bonjour à tou·te·s"....
A. Licari-Guillaume's user avatar
9 votes
1 answer
357 views

Why can the name of a `MathOperator` have a number?

This does not compile, which is what I'd expect: \documentclass{amsart} \newcommand{\G2}{G_2} %\DeclareMathOperator{\G2}{G_2} \begin{document} \(\G2\) \end{document} produces ! LaTeX Error: Missing \...
LSpice's user avatar
  • 1,468
1 vote
1 answer
171 views

Resolving tikzcd/externalize/align incompatibilities

I've been trying to follow the insights from the following posts: Are the TikZ libraries cd and external incompatible with one another? How to avoid redefining ampersand & globally? Use & ...
DaftWullie's user avatar
0 votes
1 answer
44 views

Prevent active character from being expanded in macro argument

Goal: Have an active character not expanded when writing to file MWE \documentclass{article} \makeatletter % == Package code -- untouchable \def\foo{\@ifnextchar[{\@foo}{\@foo[x]}} \...
aker's user avatar
  • 15
3 votes
1 answer
297 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 \\...
Pavel Kirienko's user avatar
1 vote
1 answer
86 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?
Мақсат's user avatar
1 vote
2 answers
78 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}[...
MaestroGlanz's user avatar
  • 2,348
1 vote
3 answers
160 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 ...
Hugo Abreu's user avatar
1 vote
1 answer
86 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....
projetmbc's user avatar
  • 13.4k
0 votes
1 answer
67 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. ...
Long Horn's user avatar
  • 115
1 vote
2 answers
95 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'...
chrimbo's user avatar
  • 13
0 votes
2 answers
154 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}...
yegor256's user avatar
  • 12.3k
5 votes
4 answers
360 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 ...
Daniel Bandeira's user avatar
3 votes
2 answers
240 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 ...
yegor256's user avatar
  • 12.3k
4 votes
2 answers
239 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} \...
youthdoo's user avatar
  • 891
1 vote
1 answer
47 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 (...
mccurley's user avatar
  • 159
0 votes
1 answer
119 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 ...
texnically's user avatar
0 votes
1 answer
81 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 ...
yegor256's user avatar
  • 12.3k
3 votes
1 answer
114 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 ...
yegor256's user avatar
  • 12.3k
0 votes
2 answers
192 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 ...
Veak's user avatar
  • 1
2 votes
2 answers
72 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. ...
ashman's user avatar
  • 121
5 votes
2 answers
186 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{...
MGy's user avatar
  • 115
8 votes
5 answers
579 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\...
antshar's user avatar
  • 4,652
0 votes
2 answers
78 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 ...
user182849's user avatar
1 vote
2 answers
127 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 ...
btshepard's user avatar
  • 680
4 votes
3 answers
239 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 ...
btshepard's user avatar
  • 680
6 votes
3 answers
745 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 ...
btshepard's user avatar
  • 680
3 votes
1 answer
240 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 ...
bcsikos's user avatar
  • 869
6 votes
1 answer
344 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 ...
user32882's user avatar
  • 1,594

1
2 3 4 5
8