Questions tagged [detokenize]
The e-TeX primitive `\detokenize`, which removes special meaning from TeX code.
33
questions
0
votes
2answers
38 views
Reduce the length of underscore inside detokenize
Like this question
But because many of my keywords has underscore, I created a macro called \keyword with \detokenize to make things easy. However, it makes underscore become longer again.
\...
2
votes
1answer
29 views
Using \detokenize and underscore in combination with \listoffigures
I've been using a macro X similar to
\newcommand{\X}[1]{{\ttfamily{\detokenize{#1}}}}
to format certain words that may contain an underscore, without having to escape with \_.
This worked until I ...
1
vote
2answers
72 views
detokenize only active character
Few year ago, I asked a question about the best way to make active character inactive, in order to solve an issue with reledmac.
inputenc, active catcode and \csnsame
The answer was to use \...
2
votes
1answer
74 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
60 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 ...
5
votes
2answers
176 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 ...
7
votes
4answers
359 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
214 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
215 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
381 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
447 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
2k 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
293 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
152 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
133 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
519 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
168 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
2answers
161 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
509 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
160 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
214 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
277 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
87 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{...
7
votes
2answers
1k 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
143 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
323 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
884 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 _....
11
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
333 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}}
\...
7
votes
1answer
704 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 ...
40
votes
2answers
12k 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 (...