0

Here is an error from latexml (installed with brew install latexml on OS X):

$ latexml --dest tmp/book.xml main.tex
latexml (LaTeXML version 0.8.5)
processing started Thu Aug 26 13:19:17 2021

(Digesting TeX main... (Loading /usr/local/Cellar/latexml/0.8.5/libexec/lib/perl5/LaTeXML/Package/TeX.pool.ltxml... (Loading /usr/local/Cellar/latexml/0.8.5/libexec/lib/perl5/LaTeXML/Package/eTeX.pool.ltxml... 0.00 sec) (Loading /usr/local/Cellar/latexml/0.8.5/libexec/lib/perl5/LaTeXML/Package/pdfTeX.pool.ltxml... 0.01 sec) 0.14 sec) (Processing content .../main.tex... Error:undefined:\include The token T_CS[\include] is not defined. at main.tex; line 4 col 8 - line 4 col 8 Defining it now as <ltx:ERROR/> ...

I believe the include directive is LaTeX.

This is a book, so there are 20 files or so that are put together in a certain order by main.tex. The book compiles just fine on overleaf.

EDIT: Here is a simplified version of main.tex:

\include{preamble}
% more preamble files "include"-d here.
\begin{document}

\frontmatter

\input{titlepage} % more frontmatter files here ...

\tableofcontents

\mainmatter

\input{chapter01n} % more chapter files here ...

\appendix \appendixpage \addappheadtotoc

\input{appendixA} % more appendix files here ...

\end{document}

The preamble has lots of \usepackage and \newcommand and such. The first statement in the preamble (actually called aprogpre2.tex) is:

\documentclass[reqno,10pt,english]{book}
dfrankow
  • 233
  • David Carlisle has given the correct answer in that it's an error to have \include before the document begins. The reason this breaks gave an error is that LaTeXML starts out assuming TeX input, and switches over to LaTeX when it sees a handful of LaTeX specific commands. \include is not one of those commands. – Teepeemm Jan 24 '24 at 03:08

1 Answers1

2

You did not provide a test file but it appears that you had a file like

\include{sample2e}
\documentclass{article}
\begin{document}
aabb
\end{document}

LaTeXML gives the error you show if \include is before \documentclass

Error:undefined:\include The token T_CS[\include] is not defined.
        at lm1.tex; line 1 col 8 - line 1 col 8
        Defining it now as <ltx:ERROR/>
        Next token is T_BEGIN[{]
        In Core::Gullet[@0x5597b66acc18] /home/david/lm1.tex; from line 1 col 9 to line 1 col 9
         <= Core::Stomach[@0x5597b6862870] <= ...

It gives a slightly different error if \include is used in the preamble, between \documentclass and \begin{docuemnt}.

\include only works correctly if used in the main document, after \begin{document} Unfortunately standard latex processing does not give an error (it just silently does the wrong thing). So the solution assuming this is the issue would be to fix the source document, probably by changing \include to \input.

David Carlisle
  • 757,742
  • Perfect, thank you! I changed \include to \input, and this works. The preamble is being included as a separate file. – dfrankow Aug 27 '21 at 18:10
  • but why before \documentclass ? (at least I assume it is before documentclass, your question shows no relevant code) @dfrankow – David Carlisle Aug 27 '21 at 19:08
  • No reason. I inherited this latex book, and I'm trying to make an ebook out of it. I can do some latex, but I don't understand the intricacies. I added a simplified version of the book above. – dfrankow Aug 27 '21 at 20:57
  • @dfrankow Ok as I say \include there is wrong in latex as well (and doesn't work in general) it just accidentally fails to give an error. – David Carlisle Aug 27 '21 at 23:31
  • Yep. It works on overleaf, but not in latexml. Changing it to \input works everywhere, so that's the thing to do. – dfrankow Aug 28 '21 at 21:58
  • @dfrankow no it doesn't really work in tex (overleaf) either: it just doesn't give an error message, In general it breaks the aux file handling, if you are lucky it may seem to work with tex but any output is accidental not by design. – David Carlisle Aug 28 '21 at 22:27