.tex

What is a .tex file?

LaTeX Source Document · Document · Donald Knuth / Leslie Lamport · 1978

A .tex file is a LaTeX or TeX source document: plain text marked up with commands that a TeX engine typesets into a beautifully formatted PDF. It is the standard for academic papers, maths and books.

Category
Document
Type
Plain text
Is a .tex file safe to open? Mostly safe, but TeX can run shell commands during compilation if enabled. Compile untrusted .tex files with shell-escape disabled, which is the default.

What is a .tex file used for?

Instead of a visual editor, LaTeX describes structure and maths in text commands, then compiles to PDF. This gives precise, consistent typography, which is why journals and mathematicians rely on it.

The files are plain text and open in any editor, but you need a TeX distribution (TeX Live, MiKTeX) or an online service like Overleaf to compile them into a document.

What opens a .tex file?

The .tex format opens in the following apps, grouped by operating system. If one app does not work, try another from the same list.

Windows

  • TeXworks
  • VS Code (LaTeX Workshop)
  • MiKTeX

macOS

  • TeXShop
  • VS Code
  • MacTeX

Linux

  • TeX Live
  • VS Code
  • any text editor

Web

  • Overleaf

Open a .tex file step by step

  1. Confirm the file really is a .tex. Drop it into the WhatFileType identifier, which reads its signature in your browser without uploading anything.
  2. On Windows, open it with TeXworks or VS Code (LaTeX Workshop).
  3. On Mac, use TeXShop or VS Code.
  4. On Linux, try TeX Live or VS Code.
  5. Still stuck? Convert the .tex to pdf, which opens more widely.

Why can't I open my .tex file?

Almost always because no installed app understands TeX. Install one of the apps above, or convert the file to a format your existing software already reads. If double-clicking opens the wrong program instead of nothing at all, the file association is set to the wrong app rather than the file being broken.

The other possibility is that the file is not really a .tex at all. Drop it into the file identifier to check it by its bytes instead of its name. Nothing is uploaded.

How to convert a .tex file

You can convert a .tex file to pdf, html, docx using a conversion tool or the export menu of an app that opens it.

TeX has no fixed magic number, so there is no signature table on this page. Its bytes alone do not prove the format: identification relies on the extension, the structure of the content and the program that created it. The magic-numbers reference lists the formats that do carry one.

Frequently asked questions

What is a .tex file?

A .tex file is a LaTeX or TeX source document: plain text marked up with commands that a TeX engine typesets into a beautifully formatted PDF. It is the standard for academic papers, maths and books.

How do I open a .tex file?

Any text editor shows the source. To produce the formatted document, compile it with a TeX distribution such as TeX Live or MiKTeX, or use Overleaf online.

How do I turn a .tex file into a PDF?

Run a LaTeX compiler (pdflatex file.tex), use an editor like TeXworks or VS Code with LaTeX Workshop, or upload it to Overleaf.

What is the difference between TeX and LaTeX?

TeX is the low-level typesetting engine; LaTeX is a widely used set of macros on top of it. Most .tex files people write today are LaTeX.

Related formats

Sources

Details on this page were checked against authoritative references. How sources are ranked and what is deliberately left out is set out in the methodology.