# Non-latin characters with plain TeX

What would it take to output non-latin letters (e.g. cyrillic letters) to a document using just plain TeX (i.e. without using "third-party" macro packages such as LaTeX)?

• Are we restricted to Knuth's (8-bit) TeX or can we use other engines? – Joseph Wright May 24 '14 at 7:32
• Related (/dup): tex.stackexchange.com/questions/163852/… – morbusg May 24 '14 at 7:44
• @JosephWright: currently, I am not very familiar with TeX engines and how they differ, so for me it would be best if you first consider simple, bare-bones engines. Depending on how much I like these solutions, I may or may not ask about other engines, too. – SJU May 24 '14 at 9:23
• @AngelTsankov Any modern system has pdfTeX, XeTeX and LuaTeX installed: the latter two are UTF-8 engines. – Joseph Wright May 24 '14 at 9:29

Unrecommended way: This is ancient history

This is the oldest approach I've used with some help of Latin transliteration and the AMS fonts, please see pages 15+ in http://mirrors.rit.edu/CTAN/fonts/amsfonts/doc/amsfndoc.pdf. I enclose a snippet for pdftex and a preview of the PDF file.

I was using fonts from the Wadalab project to typeset just several CJK characters. These days I would use xetex, luatex or context with UTF-8 coded input.

% run: tex or pdftex mal-non-latin.tex
\nopagenumbers
\input cyracc.def
\font\tencyr=wncyr10
\def\cyr{\tencyr\cyracc}
\cyr
Nezna\u\i ka --- literaturny\u\i\  personazh, opisyvayemy\u\i\  kak predstavitel\cprime\ plemeni malen\cprime kikh chelovechkov --- korotyshek, gero\u\i\ posvyashch\"enno\u\i\ ego priklyucheniyam trilogii Nikolaya Nosova i e\"e mnogochislennykh prodolzheni\u\i. Chlen Kluba ves\"elykh chelovechkov.
\par
\font\mjap=dmjhira \mjap
\char"15\char"48\char"06\char"2A\char"49
\bye


Update: This is one fast test of loading OTF files in the luatex engine.

\nopagenumbers
\def\mytest{This is a test. Това е тест.\par}
\font\myfont=FreeSerif.otf % a font from the GNU FreeFont family
\myfont\mytest
\font\myfont=LinLibertine_R.otf % a font from the Linux Libertine family
\myfont\mytest
\font\myfont=cmunrm.otf % a font from the Computer Modern family
\myfont\mytest
\bye


• Thanks, it work with Knuth's TeX ('tex mal-non-latin.tex')! A few more questions, though: 1) Why is it unrecommended? 2) You say this is the oldest approach you've used. Is there a newer one? – SJU May 24 '14 at 15:00
• @Angel If the engine fits you, that's a good news! To 1) We can solve almost anything in TeX, but we are limited when it gets to 8-bit version, e.g. font files can contain only 256 glyphs, there are 16 slots for I/O file operations only, handling calculations need extra care (try to compute factorial of 720)... If you try to solve some of the questions at TeX.SX you will notice you would prefer better tools/engines/packages than the TeX core. To 2) It depends what you are trying to solve, in general xetex+luatex+context are better engines for a usual TeXist and nowadays tasks in typography. – Malipivo May 24 '14 at 16:24
• @Malipivo: OK, I tried LuaTeX on This is a test Това е тест \bye but only got the latin text in the output. Is this a font issue, do I need to input a package or what? – SJU May 25 '14 at 7:33
• @AngelTsankov Please see the update. That example is not handling hyphenation, that would require some additional work. – Malipivo May 25 '14 at 8:18
• @Malipivo: I understand why you define mytest but do you really need to define myfont, as well? – SJU May 25 '14 at 8:30

You can be inspired by cyrchars.tex file from csplain package.

\input cyrchars

Normal text and текст на русском языке.

{\it Normal text in italics and текст на русском языке}.

{\bf Normal text in bold and текст на русском языке}.

\end


The cyrchars.tex macro uses encTeX for automatically font selection depending on the encoding. The pdfTeX is supposed, the format csplain or pdfcsplain is recommended. You can try the command pdfcsplain document.

For Plain TeX there are a series of fonts mapping to different 8bit encoding schemes for cyrillic, in the cmcyr fonts. Just make sure you use the same input and output 8bit encodings (koi8, cp1251, cp866 and iso8859-5 are available). By a similar procedure (setting up fonts in the right encoding) it would be easy to typeset modern Greek. A suitable set of fonts encoded as UNITYPE WINLANGUAGE is distributed in the cm-lgc fonts; adapting them to modern Greek, iso 8859-7 encoded, wouldn't be difficult, simply reencoding the font with afm2tfm.