3

I was just wondering what the standard extension is for a LaTeX file. Obviously LaTeX files are just text and therefore the file could be named anything, but I am interested in convention. myfile.tex or myfile.latex would be two options I would consider to be most obvious. Which is better or is there something else?

8
  • 2
    .tex is the standard extension.
    – Bernard
    Mar 3, 2016 at 0:57
  • It is always .tex, never seen otherwise.
    – Masroor
    Mar 3, 2016 at 0:58
  • @Bernard Thanks! This doesn't cause confusion between LaTeX and plain TeX? I know c++ generally has a modified extension so I was just wondering. Mar 3, 2016 at 0:59
  • Not at all. A latex file has a precise structure, and if you try to compile it with plain TeX, the compiler will scream, and conversely.
    – Bernard
    Mar 3, 2016 at 1:04
  • @Bernard I see your point. Just interesting that a c compiler would scream at c++ as well and they also chose a new extension. Seems that they just opted for different conventions. Thanks for your help! Mar 3, 2016 at 1:09

1 Answer 1

3

The standard extension for a TeX file is independent of the engine used. See, for example, the output when using typing tex --help from the terminal:

./>tex --help
Usage: tex [OPTION]... [TEXNAME[.tex]] [COMMANDS]
   or: tex [OPTION]... \FIRST-LINE
   or: tex [OPTION]... &FMT ARGS
[snip]

...and for latex --help:

./>latex --help
Usage: pdftex [OPTION]... [TEXNAME[.tex]] [COMMANDS]
   or: pdftex [OPTION]... \FIRST-LINE
   or: pdftex [OPTION]... &FMT ARGS
[snip]

...and for xelatex --help:

./>xelatex --help
Usage: xetex [OPTION]... [TEXNAME[.tex]] [COMMANDS]
   or: xetex [OPTION]... \FIRST-LINE
   or: xetex [OPTION]... &FMT ARGS
[snip]

...and for lualatex --help:

./>lualatex --help
Usage: luatex --lua=FILE [OPTION]... [TEXNAME[.tex]] [COMMANDS]
   or: luatex --lua=FILE [OPTION]... \FIRST-LINE
   or: luatex --lua=FILE [OPTION]... &FMT ARGS
[snip]

All of the engines use an optional [.tex] file extension in their input. That is, it is expecting a .tex extension, making it in the standard/default.

2
  • does this mean a *.latex extension will be converted to a *.tex extension?
    – naphaneal
    Mar 19, 2018 at 22:36
  • @naphaneal: No. It just means that you don't have to specify the extension if it is .tex. If it's .latex, then you'll have to specify it. Moreover, (La)TeX does not alter the input, just the output.
    – Werner
    Mar 19, 2018 at 23:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .