在 TeX 中,256 個位元組中的每一個都有一個關聯的\lccode
, 和\uccode
[0,255] 範圍內的整數,它們除其他外指示如何\lowercase
和\uppercase
動作。當然還有很多其他數字(例如數學代碼和貓代碼),但我在這裡關注的是大小寫更改代碼。
透過查看 TeXbook,我了解了 和 的以下\lccode
用途\uccode
:
\lowercase
<general text>
將參數中的每個字元標記轉換為具有相同類別代碼的字元標記,但字元代碼等於\lccode
原始字元代碼,除非 為零\lccode
,在這種情況下,保留原始字元代碼。\uppercase
<general text>
行為方式相同,但使用\uccode
代替。當連字符連接時,TeX 會採用任何到達其胃部的字符(因此要么來自類別代碼 11 或 12 的標記,要么來自 chardef'd 標記或 char),並將“字母”定義為非零的字符
\lccode
。如果字母\lccode
等於其字元代碼,則該字母為小寫。
這就是全部嗎?特別是,TeX 是否將 用作原語\uccode
以外的任何目的\uppercase
?其他引擎,pdfTeX、XeTeX 和 LuaTeX 怎麼樣?
答案1
當設定為零時,字元的\lccode
被用於連字符:\uchyph
\documentclass{article}
\begin{document}
\uchyph=0 %
\begingroup
\lccode`\C=`\C
Some filler text.
Some filler text.
Some filler text.
Some filler text.
Capitalised word.
\par
\endgroup
\begingroup
\lccode`\C=`\c
Some filler text.
Some filler text.
Some filler text.
Some filler text.
Capitalised word.
\par
\endgroup
\begingroup
\uccode`\C=`\C
Some filler text.
Some filler text.
Some filler text.
Some filler text.
Capitalised word.
\par
\endgroup
\begingroup
\uccode`\C=`\c
Some filler text.
Some filler text.
Some filler text.
Some filler text.
Capitalised word.
\par
\endgroup
\end{document}
請注意,它的\uchyph
命名具有誤導性,因為測試的是該單字是否以小寫字母開頭(與其\lccode
自身相等)。
答案2
裡面的字母\patterns
通過 映射\lccode
。事實上,這是可以指定連字符模式(包括 - 和/或 0-9)的唯一機制,因為按字面書寫它們會將它們解釋為連字符優先級或連字符點。
hypht1.tex
在起始評論部分提到了這個技巧。