- Am I right that MikTeX sources in C++ contain the code that opens .tex file (when I run
latex.exe myfile.tex
), reads it, parses commands, performs them if they are correct and logs error messages otherwise? - And the TeX/LaTeX syntax is 'mounted' into these sources as well?
- For example, a LaTeX document must start with
\documentclass
command. Is this syntax requirement maintained somewhere in the ะก++ sources directly?
[Tex/LaTex] MikTeX sources and LaTeX language
latex3miktexsourcesyntaxtex-core
Best Answer
MikTeX, like texlive includes an implementation tex-the-program largely automatically converted from the original WEB (Pascal) source to C, suplemented by additional C as needed. You can browse the sources at
https://miktex.org/sources
LaTeX is a program written in TeX and then processed with a suitable TeX executable so pdflatex, latex, lualatex, xelatex, etc are essentially the same latex source code processed with pdftex, etex, luahbtex, xetex respectively.
You can see the documented source of latex with
texdoc source2e
and the extracted run time tex file that is used to make the latex formats will be installed in your tex tree as<texmf-root>/tex/latex/base/latex.ltx
So for example the command you mention,
\documentclass
is defined in that file byand the constraint that there must be exactly one is also implemented in TeX macros. As shown above, after the first use,
\documentclass
redefines itself to be\@twoclasseserror
which will generate an error if used. Conversely, elsewhere in the file you will findWhich will generate an error if a paragraph of text is started before the
\begin{document}
and\begin{document}
checks that at least\normalfont
is defined as a check that a document class has been specified.