0

The task is to identify latex main files to write a maven plugin processing latex files (conversion into various formats).

Currently, I identify the main file with the pattern

.*\\begin\s*\{document\}.*

but this is wrong. What about

\s*\\documentclass.*

? This would mean that apart from blanks, \documentclass must be the very beginning of the file.

I remember that there was a second possibility: \documentstyle?

  • 4
    \documentclass doesn't need to be the first command. There could be \RequirePackage or definitions before. Also while nowadays normally every LaTeX file has a \documentclass, a main file could also consist simply of an \input{real-main-file}. – Ulrike Fischer Oct 25 '16 at 09:26
  • In the meantime I found http://tex.stackexchange.com/questions/35855/placing-items-before-documentclass. – user2609605 Dec 05 '16 at 09:52
  • Well, you should check for a \documentclass or \begin{document}, but following any \input provided, so that you can't miss it. How detailed do you want your check? A latex main file means you would also have to check that this is not pdflatex, xelatex or lualatex (check for eventually enhanced features). – TeXnician Jul 04 '17 at 06:39

0 Answers0