# Error to load preamble in subfiles

I'm trying to write a document in spanish with multiple files, however I can't compile special characters (á,é,í,ó,ú) in the child files (these compile fine in main file) and I can't add a preamble in the subfiles as it inherits the main preamble. Here's a minimal (not) working example:

Main file:

\documentclass[11pt,twoside,openany]{book}
\usepackage[paperwidth=17cm, paperheight=22.5cm, bottom=2.5cm, right=2.5cm{geometry}

\usepackage{subfiles}

%Spanish writing packages
\usepackage[spanish]{babel}
\selectlanguage{spanish}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

\begin{document}
á é í ñ  % these compile fine when I comment out the child file

\chapter{Introducción}
\subfile{child}  % include for standalone and subfile for subfiles

\end{document}


Child file:

\documentclass[main.tex]{subfiles}

\begin{document}
Tipos de investigación en el capítulo 1
\end{document}


PS1: I also tried to use the standalone package with the preamble for spanish writen in the child file, but I got the same results.

PS2: I am using TexMakerX, could it be I'm missing some update o that it is poorly installed?

Thank you so much for your help!

• Welcome to TeX SX! TeXMakerX is the very old name of what has become TeX Studio. Perhaps you should update. Also do you have any reason to not using the simple \include{child}, the latter having no preamble? – Bernard May 11 '17 at 1:11