1

Unfortunately, I've never used plain TeX so I have no idea how to use the language support in that format. How to connect babel for plain Xe/luaTeX (not Xe/LuaLaTeX)? More specifically, I am interested in support for Cyrillic based languages (ukrainian, russian) for plain TeX (with prefix Xe/lua).

% !TeX program = luatex

\input luaotfload.sty
\font\tenrm="Times New Roman"

\tenrm
\TeX --- мова розмітки даних спеціального призначення, 
яка є основним ядром системи набору публікацій (комп'ютерної 
верстки); зокрема для набору математичних та інших технічних
текстів. 

З самого початку \TeX став популярним серед математиків, фізиків, астрофізиків, астрономів, різних вчених-дослідників, яким бракувало необхідних символів на друкарських машинках, а якість документів, створених в інших системах, була незадовільною.

Ядро \TeX --- це інтерпретатор. Базові команди мови дуже низького рівня, але на їх основі можна створювати макрокоманди вищого рівня.
\bye

enter image description here

10
  • 1
    Once there was a reason for closure labeled “too broad”. This question would fit.
    – egreg
    Feb 15 at 18:46
  • 1
    texdoc babel and use LuaLaTeX will be a better approach.
    – yannisl
    Feb 15 at 18:48
  • 1
    @yannisl You're probably right. I'll have to rearrange it. Feb 15 at 19:06
  • 1
    You want: 1. Font selection,; 2. Language switching; 3. Different hyphenation rules. Too broad.
    – egreg
    Feb 15 at 19:59
  • 1
    @egreg I was able to connect the font (changed MWE), but now how do I connect the hyphenation? Feb 15 at 21:08

2 Answers 2

3

You've already figured out how to load fonts: input luaotfload.sty then use the \font command with the name of the font that you want to load. Cyrillic has a few characters that have different appearances depending on the language, so it's recommended to explicitly set the language used (although the Ukrainian/Russian variants are almost always the defaults anyways). You should also set tlig, otherwise --- and ``'' will appear as literal --- and ``'' instead of the expected and “”.

Setting the hyphenation patterns is comparatively easy: just \uselanguage{ukrainian}. This is documented in texdoc etex_src (which you would never find unless you knew to specifically look for).

But I think that that's all that's necessary for proper Ukrainian typesetting, unless there are some other requirements that I'm missing. (I don't speak any Cyrillic languages.)

%% Load the font
\input luaotfload.sty  % Lets us use otf/ttf fonts
% "language=ukr;+locl;" to make sure that we use the Ukranian glyph variants (which are almost always the default anyways)
% "tlig" makes "---" and "``quotes''" work as expected
\font\tenrm="CMU Serif Roman:language=ukr;+locl;+tlig" at 10pt
\tenrm  % Set the font

%% Set the hyphenation patterns
\uselanguage{ukrainian}

%% Set the page size (just for the demo, ignore)
\hsize=0pt
\overfullrule=0pt
\hoffset=-0.75in
\pagewidth=1.5in
\voffset=-0.75in
\vsize=6.5in
\pageheight=7in
\nopagenumbers

%% Demo text given in the question
\TeX --- мова розмітки даних спеціального призначення, яка є основним
ядром системи набору публікацій (комп'ютерної верстки); зокрема для
набору математичних та інших технічних текстів.

З самого початку \TeX став популярним серед математиків, фізиків,
астрофізиків, астрономів, різних вчених-дослідників, яким бракувало
необхідних символів на друкарських машинках, а якість документів,
створених в інших системах, була незадовільною.

Ядро \TeX --- це інтерпретатор. Базові команди мови дуже низького рівня,
але на їх основі можна створювати макрокоманди вищого рівня.

%% End
\bye

output

0

The clarification has evolved a little, so here's an example using pdflatex:

result

\documentclass[10pt,a4paper]{article}
\usepackage[T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[ukrainian,english]{babel}

\begin{document}
 
\TeX --- мова розмітки даних 
спеціального призначення, 
яка є основним ядром системи 
набору публікацій (комп'ютерної 
верстки); зокрема для набору 
математичних та інших технічних
текстів.  
\bigskip
 
\TeX~ is a special-purpose data markup language that is the main
core of a publication typesetting system (computer layout); in 
particular, for the typesetting of mathematical and other
technical texts. 
 
\end{document}

Though your situation remains hidden to me, i.e. I don't understand where you start and where you're heading along which route, I'd like to point you towards a site which sometimes seems to be useful.

https://www.phind.com is similar to ChatGPT, but designed for programming purposes. So here's a link to my cache with this sequence of prompts (queries); at least it's useful as a different kind of search engine, which neatly mentions its sources. Intended to be a starter for your own (improved) series of prompts.

  1. How do I obtain language support in tex, not latex, for ukrainian and english? give code examples
  2. How do I obtain language support in tex, not latex, for ukrainian and english? give code examples. AVOID commands \documentclass, \usepackage and similar.
  3. How do I create my own language definition file in plain TeX?

The first resulted in unwanted Latex code, like the following (without trying to compile it: we still must be aware of AI's halluzination effects of looking nice but being wrong)

\documentclass{article}
\usepackage[ukrainian,english]{babel}
\begin{document}
This is English text. \foreignlanguage{ukrainian}{Це український текст.} This is again English text.
\end{document}

The second was more interesting, giving some (generic?) example and a hint towards Xetex or LiaTex with polyglossia; don't know if this really will work:

% Define a new command to switch to Ukrainian
\def\switchtolatin{\language=0 }
\def\switchtoukrainian{\language=1 }

% Define the language number for English and Ukrainian
\language=0

% Start the document
\switchtolatin
This is English text.
\switchtoukrainian
Це український текст.
\switchtolatin
This is English text again.

% End the document
\bye

The third one, a follow-up proposed by phind, talks a bit about .ldf files , leaving out useful text,

% Define the character encoding for Ukrainian
\catcode`й=1
\catcode`ї=1
...

% Define hyphenation patterns for Ukrainian
\patterns{ukrainian}
\hyphenation{
  при-в-и-ту-м % Example hyphenation pattern
  ...
}

% Define language-specific settings
% For example, you might define the opening and closing quotation marks
\def\"{\cyrdq}
\def\`{\cyra}
...

% Save this in a file named ukrainian.tex

and its use:

% To use this language definition in your TeX document, you would include it using the \input command:

\input{ukrainian.tex}

% Now you can use Ukrainian characters and hyphenation
Привіт! Це простий текст на українській мові.

Next prompts might look into e.g. generalization, as you probably want rules for hyphenations rather than listing all words you have in your dictionary.

Hope this puts you on a fruitful track exploiting phind, this place, google and what have you.

E.g. open a new phind-window and prompt e.g. "explain to me .ldf files used in plain tex", which at least guides you to Installing a .LDF language file. Ok, you've got the concept.

5
  • 1
    The question is about not using LaTeX
    – egreg
    Feb 15 at 19:58
  • Right, but TeX was excluded as far as I read ...
    – MS-SPO
    Feb 15 at 19:59
  • @MS-SPO I have been using LuaLaTeX for quite a long time, but I have no idea how to work with plain TeX and how to connect language support there. That's why this question has arisen. Feb 15 at 20:56
  • @sergiokapone, thank you, I somehow understood that. Wasn‘t this an agreement, TeX is out tex.stackexchange.com/questions/709700/…? However, do I get it right you have many TeX files in Ukrainian and want to add English? Would a split approach work for you, e.g compile TeX parts separately AND include those pdfs in some LaTeX dialect?
    – MS-SPO
    Feb 15 at 21:39
  • @sergiokapone, I added some pointers for you to my answer.
    – MS-SPO
    Feb 15 at 23:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .