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
2 votes
3 answers
161 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 } ...
zongpingding's user avatar
0 votes
1 answer
34 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
92 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
  • 699
0 votes
0 answers
70 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
146 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
381 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
  • 1,875
0 votes
1 answer
66 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
  • 1,875
1 vote
1 answer
111 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
  • 1,875
0 votes
2 answers
71 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
  • 1,875
0 votes
2 answers
68 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
5 votes
1 answer
119 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
  • 30.8k
9 votes
7 answers
575 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}{\...
rallg's user avatar
  • 2,051
2 votes
0 answers
31 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
  • 197k
2 votes
2 answers
68 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
  • 8,401
1 vote
0 answers
249 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
350 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,448
1 vote
1 answer
121 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
40 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
195 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
77 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
74 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
139 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
71 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.8k
0 votes
1 answer
60 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
82 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
129 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
  • 12k
5 votes
4 answers
345 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
225 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
  • 12k
4 votes
2 answers
193 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
  • 841
1 vote
1 answer
42 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
  • 139
0 votes
1 answer
103 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
74 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
  • 12k
3 votes
1 answer
98 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
  • 12k
0 votes
2 answers
133 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
71 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
177 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
549 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,218
0 votes
2 answers
64 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
107 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
234 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
661 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
224 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
301 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 vote
0 answers
47 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 ...
Shahryar's user avatar
  • 365
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 ¿ ...
Hasnain Shafqat's user avatar
1 vote
1 answer
54 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\...
user202729's user avatar
  • 6,963
0 votes
2 answers
133 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 \...
rlsx's user avatar
  • 19
2 votes
2 answers
52 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, ...
Jarl Øystein Samseth's user avatar
1 vote
1 answer
57 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{...
zetyty's user avatar
  • 769
3 votes
1 answer
213 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....
tobiasBora's user avatar
  • 8,401

1
2 3 4 5
7