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?

3
  • 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}. Oct 25, 2016 at 9:26
  • In the meantime I found tex.stackexchange.com/questions/35855/…. Dec 5, 2016 at 9: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 4, 2017 at 6:39

0

You must log in to answer this question.

Browse other questions tagged .