The difference between LaTeX's input and output encodings has been discussed in various places; I especially like user @egreg's answer here.

There is however an aspect of dealing with output encodings that I do not understand: When a user loads multiple output encodings, how does LaTeX decide and know which one to use at any given time during compilation?

For example, the documentation of tipa has an example where the user loads three output encodings:


Also, why don't packages or languages that require certain output encodings load these themselves? That is, why does the user have to decide which ones to load via fontenc's options?


Encodings are a bit like the languages of babel: The last encoding option will be the one active at the begin of the document, but in the course of the document you can switch from one encoding to one of the other predeclared encodings with \fontencoding{..}\selectfont. Quite a lot commands include such font encoding switches.

In one respect fontenc is a rather special package: You can load it more than once.


will give no "option clash" error message, and it will also not ignore the second \usepackage. The active encoding will be T1 after the two commands.

This means that package authors have to be a bit careful with loading fontenc: They can easily overwrite the encoding the user wants to use as default. This problem just came up with the new libertine-type1-package: It sets the default font encoding to LY1, which leads to unexpected substituations. In general normal font packages (for fonts which can be used with "normal" encodings like T1, LY1 or OT1) leave the choice of the encoding to the user. Packages which needs special font encodings (like tipa or chessfss) do some twists to load the definitions but not activate them. fontspec on the other side simply set the encoding to EU1/EU2.

  • Given that font encodings (= output encodings) are a bit of a LaTeX-algorithm-internal thing (as discussed with @egreg at the link supplied in the question statement), I'm wondering why the packages can't just load the encodings all by themselves. It makes sense that the fact that packages can accidentally overwrite the "desired" output encoding makes things tricky, but given that (I think) the user "shouldn't" need to worry about such encodings in the first place, why isn't fontenc a package that is only ever loaded by the packages themselves (as opposed to the user)? – Lover of Structure Sep 26 '12 at 9:06
  • With which option should a package load fontenc? The lmodern fonts can be used with OT1, T1, LY1, T5 and some more encodings. You can't avoid that sometimes a user has to make a decision. Also in your example above you are actively preventing tipa to load fontenc with the noenc option. You are telling the package that you want to handle the encoding yourself. Without this option tipa would load T3 and the active encoding. – Ulrike Fischer Sep 26 '12 at 9:35
  • The example is from the documentation, which tells me to do things that way "if I want to use a more complex form of encoding". But why would I "want" to? Again, font encodings are an algorithm-internal thing that the user shouldn't need to worry about. Why do I have these options? The reasons indicated here for example seem all like non-reasons: hyphenation (and the required choice of encoding) is determined by the language, so this (as well as copy/paste) and input should be handled in the background. – Lover of Structure Sep 27 '12 at 16:52
  • 2
    Well normally you don't have to worry much. You should load T1-encoding because the old default (OT1) used by LaTeX is bad (LaTeX3 will hopefully drop OT1). If you want to use greek you should probably load LGRX - because it is better than the old default LGR loaded by babel. In the case of quite of lot of language babel will handle the encoding. tipa will also load the needed definitions. But if you for some reason prefer e.g. LY1 or some other encoding for a language you can load and use it. – Ulrike Fischer Sep 27 '12 at 17:16
  • 2
    1. \makeatletter\show\f@encoding\makeatother will show you the current encoding on the terminal and in the log. 2. Not really. Try it out. And don't forget that other packages can change the encoding too. – Ulrike Fischer Sep 28 '12 at 7:44

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.