1

My setup: web2cTeX (TeX Live).
Consider xyz.tex:

\xordcode"27="0D
\tt '
\bye

and compile it with:

tex -ini -enc '\input plain \dump' # we need this for \xordcode to work
tex -fmt plain xyz.tex

I need to get ' here, but TeX produces empty result, because \xordcode makes TeX consider ' ("27) as ^M ("0D).

So, is there a way to change default \xordcode behavior so that it would only determine which character to take from corresponding font while actual typesetting, and not to try to influence other things?

Ideally, what I'm trying to acheive (in PlainTeX), is to produce \char"12 when I type ` (\char"60), and to produce \char"0D when I type ' (\char"27). If used with \tt, they will give proper ` and ', which I need, instead of default ‘ and ’.

10
  • ` is U+0060 and has catcode 12 in plain, so ` will typeset as \char"60` which is apparently what you want to happen. – David Carlisle Feb 28 '15 at 13:11
  • @David echo cmtt10 | tex '\input testfont \table \end'; xdvi testfont.dvi - In positions '140 and '47 you have ‘ and ’, don't you? – Igor Liferenko Feb 28 '15 at 13:19
  • Oh OK what I said is true but I see what you mean. Oh OK why use enctex for this rather than just {\tt \catcode`'\active \def'{\char"0D } .... 'foo'} – David Carlisle Feb 28 '15 at 14:38
  • @David Because I want ` and ' to keep their default properties. For example, for ' to work with constants (i.e., \char'39) it must have catcode 12, \char`\X must also work as before, etc. – Igor Liferenko Feb 28 '15 at 14:45
  • Yes but that is much easier to control using active characters which can be local to a specific macro rather thna enctex which is global to a file – David Carlisle Feb 28 '15 at 14:50
4

An example by using encTeX:

\mubyte\myquoteout '\endmubyte\def\myquoteout{\char"0D}
\mubyte\myquotein `\endmubyte\def\myquotein{\char"12}\mubytein=0
\let\oldtt\tt\def\tt{\mubytein=1\oldtt}
%
`test' {\tt `test'} `test'
\bye
1

TeX has no possibility to reencode during the expand processor state (this was my initial intent).

Two examples using active character:

\catcode`'\active\def'{\char"0D}\catcode`'=12
\catcode"60\active\def`{\char"12}\catcode"60=12
\let\oldtt\tt\def\tt{\catcode"60\active\catcode`'\active\oldtt}
%
`test' {\tt `test'} `test'
\bye
\def\adef#1{\catcode`#1=13 \begingroup \lccode`\~=`#1\lowercase{\endgroup\def~}}
\let\oldtt\tt\def\tt{\adef`{\char"12}\adef'{\char"0D}\oldtt}
%
`test' {\tt `test'} `test'
\bye

(adef macro is used in opmac.tex by Petr Olšák)

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.