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.

I am trying to edit a exam using a template I found on internet (article using mathexam package) but since I have to use special characters of Brazilian portuguese (like á, à, ç, ã, õ, ô, â, ê) my final .pdf was not showing how I intended. The characters do not appear on the output, after compiling, by simply typing them on the code like I do in most of my other .tex documents (using babel and inputec packages).

But when I created a new .tex and was editing it to add on the current question, it finally worked. I think it must have something to do with codification of the file, but I have no idea how to change that option on the files.

What was actually happening?

In my documents I always use \usepackage[latin1]{inputenc}. How can I know if some file has different codification, and how to change it properly?

***I work on TeXnicCenter under WIN7 system.

Below is the example:

\documentclass{article}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage[latin1]{inputenc} 
\usepackage[brazil]{babel} 
\usepackage[left=1in, right=1in, top=1in, bottom=1in]{geometry}
\usepackage{mathexam}

\ExamClass{Instituição}
\ExamName{Simplificação de Raízes}
\ExamHead{\today}

\let\ds\displaystyle

\begin{document}
\ExamInstrBox{
Coment with á é ã ç, ....}
\ExamNameLine
\begin{enumerate}
   \item Calc something1.  
      \begin{enumerate}
     \item $\frac{\sqrt{x+1} - 2}{x-3}$\answer
     \item $\frac{\sin(4x)}{8x}$\answer[1in plus 1fill]
      \end{enumerate}
   \item Calc something2 
      \[\lim_{x\rightarrow 2} x^5  -2x^2 + 4x + -7 = 0\]\noanswer[2.5in]
   \item Find...   
      \answer*{$f(x)=$}\addanswer*{$g(x)=$}
\end{enumerate}
\end{document}
share|improve this question
1  
most editors will (somehow) show you the file encoding but I do not know that one. However if the file is not latin1 it is probably UTF-8 so changing the inputenc option to [utf8] will probably fix it –  David Carlisle May 17 at 14:05

2 Answers 2

up vote 3 down vote accepted

If your posted example is saved as iso-8859-1 (latin1) it runs without error and produces the expected result.

If it is saved as UTF-8 it produces

enter image description here

Spurious accented A are a sure sign that the multi-byte UTF-8 characters are being interpreted as latin-1.

There are tools to convert back to latin1, but Unicode is the future, so possibly a better option is to tell LaTeX that you are using utf-8

\usepackage[utf8]{inputenc} 

Then your document works again

share|improve this answer

You also have to load:

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

or whatever font you please, provided it exists in T1 encoding, so as to ensure correct hyphenation of words with accented letters.

share|improve this answer
    
@David Carlisle: I once happened to get missing accented characters just because I had forgotten to load fontenc and lmodern, thereby using the default Computer Modern. Did something change in this respect more or less recently? –  Bernard May 17 at 15:19
    
@David Carlisle: !!! I don't understand what could have happened. Anyway, I'll modify my answer. –  Bernard May 17 at 17:03
    
+1 (deleted earlier comments:-) –  David Carlisle May 17 at 17:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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