30

In TeX, each of the 256 bytes has an associated \lccode and an \uccode, integers in the range [0,255] which indicate among other things how \lowercase and \uppercase act. There are of course a bunch of other numbers (mathcode, and catcode for instance), but I am focusing here on case-changing codes.

A look at the TeXbook tells me about the following uses of the \lccode and \uccode:

  • \lowercase <general text> turns each character token in the argument into a character token with the same category code, but a character code equal to the \lccode of the original character code, unless the \lccode is zero, in which case, the original character code is retained.

  • \uppercase <general text> behaves in the same way, using the \uccode instead.

  • When hyphenating, TeX takes whatever characters reached its stomach (so either from tokens with category code 11 or 12, or from chardef'd tokens, or char), and defines a "letter" to be a character with non-zero \lccode. A letter is lowercase if its \lccode is equal to its character code.

Is this all? In particular, does TeX use the \uccode for any purpose other than the \uppercase primitive? What about other engines, pdfTeX, XeTeX, and LuaTeX?

  • 1
    TeX uses also characters specified with \char or \chardef tokens when doing hyphenation (treating them if they were character tokens with category code 12); the relative \lccode should be nonzero, of course. – egreg Apr 6 '13 at 13:19
  • Thank you @egreg, I changed the claim here. In fact, my earlier statement made no sense, since there are no tokens anymore at this stage of processing. – Bruno Le Floch Apr 6 '13 at 13:24
  • 5
    A quick look at tex.web shows no particular usage of \uccode; there's only the \uchyph parameter to consider, again in connection with hyphenation: if the parameter's value is less than 1, words starting with an uppercase letter c (determined by uc_code(c)=c) won't be hyphenated. – egreg Apr 6 '13 at 13:29
  • The parenthesis in egreg's comment should read "(determined by lc_code(c)<>c and lc_code(c)<>0)", as explained in tex.web, or in Joseph's answer below. – Bruno Le Floch Jul 15 '14 at 16:13
8

The \lccode of a character is used in hyphenation when \uchyph is set to zero:

\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}

Notice that \uchyph is therefore misleadingly-named, as what is tested is whether the word starts with a lower case letter (one with \lccode equal to itself).

10

Letters inside of \patterns are mapped through \lccode. In fact, that's the only mechanism by which one can specify hyphenation patterns including - and/or 0-9 since writing them literally will have them interpreted as hyphenation priorities or hyphenation points.

hypht1.tex mentions this trick in the starting comment section.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.