Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

This question already has an answer here:

My document uses è and ï, so i used the following preamble to make sure they are displayed correctly. However they show up as something else (namely A¨~). What could be the problem?

Specifically, I started the preamble with: \usepackage[latin1]{inputenc}

I don't do \usepackage[T1]{fontenc} because that made the output an awful looking font.

UPDATE: for testing purposes, I inserted an é into every .tex file that is being \input in the main .tex file. Apparently, only 1 .tex file shows the wrong symbols, all other ones show the é like intended.

I use TeXnicCenter with MiKTeX 2.9 on Windows 7 64-bit.

ANSWER: I copied the contents of the erronous .tex file to notepad, deleted the .Tex and created a new one. Then I inserted all the text again. Now it works. So... for some strange reason that specific .tex file was of a different encoding?

share|improve this question

migrated from stackoverflow.com Apr 24 '13 at 23:05

This question came from our site for professional and enthusiast programmers.

marked as duplicate by doncherry, Werner, mafp, Speravir, Guido Apr 25 '13 at 2:41

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
\usepackage[latin1]{inputenc} - why latin1, not utf8x? –  Eddy_Em Apr 24 '13 at 18:59
    
because using that gives me many errors (like: ! Package utf8x Error: MalformedUTF-8sequence.) and warnings and latin1 doesn't give me any errors –  user1884155 Apr 24 '13 at 19:02
    
Are you sure your text in utf8, not utf16? Also, latin1 != utf8, so many your symbols from utf8 wouldn't be displayed right way. Another way is absolutely not use unicode and make accents by special commands like \oAl\"em\ae –  Eddy_Em Apr 24 '13 at 19:07
    
where can i see in what encoding my text is? I thought I defined it by setting the "% !TEX =" message –  user1884155 Apr 24 '13 at 19:32
    
Run enca your_file. That's in header is nonsense. –  Eddy_Em Apr 24 '13 at 19:43
show 5 more comments

2 Answers

If your document uses UTF8 encoding (which your first line indicates)

\usepackage[utf8]{inputenc}

should probably work.

share|improve this answer
    
using that gives me the following errors (one for each special character I use, this one is for the ï-character): !Package inputenc Error: Unicode char \u8:ïnv not set up for use with LaTeX. –  user1884155 Apr 24 '13 at 19:04
    
After some experimentation, I am able to reproduce these errors by using latin1 encoding for the document. So might your original document be latin1 encoded? If you you might want to try to remove the first line and use latin1 with inputenc. –  Jan van der Laan Apr 24 '13 at 19:42
    
I removed the first line and the special characters still show up wrong. –  user1884155 Apr 24 '13 at 19:46
    
@user1884155: that line is a simple comment. It have no sense at all! –  Eddy_Em Apr 24 '13 at 19:53
    
Welcome to TeX.sx! Your post was migrated here from another Stack Exchange site. Please register on this site, too, and make sure that both accounts are associated with each other (by using the same OpenID), otherwise you won't be able to comment on or accept answers or edit your question. –  texenthusiast Apr 24 '13 at 23:15
add comment

I frequently have this problem (albeit usually with the characters åäö in the Swedish alphabet, rather than é and ï, but I assume it's the same), and it always has the same cause, and the same solution:

Cause:

Your text file is saved with one encoding, and LaTeX is reading it in another.

Solution:

It doesn't matter if you have Latin1 or UTF-8 to get these particular characters to work, but you must be consistent and use the same encoding everywhere. I try to use UTF-8 everywhere, since it is more general (and seems to be the future of encodings, if the world could just agree on one...), and is also supported on all platforms

Some more remarks on encodings:

You mention using Notepad, so I'll assume you're on a Windows computer. Then, you might not be using either Latin-1 or UTF-8, but rather Microsoft's own ANSI format. It is usually, but not always, possible to compile as if it was Latin-1. I would not recommend using it with LaTeX - instead, I recommend using UTF-8, and, if you need, \usepackage[utf8]{inputenc}. I say "if you need", becaue it might very well be that LaTeX assumes UTF-8 as the default.

To find out what encoding a text file is in, you can open it with Notepad and hit "Save As..." from the "File" menu. There will be a little dropdown list close to the bottom of the dialog, that gives you the option to save in different encodings. The current encoding is always selected - and if it is not UTF-8, I recommend changing it to UTF-8 before saving ;)

share|improve this answer
add comment