How does the file command distinguish text and LaTeX files?

The file type recognition is driven by so-called magic patterns. The magic file for analyzing TeX family source code contains a number of macro names that cause a file to be classified as LaTeX. Each match is assigned a strength, e. g. 15 in case of \begin and 18 for \chapter. This makes the heuristic more robust against false positives like misclassification of Plain TeX or ConTeXt documents that happen to define their own macros with those names.


I found one string which seems to make file classify a file as LaTeX:

$ cat text
a
b
$ cat latex
a
\begin
b
$ file text latex
text:  ASCII text
latex: LaTeX document, ASCII text

So at least I can force all files to have the same type by adding some environments to the files currently classified as text.