1

I am working in a multi-file document and i have imported the [latin]{inputenc} package in the main document but it isn't working in the subfiles.

Main.tex

\documentclass[10pt,a4paper]{article}
\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}

%\usepackage{titlesec} %Only for book
%\titleformat{\chapter}{\normalfont\huge}{\thechapter.}{20pt}{\huge\it} %Only for book
\usepackage{subfiles}

\author{Yamil Saade}
\title{Caracterización de Laminados}

\begin{document}

    %\frontmatter
    \maketitle

    %\mainmatter

    \section{Introducción}
    \subfile{Sections/Introduction}


\end{document}

Subfile.tex

\documentclass[../main.tex]{subfiles}

\begin{document}

    Hoy en día natación

\end{document}

Result from the code Above ...

Result

  • Try using unicode for your files instead. Check if your subfile actually uses latin-1 too. – meneldal Nov 4 '19 at 3:34
  • most editors will (and should) default to UTF-8 today not latin1 (iso-8859-1) make sure that all your files are UTF-8 encoded and then change [latin1] to [utf8] the subfiles showing accented A are already in UTF-8 but display incorrectly as you have declared latin1. – David Carlisle Nov 4 '19 at 7:16
1

Your problem is not related to the subfiles package, but is a mismatch between the specified encoding, latin1, and the actually used one, utf8. Consider the following file:

% test.tex
\documentclass{article}
\usepackage[latin1]{inputenc} % Sets the expected encoding to Latin1
\begin{document}
Hoy en día natación % Actually uses UTF8
\end{document}

where the accented letters are stored in UTF-8 encoding. Under Linux, you can use the file command to check the encoding actually used:

$ file test.tex
test.tex: LaTeX 2e document, UTF-8 Unicode text

For windows, see this posting on how to check and to change the encoding using notepad.

Running LaTeX on test.tex results in three errors:

! Missing $ inserted.
<inserted text> 
                $
l.4 Hoy en día natació
                        n
? 
! Extra }, or forgotten $.
\maththreesuperior ->{^3}

l.4 Hoy en día natació
                        n
? 
! Missing $ inserted.
<inserted text> 
                $
l.5 \end{document}

If you (or your TeX system) skip these errors, you will get the following output:

enter image description here

Solution

Make sure that all your TeX files use the same character encoding. Nowadays UTF-8 is the standard, but Latin1 is also fine. Just make sure that you use the same encoding everywhere. Depending on your choice, use either

\usepackage[latin1]{inputenc}

or

\usepackage[utf8]{inputenc}

Running LaTeX on the file

% test.tex
\documentclass{article}
\usepackage[utf8]{inputenc} % Sets expected encoding to UTF8
\begin{document}
Hoy en día natación % Actually uses UTF8
\end{document}

gives no errors and results in the output

enter image description here

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.