# MWE using edmac

I am trying to evaluate the feasibility of using the plain package for building a volume one part of which is a critical edition set in plain tex using edmac, the other parts are more or less regular LaTeX. I am dealing here with an extremely complex setup, heritage code from the 1990s, whose creator has long died, but the other people on the project have kept using his system, producing a few volumes since then, and apparently they are not going to abandon it. The printed books do look great. The preceding volumes were built by first generating pdfs of the edition chapters, for each of which the starting number in the book needed to be set manually in the tex source, and these pdfs are then included by the main LaTeX file of the book. The TOC naturally has to be created manually, too. Of course it is possible to do like that again, but I would like to at least see if there's another, better, way. As I said, the thing is incredibly complex, involving a two-step pre-processing system, from input files in a custom Sanskrit encoding via a perl script to dn files for the devnag preprocessor which in the second step generates the tex source files, and a style-file providing an abstraction layer above edmac. While I was the technical person in charge of creating the last volume just using the old system, doing so was possible without an in-depth understanding of the plain tex used to create the edition. Having no other exposure to plain tex I am now struggling to create a MWE that I could then input in a LaTeX file, if that is at all possible, building an example with a real-world-file failed, I tried that of course.

\input edmac.doc

\beginnumbering
\pstart
\text{lemma}\Afootnote{note}\
\pend
\endnumbering

\bye


gives me

This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019) (preloaded format=pdftex)
restricted \write18 enabled.
entering extended mode
(./mini.tex (./edmac.doc
EDMAC Critical edition macros.
Revision: 3.7    < Date: 31 Aug 1993 15:57:20 >.
) Section 1 (./mini.1)
Runaway argument?
\Afootnote {note}\^^M\pend \endnumbering \par
! Forbidden control sequence found while scanning use of \text.
<inserted text>
\par
\bye
l.9 \bye


Probably some setup is missing, but maybe it's also a compatibility issue? I haven't found any other MWE yet, or, to start with, readable documentation. I did try the last example included in edmac.doc, as it was specifically for use with the devnag pre-processor, but it did not build, either.

Firstly, an answer to the question as asked. The short version is that \text is supposed to be terminated with /, not \.

### Explanation of error message

Note that the error message suggests "Runaway argument?", and that if you hit "H" it elaborates:

Runaway argument?
\Afootnote {note}\^^M\pend \endnumbering \par
! Forbidden control sequence found while scanning use of \text.
<inserted text>
\par
\bye
l.9 \bye

? H
I suspect you have forgotten a }', causing me
to read past where you wanted me to stop.
I'll try to recover; but if the error is serious,
you'd better type E' or X' now and fix your file.


Basically this means that the entirety of \Afootnote {note}\^^M\pend \endnumbering \par, and I think part of the \bye as well (this error was caught because \bye is declared \outer), was treated as an argument to \text (which was not your intention), suggesting that something is wrong with the invocation to \text.

### edmac documentation and MWE

The documentation for edmac is hard to find: texdoc edmac just shows a readme from 1996 encouraging you to buy the documentation as a printed book from TUG (with, I think, an out-of-date address). However, having heard somewhere about edmac/ledmac/reledmac, running texdoc reledmac is more useful, and shows a document that goes into history, and also mentions

‘An overview of edmac: a Plain TEX format for critical editions’, TUGboat 11 (1990), pp. 623–643

which is available here.

Following that documentation lets us prepare the following MWE (using examples from the document, with the name \afootnote updated to \Afootnote from the question):

\input edmac

\firstlinenum=1
\linenumincrement=1

% Some hacks for narrow columns. Not needed in real documents.
\vsize=20em
\hsize=15em
\hyphenpenalty=0
\exhyphenpenalty=0
\doublehyphendemerits=0
\finalhyphendemerits=0
\pretolerance=9999
\tolerance=9999
\emergencystretch=\maxdimen

\beginnumbering
\pstart This is a sample paragraph, with lines numbered automatically. \pend

The lines of this paragraph are not numbered.

\pstart And here the numbering begins again. \pend

\pstart
I saw my friend \text{Smith}\Afootnote{Jones C, D.}/ on Tuesday.
\pend

\bye


which results in:

generating pdfs of the edition chapters, for each of which the starting number in the book needed to be set manually in the tex source, and these pdfs are then included by the main LaTeX file of the book. The TOC naturally has to be created manually, too.

Note that this (manually specifying the starting page number of each chapter, and manually generating the table of contents) is also how Donald Knuth, the creator of TeX and the author of 25 books, also prepares many of his books. It's not so terrible, given that you probably prepare the table of contents of a book only once at the end. Automation is not always worth it, and it's useful to keep in mind a general framework for when to do so.

an extremely complex setup, heritage code from the 1990s, [...] producing a few volumes since then [...]. The printed books do look great. [...] I would like to at least see if there's another, better, way.

I have tried things in a similar spirit sometimes, and just be aware that this may end up being unsuccessful. See this classic article on rewriting software: that heritage code is "battle-scarred", having had to encounter a lot of weird situations and corner cases that you may not think about if trying to do it from scratch. It may end up being very difficult to produce a printed book that looks as great, which defeats the primary purpose of using TeX (beautiful books). Instead of throwing things away and trying to come up with a better solution from scratch, I'd recommend trying to start with the current setup and gradually removing things that are no longer needed, such as replacing the custom encoding / devnag preprocessor with something else (maybe a different script), but at all times comparing the "before" and "after" to make sure the output is not changed, or at least not compromised / made worse in any way.

Having no other exposure to plain tex

If you just want to quickly get up to speed with a useful mental model of plain TeX, I strongly recommend the book A Beginner's Book of TeX by Seroul and Levy. (See the recommendation by Hans Hagen in the ConTeXt manual.) Taking a couple of days or so may end up being worth it. But still, see the previous point.

MWE that I could then input in a LaTeX file, if that is at all possible

Note that ed-nfss.txt` (from 1994) says "In particular, EDMAC uses its own output routine, not LaTeX2e's, so lots and lots of stuff specific to the LaTeX output routine (like float placement) won't get executed", so (if this is still the case) inputting this into a LaTeX file may have surprising results.

• There has been a proposal to scan the TeXniques volumes and post these on the TUG website. I'll look into it. Also, I strongly second the recommendation for Seroul & Levy -- an excellent manual, one of the best! (The original, in French, by Seroul, was so good and well received that it was redone in English with Levy's cooperation.) Aug 20 '19 at 3:07
• Now I found the 1996 documentation for edmac 3.17. Aug 20 '19 at 4:24
• @barbarabeeton Oh I see, there was a TeXniques volume devoted to edmac... yes a scan of it might be interesting to anyone still trying to use it today for some historical reason / legacy code. (And thanks for the recommendation and history about the Seroul & Levy book; as you've probably read a lot of the manuals, your word means a lot!) Aug 20 '19 at 5:30
• @muk.li Ah cool, it also seems to be uploaded by one of the authors here. The TUG page has some related links, as of 2010. Aug 20 '19 at 5:43