3

I'm writing my thesis in spanish on latex and I'm using the \include{} function to bring other .tex files to my master.tex (main file).

My encoding looks something like this:

\documentclass[11pt,a4paper,twoside]{report}

\usepackage[spanish]{babel}
\addto\shorthandsspanish{\spanishdeactivate{~<>}}

\usepackage[T1]{fontenc}
\usepackage[utf8x]{inputenc}
.
.
\begin{document}
some text here...
\tableofcontents
\include{chapter1}
.
.
\end{document}

The thing is that the master.tex file writes perfectly spanish accents. But, when I try to include a chapter, it comes out with this error (! Package utf8x Error: MalformedUTF-8sequence.) And I checked it out and, for example it comes when I do:

This is chapter1.tex:
\chapter{Justificación del tema}
.
.
(in master.tex file: \include{chapter1}

It comes with the error when I do the ó, but If I write "Justificacion" (with no " ´ " on top of the "o", everythings fine.

Does anybody know how can I get this fixed? Do I have to put something on top of the chapter1.tex file?

To know: - I'm using TexMAKER on Windows 7.

I'd be very grateful if someone could help me! Thank you and greetings from Chile!

  • 1
    You can't get an error linked to utf8x if you use the utf8 option. However, this might mean the file is not UTF-8 encoded. – egreg Oct 13 '15 at 20:14
  • 3
    Probably your chapter1.tex file is not utf8, despite what you declare in inputenc. If you are on a linux machine, try file chapter1.tex from command line to find out the encoding of that file. – JLDiaz Oct 13 '15 at 20:48
  • 1
    @JorgeV For Windows there is a good (and free) editor called Notepad++, which has extensive support for converting/saving different encodings. – JLDiaz Oct 13 '15 at 21:07
  • @JLDiaz, I just tried using Notepad++ for changing the encoding, but it says that actually the file is in utf8. Got any other idea? Thank you !! – Jorge V Oct 13 '15 at 21:16
1

If you are having the same problem I had, you just have to put the following code into the .tex files that are going to be included in your master file:

%!TEX root = master.tex

Say you are writing an introduction, you create the introduction.tex file and you include it in master.tex with \include{introduction.tex}. The above code should be at the top of introduction.tex.

(The master.tex file is your main document.)

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.