Questions tagged [detokenize]

The e-TeX primitive `\detokenize`, which removes special meaning from TeX code.

Filter by
Sorted by
Tagged with
2
votes
1answer
41 views

Hyphenate word with detokenized underscores

I want to write clean underscores without backslashes and hyphenate words by underscores. I tried to use underscore package, but it doesn't work with clean underscores and also breaks ...
2
votes
1answer
37 views

Seqsplit with detokenize get an error

I want to write some words with underscores inside table cells. It would be better if these words could be written without using \_ to get underscore. Also I want to make these word hyphenate in any ...
3
votes
1answer
59 views

Alternative to detokenize working with special unicode characters

I have defined new command using \NewDocumentCommand which represents description of node in graph. This contains name (provided as argument), some text description (provided as argument) and links to ...
6
votes
4answers
204 views

Expand multiple math-tokens before detokenize

I am a long time Latex user and over the last few weeks I am involved in a project that needs to do the following: I want to put in verbatim some math latex code that may include user-defined macros. ...
2
votes
2answers
125 views

Change size of underscore in detokenize

My question is closely related to this one. The solution there works fine for text, but here is my scenario. I want to typeset the names of all packages specially, so it is clear what I refer to. For ...
2
votes
2answers
176 views

How to perform a replacement on a string before doing a \write?

I'd like to output LaTeX code to a file, with the caveat that all backslashes are doubled (ie, \ is replaced with \\). This output will be consumed by another program. I've adapted egreg's answer ...
2
votes
1answer
282 views

Hyphenation after _ underscore in an detokenized string

Context: In my document, I use a citation mechanism for personal references. I defined a \citeref{} macro that processes a comma-separated list of arguments. The latter have following structure: ...
2
votes
1answer
203 views

Automatic Labels with automatically generated keys

I am writing a collection of documents in book form, one each for 4-5 topics. Each book has upwards of 30 chapters each in a different file. The books must be able to cross reference each other since ...
2
votes
1answer
581 views

Special cents notation in currency

I made a code that has a special way to write the cents. Here's a MWE: \documentclass{article} \usepackage{graphicx} \makeatletter \newif\if@thecomma \def\normal@comma{,} { \catcode`\,=\active \...
3
votes
1answer
274 views

Detokenize does not produce the expected underscores

I have a Knitr document where I sometimes have to escape underscores. The underscores are actually part of the original data, get loaded in R, and at some point knitted into the LaTeX code, so ...
4
votes
1answer
118 views

omit spaces inside macro

I'm trying to understand why I can get LaTeX to ignore spaces inside text, but when I do the same thing inside a macro, it fails to ignore those spaces. I use \catcode32=9 to ignore ASCII space chars....
4
votes
1answer
98 views

Exception for detokenize

following problem: \openin\inputfile=#1% \loop% \read\inputfile to \readline% \unless\ifeof\inputfile% \global\edef\filecontent{\filecontent\readline^^J}% \repeat% \closein\inputfile% ...
6
votes
2answers
301 views

How can I check if the value of a variable is the same as what another variable?

My question is simple but I don't know any simple solution for it. I have an unknown variable namely \unknown and a variable which I want to compare \unknown with it, namely \test. I want a command ...
1
vote
1answer
132 views

Expand argument for detokenize while creating index

After reading this answer https://tex.stackexchange.com/a/292362/64189, i'm trying to use it for my index. \newcommand{\ukindex}[2][\imki@jobname]{% \index[#1]{\detokenize{#2}}% } But i need to ...
2
votes
1answer
121 views

How to obtain the string é by using the \detokenize command?

I failed to use "\include" with a file that contain the string "é" in its name like "réserve". so I tried the following without success \include{\detokenize{réserve}} After some trials I have ...
5
votes
2answers
396 views

Why does \detokenize # sometimes fail inside of environments?

When I use the pound sign/number sign/hash sign # inside of commands and environments, this refers to arguments. However, shouldn't \detokenize{#} make it NOT an argument? Situation The pound sign ...
0
votes
1answer
126 views

Breaking Typewriter-styled Detokenized Text

The goal is to have snake_cased elements typewriter-styled breaking properly. I am using \detokenize rather than simply \_ because otherwise the snake_casing looks wrong, namely like this: rather ...
3
votes
2answers
163 views

Use of mfirstuc with catcode 12 characters

I am trying to have my document read its own filename (which is known to be words and numbers separated by hyphens) and parse it. For everything after a certain hyphen, I want to replace the hyphens ...
9
votes
1answer
263 views

Somewhat versatile usage of \@gobble and \@firstofone found in several macros

I was doing search about my question (see here for more detail) and found a thread commath and \ifinner. In the thread, there is a macro named \spx , the definition and usage of which are extracted ...
3
votes
1answer
78 views

Surprising result with “fontenc” when \detokenize is applied to `-`

Whether \detokenize is applied to - or -- under the fontenc package T1 fonts the results are the same. \documentclass[border=10pt]{standalone} \usepackage[T1]{fontenc} \usepackage{lmodern} \begin{...
6
votes
2answers
878 views

How to typeset the percent symbol inside \detokenize?

I am writing some personal notes about R programming. I defined a macro to typeset R functions and operators using a different font style and color: \newcommand{\rtext}[1]{% {\texttt{\detokenize{#1}...
2
votes
2answers
132 views

Expand \def value from optional default argument? - Bug in \oldacronym (glossaries v4.02) - first use not respected and funny effects? [closed]

Edit: Bug only in glossaries v4.02. -> Update! \edef\args{[#4]{#1}{#2}{#3}}% \expandafter\newacronym\args% may be a way to expand unexpaned args. Is there a bug in the glossaries Package? ...
12
votes
1answer
288 views

What could go wrong if I don't use \detokenize when creating macro names using macro arguments?

I was in correspondence with the author of a LaTeX package in which I volunteered code similar to the following (I have anonymised it so that it is not obvious what package): \makeatletter \...
6
votes
1answer
709 views

Strange behaviour with \detokenize and underscore

I just learned about \detokenize, so this question is likely a naive one. Nonetheless, based on what I thought that I understood about \detokenize, I would have expected \detokenize{_} to render as _....
10
votes
2answers
2k views

Use detokenize with command line input that has underscores

I'm calling a script where I give a command line input to LaTeX: pdflatex "\def\myvar{given_test} \input{figures.tex}" And then in the script, I try to use this "given_test" input and print it: \...
4
votes
1answer
318 views

The command \string does not print curly braces of its argument

While printing the List of Symbols, I would like, in a draft, to print the definition commands as well. For instance, consider the following commands: \providecommand{\perm}{\ensuremath{\pi}} \...
8
votes
1answer
663 views

Can I use \begingroup \endgroup as delimiter of \detokenize, instead of {}?

I would like to use other delimiters than {} for the argument of \detokenize. E.g. something like \detokenize\begingroup a lot of stuff \com \mycom \endgroup but it does not work. Am I really ...
16
votes
2answers
2k views

Removing a backslash from a character sequence

For indexing I wanted to write a macro \macroname that removes leading backslashes from macro names but leaves the names of environments untouched. That is \macroname{\relax} --> relax \...
3
votes
2answers
1k 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 ...
37
votes
2answers
9k views

What are the exact semantics of \detokenize?

How does \detokenize work? The e-TeX Short Reference Manual states: When followed by a <general text>, expands to yield a sequence of character tokens of \catcode 10 (space) or 12 (...