2

I know that one writes the LaTeX code in a text editor as plain text. One then saves this file as a .tex file ad compiles using latex (or pdflatex, or ...).

From what I understand, there are different types of plain text. What, technically, should the plain text for the tex-code be written as?

13
  • 1
    The easiest plain text is an ASCII code .txt file... making special characters difficult, but, it's LaTeX and that's what \"a is made for: ä etc. (As a German I need such 'special' characters as lot. Make sure your text editor uses the right encoding and it's ok for LaTeX nowadays as well – user31729 Oct 11 '15 at 21:54
  • 3
    @Christian Hupfer: Don't you think nowadays, the recommended way is UTF8? ASCII makes the code hard to read (and harder to type) as soon as you have accented characters, while all modern systems and editors understand UTF8. – Bernard Oct 11 '15 at 21:57
  • 2
    @Christian Hupfer: I don't agree with you. The easiest is UTF8: generally, when you have to type accented letters, you have the keyboard that give an easy access to these characters. – Bernard Oct 11 '15 at 22:08
  • 1
    @Bernard: For a language like French or Spanish this is definitely true -- I rarely need accents (apart from the math versions). For Chinese letters/signs etc. ASCII ist not really appropiate, of course – user31729 Oct 11 '15 at 22:11
  • 4
    Any purely ASCII-encoded file is automatically UTF8-encoded as well. – Mico Oct 11 '15 at 22:15
9

Short version: it's complicated, but mostly systems automatically do the right thing.


Medium version:

There are only really two classes of differences in "types of plain text" Line endings and encoding.

Line ending is what typically distinguishes plain text file transfer from "binary" as the line endings are converted to the format used on the platform, typically this is (#13#10 pairs on windows, #10 on linux/and OSx and #13 on older mac releases, older operating systems had different conventions, or record based filesystems that did not use a lineend character at all.)

Modern TeX implementations will handle all combinations of #13 and #10 so even if you have a windows file on a linux machine (or vice versa it will work)

The other difference is encoding, that is what byte sequence is used to denote each letter. Here you can use most commonly used encodings, but you need to tell LaTeX which encoding you are using unless you only used ascii letters.

So if you are using UTF-8 (the best choice if you have no particular reason to choose something else) then you need

\usepackage[utf8]{inputenc}

in the file.

if you are using ISO-8859-1 (latin-1) encoding used in most of Western Europe before systems started moving to Unicode, then you need

\usepackage[latin1]{inputenc}

etc.

UTF-8 is preferred as it is a Unicode encoding rather than a language or region specific encoding. (Examples copied from this site will be in UTF-8 originally, although many editors will automatically convert if you cut and paste them into a file that is being saved with a different encoding.)


Long version: The Unicode spec.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.