# [OS X TeX] Input encoding question

Herbert Schulz herbs at wideopenwest.com
Thu Feb 19 18:20:18 CET 2009

On Feb 19, 2009, at 10:35 AM, Nathan Paxton wrote:

> 	Hi all,
>
> 	I have a (hopefully) simple question. I know that TexShop can save
> files in a  variety of encodings, like Latin, UTF-8, and so forth.
>
> 	The default for TS seems to be Western Mac encoding. What will
> change if I change everything to UTF-8?
>

Howdy,

You can change the default from MacRoman to UTF-8 Unicode in TeXShop-
>Preferences->Source->Encoding. But, by far the best thing to do is
place the line

%%!TEX encoding = UTF-8 Unicode

or

%%!TEX encoding = MacOSRoman

if you are going to use UTF-8 or MacOSRoman respectively near the
beginning of the file. You must do this with each file!!! That way
TeXShop will do the right thing no matter how the default encoding is
set up.

You will need to tell TeX what encoding it should use to
``understand'' the file it's reading. This is done using the line

\usepackage[utf8]{inputenc}

or

\usepackage[applemac]{inputenc}

for UTF-8 or MacOSRoman respectively in your preamble.

> 	I'll explain why: I have a document that's a sub-part of a master
> doc (a chapter of my dissertation). In the chapter, there's a lot of
> stuff that's quoted in or cut-and-pasted from Spanish, and the
> originals have lots of accented characters (á and other vowels, for
> example). Under the default encoding, pdflatex is unhappy and spits
> back an error, but under UTF-8, pdflatex is as happy as a clam. I've
> written the other parts of the dissertation (three chapters) in
> Western Latin Mac. Is anything terrible going to happen (to the best
> of your guessing) if I save just this chapter in UTF-8, as a
> subsidiary of the master doc? So,
> 1.	Is one part of a master in a different encoding a problem?
> 2.	Or does the whole master doc and all subsidiary (\include{}) docs
> need to be in the same encoding?
> 	a.	What effect could this have on those docs, assuming no other
>
> 	I hope that's clear. Thanks in advance for any guidance you can
> offer.
>
> Best,
> -Nathan

ASCII is a subset of both MacOSRoman and UTF-8. If you are using plain
ASCII in all the other document files (i.e., no accented characters
except those included using macros [e.g., \'e for é]) there will be no
problem. If that isn't true then all the files must be in same
encoding; as far as I know there is no way to have TeX change the
input encoding interpretation mid-process.

Hope that helps.

Oh... one more thing... you should use the latin modern font and T1
font encoding so that TeX knows what glyph to use. (The standard
Computer Modern fonts need to build accented characters.) Add the lines

\usepackage[T1]{fontenc}
\usepackage{lmodern}

where the Latin Modern fonts are extended Computer Modern fonts.

Good Luck,

Herb Schulz
(herbs at wideopenwest dot com)