About
Shop
LaTeX
Software
Books
Gallery
News
Contact
Blog
Settings
Account


4.3.1 The inputenc Package

Instead of using the accent and ligature commands described above, you can use the inputenc package and enter the character directly, but you must ensure you match the encoding with that used by your text editor. For example, this book uses UTF8 encoding so I have loaded the inputenc package in the preamble with the utf8 option:

\usepackage[utf8]{inputenc}

Note that it's a good idea to also use the fontenc package as well. For example, if you want to use Type 1 fonts:

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

Returning to an earlier example, I can directly enter the Unicode character (U+0153) for the lower case œ ligature:

manœuvre

Note that if you are collaborating on a document and you want to use this approach, you must ensure that all your co-authors use the same input encoding. For example, suppose you decide to use ISO Latin 1 encoding (latin1 option):

\usepackage[latin1]{inputenc}

but your co-author is using a UTF-8 editor and types:

naïve

where ï is the Unicode character U+00EF. UTF-8 characters use one to four 8-bit bytes whereas ISO Latin 1 uses an 8-bit single-byte character set. So the U+00EF binary sequence is interpreted by ISO Latin 1 encoding as two characters: Ã (0xC3) and ¯ (0xAF). Therefore the resulting PDF file will end up containing the rather odd looking:

naï ve

(If you are using TeXWorks, you can set your preferred encoding using EditPreferences and select the “Editor” tab where there is an “Encoding” setting. Make sure this setting matches the inputenc option you use in your document.)

Exercise 4: Using Special Characters

Start a new file in TeXworks, and see if you can write the source code to create the output below. (Ignore any hyphenation that may appear below, LaTeX does that automatically where necessary, see §2.14. Hyphenation. Likewise, ignore where the line breaks occur, except for the paragraph break.) Choose whether you want to use the inputenc package or if you want to use commands such as \c, but in either case you need to be careful of the special characters.

You can download or view the source code if you can't work out how to do it, and remember to check Appendix B. Common Errors if you have a problem.


This book is also available as A4 PDF or 12.8cm x 9.6cm PDF or paperback (ISBN 978-1-909440-00-5).

© 2012 Dickimaw Books. "Dickimaw", "Dickimaw Books" and the Dickimaw parrot logo are trademarks. The Dickimaw parrot was painted by Magdalene Pritchett.

Terms of Use Privacy Policy Cookies Site Map FAQs