lccode 和 uccode 有何用途?

lccode 和 uccode 有何用途?

在 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在起始評論部分提到了這個技巧。

相關內容