olsak / tex-nutshell

TeX in a Nutshell -- A short document about TeX principles
4 stars 2 forks source link

\detokenize{\macro} expands to seven tokens, with the last a space token #4

Open muzimuzhi opened 1 year ago

muzimuzhi commented 1 year ago

On page 16, TeX in a Nutshell v0.9,

image https://github.com/olsak/tex-nutshell/blob/2ae3c848c1706c272ff1bcc90b17d85bd75abf7c/tex-nutshell/tex-nutshell.tex#L1344-L1350

But actually \detokenize{\macro} expands to seven, not six tokens, with the last one a space token.

From dd6691d2549af9abbcbfff2412e5d4bcc5237f95 Mon Sep 17 00:00:00 2001
From: Yukai Chou <muzimuzhi@gmail.com>
Date: Sun, 28 May 2023 06:03:38 +0800
Subject: [PATCH] Add missing space token

---
 tex-nutshell/tex-nutshell.tex | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tex-nutshell/tex-nutshell.tex b/tex-nutshell/tex-nutshell.tex
index e3f63ed..a74e114 100644
--- a/tex-nutshell/tex-nutshell.tex
+++ b/tex-nutshell/tex-nutshell.tex
@@ -1343,7 +1343,7 @@ If it is~a~Lua\TeX/ only command then three *** are prefixed.

   The `/<expandafters>.`\z`{|<text>};` syntax rule enables us to prepare \z`|<text>;` by
   `\expandafter`(s). For example \i detokenize `\detokenize{\macro}` expands to
-  `\`\c{12}`m`\c{12}`a`\c{12}`c`\c{12}`r`\c{12}`o`\c{12}. But if you need to detokenize
+  `\`\c{12}`m`\c{12}`a`\c{12}`c`\c{12}`r`\c{12}`o`\c{12}{\Blue\char9251}\c{10}. But if you need to detokenize
   the `<replacement text>` of the `\macro` then use
   `\detokenize\expandafter{\macro}`. Not only `\expandafter`s should be
   here. The expand processor does full expansion here until an opening brace 
-- 
2.40.1

Not sure if {\Blue\char9251}\c{10} is the write markup. The patch above introduces a bad box to be resolved. image

olsak commented 1 year ago

Thank you, I'll correct the example as you suggest.