{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

6
votes
1answer
857 views

\input only part of a file using catchfilebetweentags package

I would like to include only a part of a .tex file into a different .tex file. The part I want to include is delimited by some comment tags, as it is used by catchfilebetweentags package. I tried the ...
32
votes
2answers
783 views

No \makeatletter required?

In typing up some small examples that might create errors in LaTeX (for Documents with typical LaTeX errors), I tried the following: \documentclass{article} \def\my@macro#1{-#1-}% This is magic ...
8
votes
4answers
320 views

Having multiple commands with underscores and numbers that start with same text

Recently me and some friends really got into "making everything compilable". More specifically, we need to do a lot of matlab calculations, and then we need to put the results into a tex document. ...
4
votes
3answers
1k views

Replace chars with xstring. Catcode problem

I try to do something like this (minimal example): \documentclass[]{article} \usepackage{mathtools} \usepackage{xstring} \newcommand{\foo}[1]{ \StrSubstitute{#1}{:}{\string&}[\fooo] ...
3
votes
1answer
209 views

checking for whitespace inside verbatim environment

I would like to determine whether a line inside a verbatim environment starts with 3 spaces. I'm using pdflatex and the \pdfmatch primitive. I see that the verbatim environment sets the category ...
3
votes
1answer
127 views

Possible to use certain delimiters for macros with fancyvrb?

In this document: \documentclass{article} \usepackage{fancyvrb} \DefineVerbatimEnvironment{AVerb}{Verbatim}{commandchars=\\\{\}} \def\foo#1-#2;{} \begin{document} \begin{AVerb} \foo x-z; ...
3
votes
2answers
713 views

How listing and verbatim do to escape special character?

I use one macro to display text using texttt style. For the moment this macro is very basic. For example, if I want to use the character _, its catcode must be changed. Is there a clever way to ...
8
votes
3answers
827 views

Changing the catcode of _ in one command?

In the following code, I would like _ to be a simple letter. How can I achieve this ? % Source : http://forum.mathematex.net/latex-f6/forcer-le-retour-a-la-ligne-dans-texttt-t13246.html#p127511 ...
2
votes
1answer
312 views

A simple implementation of comment/verbatim: drawbacks?

While considering how to exclude \items in Yossi Farjoun's recently active question onlyitems? How to select specific items from an item list, I thought I would do what I proposed in my first answer: ...
8
votes
2answers
715 views

Change the behavior of carriage return

Define an enhance verse environment, where stroke Carriage return key once make a \\, twice make a \par, three times make a \medskip, four times and more make a \bigskip. An example would be: ...
29
votes
5answers
2k views

Using indentation to automatically begin and end itemize environments

This is a question one might answer with "Why the hell would you want to do it?!", sort of an experiment. What I am looking for is a way to write lists with many levels of nestings (notes for school) ...
2
votes
1answer
457 views

Potential problems from passing macro arguments to \verb

I've been working on a command that will typeset snippets of code within a paragraph. I'm aware of listings and company, but I want something that will just typeset the code verbatim and also allow ...
7
votes
1answer
549 views

string manipulation and catcodes

I want to detect whether an input line contains a certain substring, similar to the problem discussed here: Check if a string contains a given character The complicating problem is that the match ...
10
votes
1answer
242 views

Making a character active vs assigning it a specific catcode

My query arises from my answer to Tab not as extra alignment tab and Andrey's rather nicer version. The question at hand involved making the TAB character usable for aligning tables. I assigned it to ...
7
votes
1answer
171 views

Printing a character that has been made active in text and/or math mode?

I am not very familiar with TeX's category codes. If I use \catcode`\|=13 \renewcommand{|}{hello world} then every use of | in my document will be replaced by hello world. However, how would I be ...
12
votes
3answers
522 views

How do I test for a character, irrespective of catcode?

This came up from Labels in TikZ are incorrectly interpreted, but it's also something I've run into with the braids package, and a couple of other things I've done. Also, from looking at the TikZ ...
7
votes
2answers
419 views

Active characters after \begin{document}

I'm using XeLaTeX and I want to do automatic repeating of plus sign after breakline. I've found the unoffical package for this but it seems to me a bit overkill (although didn't try it). I tried to ...
4
votes
3answers
251 views

Why does a defined command appear differently in the align environment?

In the LaTeX document shown below, my definition \comp does not show correctly in the align environment. Why it is this the case? ========== Begin LaTeX scripts ============= ...
1
vote
0answers
215 views

How to use tikz matrix in a LaTeX command? [duplicate]

Possible Duplicate: Problem with defining shortcuts for TikZ matrices. I tried to use a tikz Matrix in a LaTeX document as the following: \documentclass{article} \usepackage{tikz} ...
3
votes
1answer
249 views

How to prevent \endlinechar=-1 from interfering a loaded EPS image?

I have to work in a block that begins with \endlinechar=-1\relax removing any space at the end of each line. After the \endlinechar=-1\relax, there will be codes related to loading an image ...
13
votes
3answers
718 views

How to get the catcode of a token?

For debugging a complicated macro I would like to print out the catcode of a token. Optimally I would like to have a macro \getcatcode such that, for example, \getcatcode{a} would expand to 10. How ...
2
votes
1answer
498 views

Scope of catcode change for escape character ?

In the following macro, I change the category code for the escape character (\) to "other" (12): \def\xxA{\begingroup \catcode`\\ = 12 \gdef\xxB ##1z{\tt ##1\endgroup} \xxB} How the heck does ...
11
votes
1answer
361 views

Is there a \show for catcodes?

In the course of attempting to out-pedant another mathematician, I wanted to \show the catcode of $ to convince myself that it was a "special" character in ordinary TeX as well as LaTeX. I was just ...
14
votes
2answers
367 views

Macro to take a character as argument, make it active, then \def it.

I have a XeLaTeX document in which I want some unicode symbols to be auto-substituted, like ¼ → 1/4, » → >>, « → <<. But instead of a long list like \catcode`\¼=\active\def¼{1/4} ...
5
votes
2answers
191 views

Changing catcode for commercial at (@) inside a macro to get it matched in pattern.

This question is related to TikZ: pgfutil-common: pgfutil@in@ - how does it work? and is a result of coping with that problem. I've already read How to change #catcode in a macro, but it didn't help ...
36
votes
4answers
2k views

What are category codes?

Following on from this question, I'd like to ask a more general question: What are category codes, and what can I achieve by changing them?
6
votes
1answer
1k views

Using tilde `~` in csname in Beamer

In beamer, I would like to be able to use the tilde character ~ in the name of a command sequence. I tried with adjusting catcodes. While this was successful with the standard article class, it failed ...
14
votes
1answer
704 views

How to change #catcode in a macro

I want to change the catcode in a macro, but it seems it doesn't work. Can anyone help me? \def\A{\catcode`\|=0 |bf{test}} |bf{test} would not work as expect.
20
votes
2answers
669 views

How bad is slack \makeatother discipline really?

Following Will Robertson's admission that Fwiw, i'm not aware of any troubles with a missing \makeatother, but you're right. It's a bad habit of mine to omit it, and my own progressive slackness about ...
2
votes
2answers
651 views

ignorespace and unskip in verbatim/listings?

I am writing a \bashDemo macro that will (a) execute its argument in a shell, e.g., bash, script, and (b) display the argument in a listings. So, \bashDemo ls -ls > myfiles \END will both run ls ...
4
votes
2answers
147 views

Command to display free-text answers from a survey, eliminating ascii control chars

I'd like to create a report from a survey with free-text answers that is collected in a database. For each question there are typically many answers which I could present in an itemize environment, ...
4
votes
2answers
208 views

Get tokens between two commands

I'm trying to create a screenplay-like class that uses a very simple syntax to create the dialogue, and dumps it as a plain text file for use in subtitles. To divide the subtitle sections I use &, ...
322
votes
1answer
47k views

What do \makeatletter and \makeatother do?

Many LaTeX “hacks” begin with \makeatletter and end with \makeatother. What do these commands do?
9
votes
4answers
660 views

How do I get the category code of a character that is the value of a control sequence?

How can I get the category code of a character that is the value of a control sequence? If I do this The catcode for A is \the\catcode`A. I get The catcode for A is 11. If I do this \let\abc=A ...
18
votes
4answers
3k views

How to make a real backslash (escape) character?

I just want a good way to make a backslash character (or whatever character(s) any given format uses as escape characters), suitable to \write to a file or pass to a pdfTeX primitive. Let me ...
40
votes
1answer
3k views

Is it \catcode or \catcode`?

I've noticed that \catcode is poorly documented in the TeXbook. The primitive is defined as \catcode but every time it is used, it is used as \catcode` ... the backquote is never discussed. ` itself ...
4
votes
2answers
497 views

How to test whether next token on input stream is catcode 10

Why doesn't the following code work? From a failed, now fixed, SO answer of mine: \documentclass{article} \usepackage{expl3} \ExplSyntaxOn \newcommand\latinabbrev[1]{ \peek_meaning:NTF . {% Same ...