What is MIME type "text/x-tex"?

A MIME type is a string that tells browsers and other tools how to handle a particular kind of file.

text/x-tex is a MIME type used for files containing TeX source code.
TeX is a typesetting system common in academic and technical environments.
Files of this type are plain text and include commands for layout, equations, and formatting.
They are processed by TeX compilers to produce final documents such as PDFs.
The file typically uses the TEX extension.
Learn more about TeX.
TeX Live distributions provide comprehensive environments for compiling these files.

Associated file extensions

Usage Examples

HTTP Header

When serving content with this MIME type, set the Content-Type header:


    Content-Type: text/x-tex    
  

HTML

In HTML, you can specify the MIME type in various elements:


    <a href="file.dat" type="text/x-tex">Download file</a>    
  

Server-side (Node.js)

Setting the Content-Type header in Node.js:


    const http = require('http');    
    
    http.createServer((req, res) => {    
      res.setHeader('Content-Type', 'text/x-tex');    
      res.end('Content here');    
    }).listen(3000);    
  

Associated file extensions

FAQs

How do web browsers handle text/x-tex files?

Most web browsers do not natively render TeX files as formatted documents. Instead, they will usually display the raw source code as plain text or prompt you to download the file. To display the content beautifully on the web, consider compiling the file to application/pdf or using a JavaScript library like MathJax.

How do I configure Apache to serve .tex files correctly?

To ensure your Apache server sends the correct MIME type, add the following line to your .htaccess file or server configuration: AddType text/x-tex .tex. This tells the browser and client applications that the file contains TeX source code.

Is text/x-tex used for LaTeX files as well?

Yes, the MIME type text/x-tex is the standard identifier for both plain TeX and LaTeX source files. Although LaTeX is a macro package built on top of TeX, they share the same .tex extension and underlying text-based structure.

What software is needed to open and compile a text/x-tex file?

You can open the file with any simple text editor (like Notepad or Vim) to view the source code. To process the commands and generate a final document, you need a TeX distribution such as TeX Live or MiKTeX, often used with specialized editors like TeXShop or TeXworks.

Why does the file look like code instead of a document?

Files with the text/x-tex MIME type contain typesetting instructions and content, not the final visual output. You must run the file through a compiler (like pdflatex or xelatex) to produce a readable document, typically a PDF or DVI file.

Are there security risks associated with opening text/x-tex files?

The file itself is harmless plain text, but compiling untrusted TeX code can be risky. TeX engines have features that can execute shell commands (often via \write18), so you should always inspect the source of unknown .tex files before compiling them.

How do I configure Nginx for text/x-tex?

In your Nginx configuration file (usually nginx.conf or inside mime.types), ensure the mapping exists: text/x-tex tex;. If it is missing, add it to the types { ... } block to ensure the server delivers .tex files with the correct header.

General FAQ

What is a MIME type?

A MIME (Multipurpose Internet Mail Extensions) type is a standard that indicates the nature and format of a document, file, or assortment of bytes. MIME types are defined and standardized in IETF's RFC 6838.

MIME types are important because they help browsers and servers understand how to process a file. When a browser receives a file from a server, it uses the MIME type to determine how to display or handle the content, whether it's an image to display, a PDF to open in a viewer, or a video to play.

MIME types consist of a type and a subtype, separated by a slash (e.g., text/html, image/jpeg, application/pdf). Some MIME types also include optional parameters.

How do I find the MIME type for a file?

You can check the file extension or use a file identification tool such as file --mime-type on the command line. Many programming languages also provide libraries to detect MIME types.

Why are multiple MIME types listed for one extension?

Different applications and historical conventions may use alternative MIME identifiers for the same kind of file. Showing them all helps ensure compatibility across systems.