Questions tagged [detokenize]

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

Filter by
Sorted by
Tagged with
0 votes
0 answers
41 views

Detokenize input to \newcommand

I would like to define a command that removes .m when referencing to the caption generate_simdata.m (i have a lot of such matlab function files, and would like to reference them normally with \nameref ...
user avatar
0 votes
2 answers
34 views

Escaping LaTeX tokens in addresses for printing one label printer that can cut

I am trying to print addresslabels on a Brother_QL_820NWB, which is a label printer, that can cut the paper. I have a small script, that gathers the address data from user input and than calls my ...
user avatar
  • 51
2 votes
0 answers
50 views

Mintinline in Tabularx / remove space in detokenize

I write a LaTeX manual in memoir class with the Minted package, TeXlive 2021 and TeXmaker. To insert some \mintinline code in a Tabularx X-type column, I used this trick and it work. Except that it ...
user avatar
2 votes
1 answer
79 views

How do I detokenize '\texttt{%>%}'

I have a command: \newcommand{\help}[2]{ \href{https://www.rdocumentation.org/packages/#1/functions/#2}{\texttt{?\detokenize{#2}}} } and another \newcommand{\code}[1]{\texttt{\detokenize{#1}}} ...
user avatar
  • 159
0 votes
2 answers
64 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. \...
user avatar
  • 184
2 votes
1 answer
75 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 ...
user avatar
  • 581
1 vote
2 answers
92 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 \...
user avatar
  • 10.7k
2 votes
1 answer
91 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 ...
user avatar
2 votes
1 answer
84 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 ...
user avatar
5 votes
2 answers
253 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 ...
user avatar
7 votes
4 answers
504 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. ...
user avatar
  • 73
2 votes
2 answers
322 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 ...
user avatar
2 votes
2 answers
231 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 ...
user avatar
  • 123
2 votes
1 answer
411 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: ...
user avatar
  • 10.8k
2 votes
1 answer
699 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 ...
user avatar
  • 847
2 votes
1 answer
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 \...
user avatar
  • 1,001
3 votes
1 answer
303 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 ...
user avatar
  • 969
4 votes
1 answer
170 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....
user avatar
4 votes
1 answer
155 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% ...
user avatar
  • 41
6 votes
2 answers
708 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 ...
user avatar
1 vote
1 answer
194 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 ...
user avatar
  • 481
2 votes
2 answers
188 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 ...
user avatar
5 votes
2 answers
623 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 ...
user avatar
0 votes
1 answer
185 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 ...
user avatar
  • 319
3 votes
2 answers
247 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 ...
user avatar
9 votes
1 answer
294 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 ...
user avatar
  • 581
3 votes
1 answer
94 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{...
user avatar
  • 48.8k
7 votes
2 answers
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}...
user avatar
2 votes
2 answers
144 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? ...
user avatar
  • 206
12 votes
1 answer
345 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 \...
user avatar
  • 3,426
7 votes
1 answer
987 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 _....
user avatar
11 votes
2 answers
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: \...
user avatar
4 votes
1 answer
351 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}} \...
user avatar
7 votes
1 answer
740 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 ...
user avatar
  • 7,757
16 votes
2 answers
3k 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 \...
user avatar
3 votes
2 answers
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 ...
user avatar
  • 11.4k
43 votes
2 answers
14k 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 (...
user avatar
  • 7,811