# From LaTeX with pdflatex to plain TeX

I've always wanted to try plain TeX instead of LaTeX. I can use plain but I'm not able to use correctly the fonts and I'm not able to use the french hyphenation. I would to know how to do this with plain. Yes a lot of questions ! I work with MacTeX, it's perhaps important if I need to create a new format.

\documentclass{article} % It's not really important I can work without a class.
\usepackage[utf8]{inputenc} % is it possible to work with utf8 with TeX ?
%\usepackage[T1]{fontenc}
\usepackage[upright]{fourier} % or another font with T1 !
\usepackage[frenchb]{babel} % I need french hyphenation only !
\begin{document}

Bonjour

J'ai toujours voulu savoir comment écrire un document en français avec TeX.

\end{document}


Perhaps it's more interesting to have a solution with ConTeX ?

It would be interesting to have an answer with XeTeX, XelaTeX, LuaTeX and LuaLaTeX.

Plain TeX is really an example format rather than something for making documents in so you almost always have to load something to get a document usable setup (manmac, or eplain or amstex or your own macros) but anyway keeping to plain as far as possible.

\documentclass{article} % It's not really important I can work without a class.


Just do nothing, plain just starts off in typesetting mode. It doesn't have the analogue of LaTeX's preamble for setting things up at the start.

\usepackage[utf8]{inputenc} % is it possible to work with utf8 with TeX ?


It would be easier to just use LuaTeX or xetex, but in principle you just need to make characters 128-255 active and parse the next few characters to look up the Unicode number. ctan may have code to do this compatible with plain TeX already or latex's inputenc could be converted (or perhaps simpler) the utf8 reader in xmltex has essentially no dependencies on anything (xmltex can be loaded into initex)

%\usepackage[T1]{fontenc}


As you implied by commenting this out, plain doesn't have any notion of managing font encodings, if you use fonts with different encodings then it is up to you to switch any encoding dependent definitions at the same time, the format doesn't help.

\usepackage[upright]{fourier} % or another font with T1 !


As noted above, plain doesn't care about the encoding. If you stick

\expandafter\show\the\font


into your latex document it says

\T1/futs/m/n/10=select font futr8t.

so if you put

\font\tenrm=futr8t
\rm


into your plain TeX file you will get that font in 8t (aka T1) encoding.

\usepackage[frenchb]{babel} % I need french hyphenation only !


To switch languages you need \language2 or whatever value \language had when you input the french hyphenation table. But you can't input hyphenation tables into a standard tex, you need it to be run as initex and dump a new format. At this point you may want to switch to eplain at least as that has more language hyphenation tables dumped at format build time. But plan does explicitly allow you to customise the languages and hyphenation tables at format building time, almost the whole format is defined by the single file plain.tex except for hyphenation for which it does \input hyphen so if you have an English/French (or just French) hyphenation table setup in hyphen.tex at the time you make the plain tex format you can have French.

\end{document}


The plain tex for that is \bye

If you don't use utf8 and just want latin-1 input with T1 output then you can avoid worying about making multi-byte encodings work and it should all just work. When I cut and pasted your latex document it ended up in latin1 rather than utf8 anyway (not sure where the translation happened) so the following plain TeX document does give accented letters, both é and ç being typeset correctly.

\font\tenrm=futr8t
\rm

Bonjour

J'ai toujours voulu savoir comment écrire un document en français avec TeX.

\bye

• You may want to fix the \bye to \end{document}. – Yiannis Lazarides Apr 14 '12 at 13:44
• " you need it to be run as initex and dump a new format." Do you have a link to get explanations ? I never used initex so I need some informations to create a new format. – Alain Matthes Apr 15 '12 at 5:54
• initex used to be a separate program but now usually it's the same program with different options. So probably best if you say which distribution you are using. No one does this much anymore, used to have to do it every time latex was updated, but now of course almost everyone (including me:-) just uses texlive or miktex or some other ready packaged installation. – David Carlisle Apr 15 '12 at 9:27

With XeTeX and LuaTeX you don't need inputenc or fontenc, since all strings are assumed to be UTF-8 encoded by default. What you need though is to setup the fonts. If you don't mind cmr like fonts, I recommend you to install the CMUnicode fonts. To get instructions to set them up you may follow the directions given in this question, using the plain-cmu.tex file suggested by egreg.

XeLaTeX and LuaLaTeX require less effort, as the fontspec package takes care of setting up the font. You only need to declare

\usepackage{fontspec}
\setmainfont{CMU Serif}


after you install the fonts.

For Plain PDFTeX or (e)TeX, you may want to try the encTeX extension at format building time, saying

[PDF[e]]TeX -ini -enc [yourformatfile] \dump


You should need to setup the font encoding of the fonts you use, following the example from Russian explained here, but you may adapt it to French. Make sure you select the right fonts: Latin Modern or European Modern are the favorites.