Suppose person A writes a short bit of TeX code, and sends it to person B for inclusion as part of a larger document. The snippet written by A doesn't use anything fancy: no cross-references, citations, sectioning, footnotes, etc. etc. But it has math, of course, and minimal text formatting commands like bold, italics, enumerated lists, maybe tables, etc.

The problem is that A and B use different flavors of TeX. I believe that A uses Plain TeX and B uses LaTeX, then usually B can just paste A's code in and it will work, since most of the text-formatting commands in Plain TeX (e.g. {\bf bold}) are actually TeX primitives and hence also available in LaTeX even if not the "recommended" style.

If A uses LaTeX and B uses Plain TeX there is more of a problem, since for instance \textbf{bold} doesn't exist in Plain TeX. But of course in this case, B can just define a simple version of it herself. My question is whether I can save B this work? Where can I find a short, quick and dirty collection of macro definitions that a Plain TeX user can paste at the top of her document that will enable her to paste in simple fragments of LaTeX, using no more than basic text formatting commands and (say) list and tabular environments, and have them come out looking at least vaguely reasonable? Obviously if the LaTeX code uses anything fairly complicated, then there is no answer to this (short of pasting in or reimplementing all of LaTeX), but it seems that for very simple code it should be possible, and maybe someone has done it before.

  • For text formatting only, plnfss should work.
    – jarnosc
    Sep 14, 2017 at 22:20
  • @erreka The documentation of plnfss is not very helpful, but poking through the files I don't see any definitions of latex-like macros? Sep 14, 2017 at 22:28
  • Supported Commands \rmfamily \sffamily \ttfamily \mdseries \bfseries \upshape \itshape \slshape \scshape \normalfont \textrm \textsf \texttt \textmd \textbf \textup \textit \textsl \textsc \rm \sf \tt \md \bf \up \it \sl \sc What is missing?: - size commands: \large, \huge etc. Use \fontsize{20pt} instead. - scaling - math support is poor
    – jarnosc
    Sep 14, 2017 at 22:36
  • 4
    note \bf is not a tex primitive (and not defined by default in latex) so even using plain in latex is not always guaranteed. The other direction is just as hard as you want to make it, \mathbf is easy to define, an ams alignment less so. Sep 14, 2017 at 22:54
  • @DavidCarlisle -- since amsmath is derived from ams-tex there might be some hope there, but the thought of trying to implement tabular in plain tex strikes terror in me. there are some list-like features in ams-tex (roster), but no automatic numbering. i'm not familiar enough with eplain to know whether that holds promise. Sep 15, 2017 at 2:53

2 Answers 2


You can always just copy the definitions. The file miniltx.tex will help a bit (this already allows latex colour and graphics commands in plain, and defines some internal latex tools, but it does not help a lot with tabular. The file below adds tabular, just the basic version not extended versions from array package or tabularx etc, also I used \Lbegin and \Lend to avoid clashing with the \end primitive as used by \bye.

enter image description here

\input miniltx

\def\@ignoretrue {\global\let\if@ignore\iftrue}


    {\def\reserved@a{\@latex@error{Environment #1 undefined}\@eha}}%
     \csname #1\endcsname}}%
  \csname end#1\endcsname\@checkend{#1}%
      \reserved@a\@currenvir \else\@badend{#1}\fi}

\def\extracolsep#1{\tabskip #1\relax}
\def\array{\let\@acol\@arrayacol \let\@classz\@arrayclassz
\def\endtabular{\crcr\egroup\egroup $\egroup}
\expandafter \let \csname endtabular*\endcsname = \endtabular
\def\@tabular{\leavevmode \hbox \bgroup $\let\@acol\@tabacol
   \let\@classiv\@tabclassiv \let\\\@tabularcr\@tabarray}
  \if #1t\vtop \else \if#1b\vbox \else \vcenter \fi\fi
    \vrule \@height\arraystretch\ht\strutbox
           \@depth\arraystretch \dp\strutbox
    \ialign \noexpand\@halignto
      \bgroup \@arstrut \@preamble \tabskip\z@skip \cr}%
  \let\@startpbox\@@startpbox \let\@endpbox\@@endpbox
    \ifhmode \@preamerr\z@ \@@par\fi
  \ifnum0=`{\fi}${}\ifdim #1>\z@ \@xargarraycr{#1}\else
    \ifdim #1>\z@
\def\@xargarraycr#1{\@tempdima #1\advance\@tempdima \dp \@arstrutbox
   \vrule \@height\z@ \@depth\@tempdima \@width\z@ \cr}
\def\@yargarraycr#1{\cr\noalign{\vskip #1}}
  \@arstrut \@preamble\hbox{}\endgroup\ignorespaces}
\def\@xexnoop #1\@@{}
\def\@expast#1{\@xexpast #1*0x\@@}
       {\edef\reserved@a{\reserved@a#3}\advance\@tempcnta \m@ne}%
  \expandafter\reserved@b\reserved@a #4\@@}
    \edef\@preamble{\@preamble &}%
\def\@arrayacol{\edef\@preamble{\@preamble \hskip \arraycolsep}}
\def\@tabacol{\edef\@preamble{\@preamble \hskip \tabcolsep}}
\def\@ampacol{\@addamp \@acol}
  \expandafter\@tfor \expandafter
    \@nextchar \expandafter:\expandafter=\reserved@a\do
    \ifcase \@chclass \@classz \or \@classi \or \@classii \or \@classiii
      \or \@classiv \or\@classv \fi\@lastchclass\@chclass}%
  \ifcase \@lastchclass \@acol
      \or \or \@preamerr \@ne\or \@preamerr \tw@\or \or \@acol \fi}
\def\@arrayclassz{\ifcase \@lastchclass \@acolampacol \or \@ampacol \or
   \or \or \@addamp \or
   \@acolampacol \or \@firstampfalse \@acol \fi
  \ifcase \@chnum
     \hfil$\relax\@sharp$\hfil \or $\relax\@sharp$\hfil
    \or \hfil$\relax\@sharp$\fi}}
    \@addtopreamble{\hskip \doublerulesep}\@arrayrule
    \@addtopreamble{\hskip .5\arrayrulewidth}%
\def\@classiii{\ifcase \@lastchclass \@acolampacol \or
   \@addamp\@acol \or
   \or \or \@addamp \or
   \@acolampacol \or \@ampacol \fi}
\def\@addtopreamble#1{\edef\@preamble{\@preamble #1}}
\def\arraystretch{1}    % Default value.
\def\@arrayrule{\@addtopreamble{\hskip -.5\arrayrulewidth
   \vrule \@width \arrayrulewidth\hskip -.5\arrayrulewidth}}
\def\@testpach#1{\@chclass \ifnum \@lastchclass=\tw@ 4 \else
    \ifnum \@lastchclass=3 5 \else
     \z@ \if #1c\@chnum \z@ \else
                              \if #1l\@chnum \@ne \else
                              \if #1r\@chnum \tw@ \else
          \@chclass \if #1|\@ne \else
                    \if #1@\tw@ \else
                    \if #1p3 \else \z@ \@preamerr 0\fi
  \fi  \fi  \fi  \fi  \fi  \fi
  \noalign{\ifnum0=`}\fi\hrule \@height \arrayrulewidth \futurelet
\def\vline{\vrule \@width \arrayrulewidth}
  \loop\ifnum\@multicnt>\@ne \sp@n\repeat}

\def\@startpbox#1{\vtop\bgroup \setlength\hsize{#1}\@arrayparboxrestore}


\tabcolsep 6pt




  • Thanks! What about enumerate and itemize? Sep 15, 2017 at 10:16
  • @MikeShulman you do the same , add an itemize environment then add more and more code copied from latex.ltx until the undefined command errors go away but it's really not a good idea, by then you will have copied (literally) half the source of latex into a context where it's never been tested and it will sort of work in simple cases and fail in others and just using the same format for shared documents (hopefully a format that is designed for making documents not just a minimal format designed a a book example) makes much more sense. Sep 15, 2017 at 10:41
  • @MikeShulman you can input all of latex.ltx into plain tex and then use all of latex commands in plain if you really want to do that, I have a link.... tex.stackexchange.com/a/91050/1090 Sep 15, 2017 at 10:44
  • Okay. I had hoped that someone would have solved this problem already, at least for lists. Of course the latex list environments are doing all sorts of fancy things, but it seems like it should be straightforward to just translate them into some code that does nothing but prefix a bunch of lines by bullets or incremented numbers. Sep 15, 2017 at 15:47
  • 1
    @erreka easier still to use latex. Sep 18, 2017 at 17:58

This is how I interpret the remaining part of the question: you would like to paste something like the following text:

\item January
\item February
\item March

into a plain TeX document, and get something that vaguely looks like an enumerated list.

The following is one way to solve it.

First, look up how enumerated lists are input, in some macro package available in plain TeX (or implement your own). For example, this is how eplain does it:

\input eplain
\li January
\li February
\li March

eplain numberedlist

And this is how opmac does it:

\input opmac
\begitems \style n
* January
* February
* March

opmac begitems style n

Next, do whatever hacking is necessary to turn that LaTeX syntax into the corresponding plain-TeX-with-macros input. For example, using eplain (note my macros can probably be improved):

\input eplain
        % May want to implement error-checking here
        \message{Unsupported environment #1}

\item January
\item February
\item March

\item April
\item May
\item June


Here, we have pasted the LaTeX snippets \begin{enumerate} … \end{enumerate} and \begin{itemize} … \end{itemize} into a plain TeX document, and got reasonable lists in the output:

eplain plus hack

Of course you'll need to come up with similar definitions for every environment you use, and you'll need to do more hackery if you want to support more elaborate syntax like the optional arguments of enumerate and so on. But you said

For my purposes, I would be happy with an answer that could deal with both itemize and enumerate simultaneously in a very bare-bones way like that.

and this is certainly very bare-bones. :-)

  • Great; this is the sort of thing I wanted! Sep 20, 2017 at 6:01

You must log in to answer this question.

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