Tagged Questions

{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.

learn more… | top users | synonyms

8
votes
2answers
135 views

Active space character without definition?

In the code below, why does the space character not produce an 'Undefined control sequence' error as the dot character does: \catcode` =\active \catcode`.=\active a b a.b \bye
0
votes
0answers
16 views

Macro that feeds its argument to an environment that changes the catcodes

Suppose an environment that reads its contents with changed catcodes (verbatim, CJK, etc). I want to write a macro that invokes this environment on its single apparent argument. The argument is ...
4
votes
1answer
78 views

Patch \insertshorttitle in beamer

In this answer @cfr showed me how to preserve short title color in beamer while allowing hyperlinks to work. His solution was to modify the \insertshorttitle command (defined in beamerbasetitle.sty) ...
3
votes
1answer
63 views

Active Delimiters to get correct delimiter size

I once read in "Die Texnische Komödie 1/2011" that it is possible to make the round delimiters () active, so you don´t need do use \left(\right) any more. The code is: \makeatletter ...
7
votes
2answers
111 views

Define a macro changing category code of number sign (namely \makenumbersignletter)

Under Typesetting hashtags with natural syntax Joseph Wrigh ask me to ask a new question: In LaTeX, \makeatletter is short for changing the category code of @. But something like ...
22
votes
5answers
721 views

Typesetting hashtags with natural syntax

I'm using an online conversation in my document and I've made an environment to use for it. The thing is, there are many #hashtags in each post (that I'd like to color appropriately). To make it ...
8
votes
1answer
79 views

Unwanted space in path for `\addbibresource`

I wanted to store a part of a path to a bib-file in a command. But if I run this example (neither the bib-file nor the bib-entry is needed to see the problem) I get an unwanted space in the path: ...
6
votes
1answer
36 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}{ ...
0
votes
3answers
106 views

Replace character defined by ASCII code (by something else)

I am trying to replace, in a given string, some characters. The characters to be replaced is given by its ASCII code. So for example, in abc, I want to replace character 97 (which is a, but I don't ...
1
vote
0answers
31 views

How to allow curly braces in command option

I need to store an URL parameter like &path=weigth:5|color:orange|enc:okydHa}peAXOHi@jANv@A@kJJmFAiDJuAHmDXcBb@cC`@gC^_DV}CJaCF{APaBVkBdAyEf@qC`@{B\aDSwB with later reencoding to utf8 and passing ...
6
votes
1answer
74 views

Redefine @ for tabular inter-column specification within \makeatletter \makeatother

I need to use a tabular with a @ inter-column specification within a \makeatletter and \makeatother environment. I. e. I something like \makeatletter %code that uses @ as letter ...
5
votes
1answer
92 views

How can I give active characters definitions with expl3?

It's very much glossed over in texdoc interface3… \documentclass{article} \usepackage{xparse} \ExplSyntaxOn \NewDocumentCommand \Digits { m m }{ \group_begin: \char_set_catcode_active:N ; ...
1
vote
1answer
45 views

gb4e breaks math subscripts in \caption

As @egreg notes in this answer to Can't compile XeLaTeX document with biblatex and gb4e together, the package gb4e makes _ and ^ active to be able to use subscripts and superscripts in ordinary ...
8
votes
2answers
254 views

Use a character other than the backslash for commands

I happen to author LaTeX code in an environment that makes entering the backslash tedious¹. Can I somehow tell LaTeX: From now on, treat, | (or another rarely used character) as if it were a \, so ...
3
votes
1answer
73 views

convert string to active character

in my book I will have to itemize a lot of things in different lists. That's why I want to reduce my commands to a minimum. This script is just part of a bigger macro. \documentclass{book} ...
6
votes
1answer
123 views

Active characters in linguistics

What are the pros and cons of using active characters instead of macros in text? Would it make sense to implement a “simplified markup” parser in Latex to make code more readable? Rationale ...
7
votes
1answer
144 views

Defining HTML-like tags as TeX macros

I have to admit, my catcode skill are not that good. I'm working with some templates that will be filled in by a programme (HTML::Template, made for HTML but very handy for LaTeX as well). I'd like ...
5
votes
3answers
79 views

catcodes vs. autonum

I'm trying to make certain equations with large amounts of special characters more readable by playing with catcodes. This works: \documentclass[12pt]{book} \begin{document} $$ \catcode`X\active ...
4
votes
0answers
64 views

\makeatletter within a beamer frame: how?

Within a beamer frame (not outside) makeatletter (or \catcode\@=11`) does not work. \documentclass{beamer} \makeatletter \def\my@command{My at command} \def\myatcommand{\my@command} \makeatother ...
7
votes
1answer
108 views

Unicode, right to left characters in command names

What is the status, in terms of category codes, of all the Unicode letters above ASCII in XeTeX (using XeLaTex+fontspec) and LuaTeX (using ConTeXt)? Can I define a macro using Unicode characters (ex. ...
5
votes
2answers
66 views

Reset an active character in \href

In my document, the symbol / is active. This leads to the problem with links. Instead of the slash they contain expansion of the slash. Wanted: http://aaa/ggg/ddd/ Got: ...
11
votes
2answers
113 views

Determine whether the first non-space character of #1 is a letter?

Let's say I have a class file with \title command, and I want to check that the title starts with a letter, and not with math or a number or a symbol. How can I do that? This is my MnWE, the syntax ...
11
votes
1answer
144 views

Is it reasonable to expect an expl3-compatible release of TikZ/PGF in the future? / Workarounds for using TikZ under expl3 syntax

Keeping in mind: TikZ uses space tokens significantly, and expl3 syntax completely disregards whitespace and will only become more prevalent, is it reasonable to expect a future version of TikZ ...
3
votes
1answer
45 views

Is there a way to provide a starred variant of a (xkeyval) boolean (class) option

I'd like to define, for a class I'm working on, two boolean keys rather similar and, instead of giving them different names, I'd like to let the latter be a starred variant of the former. Let me give ...
9
votes
2answers
208 views

Adding newlines while writing text to a file

Within a custom command, I'm doing the following to write to a file: \newcommand\mycommand[1]{ \newwrite\file \immediate\openout\file=foobar.tex \immediate\write\file{ foo bar #1 ...
10
votes
1answer
61 views

Is there some reason I can't change catcodes inside a command?

I have a very simple question. When I do this: \catcode`\@=0 \catcode`\\=11 @mycommand{a} @catcode`@\=0 \catcode`\@=11 It works perfectly and calls \mycommand correctly. However, when I try to ...
11
votes
1answer
128 views

Replacing # characters with luatex

The minimal example below should replace all # characters with another symbol. This works well if I use \# to escape it, but the user should later be able to enter it directly, e.g. to enter hash ...
14
votes
2answers
192 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 ...
1
vote
0answers
57 views

Would I use \catcode, tokens, or look outside of tex for a markdown-like parser solution?

My use case: a LaTeX template for courseware designed in a beamer presentation style. The template I'm designing is company-specific and the specificity of the company's presentation guidelines limits ...
7
votes
3answers
155 views

Trouble defining a macro that typesets underscore characters as _

I want to define a macro that typesets its argument in typewriter font and allows for underscore characters in its argument. Within a group, I make _ active, I define \_ to be typeset as an ...
8
votes
1answer
83 views

Modifying alltt

I want to create an environment which wraps alltt in such a way that the character ' is replaced by \textquotesingle wherever it occurs inside the environment but is as normal elsewhere. I have tried ...
9
votes
1answer
146 views

How can I create a better cryptogram environment?

I put together a macro that takes two arguments. The first argument is a string of letters which defines a cipher. The second argument is a message to be encrypted using this cipher. ...
10
votes
3answers
272 views

Read strings from file that contains the special character #

I need to read some values from data files as given in the sample code. The problem arises when the files contain # character. Then I get " ! Illegal parameter number in definition of \@xs@call " ...
6
votes
1answer
61 views

Scanning l3key with document catcodes?

Similar to the way TikZ attempts to use unknown keys as values for the color key, I would like to interpret an unknown key as the value for one of my own keys, decoration (not to be confused with the ...
5
votes
1answer
118 views

About catcodes and Family in LaTeX3/expl3

This is not so much the display of an issue or problem I'm facing out of my wish to use as much LaTeX3/expl3 as possible in my TeX-based work, as a request for advice on the proper ways in that ...
10
votes
1answer
249 views

Tweak with '%' (percent) symbol's catcode

I have the following code in my main.tex \catcode`\%=11 \immediate\write18{git log -1 --pretty=format:"%h%x3b%ad" --date=short > \jobname.info} \catcode`\%=14 which extracts the version ...
15
votes
1answer
222 views

Behavior of \\ in Plain TeX

According to \show, the pre-defined control sequence \\ is supposed expand to its argument without the suffix "pt": This is TeX, Version 3.1415926 (TeX Live 2012/Debian) **\show\\ > \\=macro: ...
5
votes
1answer
106 views

Active characters inside commands

I'm trying to ease my typesetting of phonetics with tipa by creating a custom command myipa which is supposed to substitute some common characters for the corresponding tipacodes. A much simplified ...
10
votes
2answers
323 views

Understanding LaTeX packages syntax

I've been using LaTeX for a few years for typesetting maths documents but I kind of feel there are two "kinds" of latex: the one I write my documents in and the one packages are written. My goal is ...
16
votes
3answers
281 views

Can I convert a string to catcode 11?

In the TeX FAQ there's a way to test if the jobname is equal to something (comparing the jobname). The difficulty of the naïve test is that the contents of the \jobname primitive are catcode 12 so to ...
4
votes
2answers
106 views

Test for a character, no matter if active or not (futurelet token)

I'd like to test for a character, irrespective its current catcode (i.e. active or not). This is very similar to How do I test for a character, irrespective of catcode?, however I cannot use ...
7
votes
1answer
94 views

Difference between 11 and 12 catcodes

I can only define commands, consisting of catcode-11 symbols or single catcode-12. What is the point of this limitation? It would be convient for me to define commands, that include following, not ...
3
votes
1answer
70 views

TeX document allowing any byte sequence being inserted

Out of a hacker's interest, I looked for a TeX document into which an arbitrary byte sequence can be inserted without causing the TeX process to fail, but had a similar issue; I basically set all ...
19
votes
2answers
448 views

Outright impossible TeX byte sequence

Out of a hacker's interest, I am wondering if there is any byte sequence that can never occur in any valid TeX document before \end is processed. I thought of things like {\catcode`}=9\catcode`\=9 ...
14
votes
1answer
510 views

When does TeX execute the \catcode=`\… assignment?

TeX always scans the input and converts it into some tokens, then expands some tokens according to the latest definition of that command ... stomach -> lists -> page but when does TeX execute the ...
22
votes
2answers
485 views

What is the differences between mathcode and catcode and how can I use mathcode?

The command \catcode is often used to change some internals. E.g. the command \makeatletter changes the catcode @. But what is \mathcode and how does it work? catcodes are well explained here: Wiki ...
4
votes
2answers
172 views

Inserting automatic vertical space between blocks when \obeylines is active

Sometimes as I write a manuscript in LaTeX for speaking, I want to format parts of it as \obeylines and \obeyspaces permit, so that a single coherent thought is expressed compactly on each line, and ...
3
votes
1answer
152 views

How to override TeX dollars?

I've read about \renewenvironment and \let commands but they are intended to work with classic commands TeX commands that start with a slash. And I cannot find any example of overriding $ and $$ any ...
4
votes
3answers
138 views

How can I typeset a bibkey with &?

I would like to typeset a catalog of all my BibTeX entries. I have been using & in many bibkey's such as Author&Editor:2000. But I cannot \catcode38=12 globally. My question is: how can I ...
7
votes
2answers
761 views

\makeatletter explained

I am using the following code in my beamer document to make the frame title's appear in the table of contents: \documentclass{beamer} \usetheme{default} \usepackage{bookmark} \usepackage{etoolbox} ...