5

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}
1
  • 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 May 17, 2014 at 14:05

2 Answers 2

5

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

0
2

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.

2
  • @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, 2014 at 15:19
  • @David Carlisle: !!! I don't understand what could have happened. Anyway, I'll modify my answer.
    – Bernard
    May 17, 2014 at 17:03

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.