What is the correct mimetype for .tex-files?
Asked Answered
A

3

8

My webservice generates and returns a .tex-file. I want to give the correct mimetype in the http-header.

I didn't found so much except for here, where I find application/x-tex. Is this an authority to stick to?

Algebraic answered 6/2, 2019 at 7:24 Comment(2)
https://mcmap.net/q/79830/-get-mime-type-from-filename-extensionJordison
Note that the x- prefix means that it's not an official type. I've seen both application/x-tex and text/x-tex, but my current mime.types file is like Benoit's.Newsmagazine
A
7

For those who came here... i ended up with "application/x-tex"

Algebraic answered 18/2, 2020 at 14:13 Comment(0)
P
5

Looking at /etc/mime.types, I found:

MIME type File extensions
application/x-latex latex
text/x-tex tex, ltx, sty, cls
Paisa answered 30/8, 2023 at 13:55 Comment(1)
And yet OP went for a combination of those two.Lydialydian
A
2

Short answer: application/octet-stream, because the IANA Media Type list does not have the .TeX file extension specified (NO application/x-tex, etc, as mentioned), this will indicate to the browser that it is an "unknown" file and show a "Save As" dialog. See the Long answer for more information.

Long answer: Internet Assigned Numbers Authority (IANA) is responsible for the official Media Types list (formerly known as a MIME type) and I couldn't find any for .TeX extension, maybe because TeX is a software designed to format scientific documents (e.g. complex math formulae), not a common application, its a typesetting language (source code), the output is usually a PDF:

Output formats

TeX source files can be typeset into several different output formats, depending on the engine. Notably, the pdfTeX engine (despite its name) can output both DVI and PDF files.

At a high level, the output format that gets used depends on the program you invoke. If you run latex (which implements the LaTeX format), you will get DVI; if you run pdflatex (which also implements the LaTeX format), you will get PDF.

No TeX engine implements native HTML output, but it is still possible to get HTML, XML, etc., output:

The tex4ht program can be run (e.g., htlatex, make4ht). TeX4ht uses TeX behind the scenes, so user macros, etc., are generally recognized. There are many possible output formats, including Office XML. TUGboat article on tex4ht, and more recent article. The lwarp LaTeX package causes LaTeX to output HTML5. It hooks into many packages to create the html. TUGboat article on lwarp. The LaTeXML Perl program independently parses LaTeX documents and generates many output formats.

Therefore, in the case of using .TeX engine as a PDF output, e.g., it should be used the application/pdf. Although, my understanding of the original post is that the developer intends to return a .TeX-file from his web service. Thus, as the Media Types list does not specify any subtype to .TeX, the application/octet-stream type would indicate to the browser that the file is "unknown" and propose a "Save As" dialog. Source: Media Types procedures - MDN Web Docs

Armagh answered 25/4 at 14:40 Comment(5)
Thank you @KJ for your comments, I am learning a lot from you. I dived into the Media Types procedures and read the original question from this post again. The developer designed its website to return a file to the user: "My webservice generates and returns a .tex-file." Right? Therefore, using the type application/octet-stream would be easier.Armagh
"This is the default for binary files. As it means unknown binary file, browsers usually don't execute it, or even ask if it should be executed. They treat it as if the Content-Disposition header was set to attachment, and propose a "Save As" dialog." because, as my understanding, there isn't a "proprietary file type" defined in the official Media Type list. Do you agree?Armagh
IANA standardizes a lot more than web sites. But ultimately, there is no real benefit of standardizing every existing file format.Curtal
The answer as it stands is that the type is application/pdf. The comments show Augusto suggesting that application/pctet-stream would be easier. I would prefer to use the latter over the former. Either the answer should be edited heavily or the answer can be deleted.Newsmagazine
As suggested, I summarized the answer, it is application/octet-stream the correct Media Type for this case, but the complete reasoning provides other forms of uses for the TeX engine because could be an output for a PDF file.Armagh

© 2022 - 2024 — McMap. All rights reserved.