1

Everyone!

I'm a bit new with latex and I'm trying to create a project with a few subfiles and I found a problem that I just dont understand. I will first put you in context. My directory distribution is as follows:

Apuntes/
|Apuntes_radio.tex  (This is the main file)
|paquetes.sty   (This is the preamble file)
|temas/
|->Introduccion/
|->|->Introduccion.tex (This is the subfile)
|->|->img_intro/  (And this is the folder where the images for this subfile will be)
|->|->|->espc_EM.png

My main file is

\documentclass[a4paper,11pt]{book}
\usepackage{import}
\usepackage{paquetes}
\usepackage{subfiles}

\usepackage{makeidx}
\makeindex

\title{Apuntes de Radiactividad y Aplicaciones (3º Física)}
\author{Samuel G. Guerrero}
\date{Febrero 2020}

\begin{document}

\frontmatter
\maketitle


\mainmatter
\chapter{Introducción}

\subfile{temas/Introduccion/Introduccion}

\end{document}

And the subfile is a bit long, so I'll show you where latex says the problems are:

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

\graphicspath{
  {"temas/Introduccion/img_intro/"} %images path for the main file
  {"img_intro/"}                    %images path for THIS subfile
}

\begin{document}

.....[some junk]....

\begin{figure}[h!]
\centering
\includegraphics[scale=0.5]{espc_EM}
\caption{Espectro electromagnético.}
\label{fig:espc_EM}
\end{figure}

.....[some junk]....

\begin{wrapfigure}{l}{0.46\textwidth}
\includegraphics[scale=0.5]{espc_incandesc}
\label{fig:espc_incandesc}
\caption{Espectro de una lámpara incandescente}
\end{wrapfigure}

.....[some junk]....

\end{document}

And the preamble file is:

\ProvidesPackage{paquetes}

\usepackage{graphicx}
\usepackage{subcaption}
\usepackage[spanish, es-tabla]{babel}
\usepackage{url}
\usepackage{amsmath}
\usepackage{wrapfig}
\usepackage{caption}
\usepackage{appendix}
\usepackage{multirow}
\usepackage{pdflscape}
\usepackage{listings}
\usepackage{titlesec}
\usepackage{csquotes}

\topmargin=-2cm
\oddsidemargin=-1cm
\evensidemargin=-1cm
\textwidth=17.5cm
\textheight=25cm
\footskip=20pt

\addto\captionsspanish{\renewcommand{\chaptername}{Tema}} %cambiar "capitulo" por " tema%


\titleformat{\chapter}[hang] 
{\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter.}{10pt}{}

Now the problem

As it is, I have no trouble compiling the subfile individualy. It shows me no errors and looks as I want it. The problem comes when I try to compile the main file (Apuntes_radio.tex), it gives me this error: enter image description here

the long one saying:

! Package pdftex.def Error: File `\es@period@code espc_EM.pdf' not found: usingdraft setting.See the pdftex.def package documentation for explanation.Type H for immediate help.... \includegraphics[scale=0.5]{espc_EM}

Can anyone tell what it is? I've sorted the 'Missing $ inserted' error before, but this time I'm pretty sure it's not a symbol missing, mainly because the subfile does compile by itself without problems! I've lost a day and a half already to this...

Thanks in advance!!

  • 1
    Welcome to TeX-SX! As a new member, it is recommended to visit the Welcome and the Tour pages to be informed about our format and also to know about Minimal Example. Otherwise, more specifically about your question: try to use \includegraphics[scale=0.5]{espc_EM.png} rather than espc_EM without extension. – R. N Feb 16 '20 at 20:22
  • Hi Samuel, are you compiling with pdflatex or xelatex? Did you consult this question? maybe it can help you: https://tex.stackexchange.com/questions/473062/psfrag-or-auto-pst-pdf-return-error-latex-warning-file-filename-pics-pdf-not/473106#473106 – Annie Fubini Feb 16 '20 at 20:57
  • @Annie I've seen that question, but I dont really understand it. I've checked, and i have perl but not gswin32c installed. And i dont really know what to do.

    About the first question, im compiling with pdflatex.

    – Samuel Guerrero Feb 16 '20 at 21:06
  • i deepen the research: never had this problem .. give me time :) – Annie Fubini Feb 16 '20 at 21:12
  • Probably appears that the extension is missing in the secondary file: \ includegraphics [scale = 0.5] {espc_EM } or it cannot find the directory. Is it possible that the subfiles are in the wrong position in the compilation declaration? – Annie Fubini Feb 16 '20 at 21:46
  • @Annie I've tried adding the extension (.png) and it has the same error. And I dont understand what you mean by subfiles been in the wrong position in the compilation declaration... Im a bit newbie... – Samuel Guerrero Feb 16 '20 at 21:56
  • When you compile the main file, into it indicates all the files (chapters, figures, etc.) that are in a folder, right? if the files are in a different location latex cannot find them and there are often 'file not found' errors. Since you've been working on it for more than a day and a half to solve this problem let's try to see if the files are exactly in the right folder: you have a folder with 'Introduccion' - inside 'Introduccion' you have a second folder with 'Introduccion.tex 'where are the .png files. that's right? – Annie Fubini Feb 16 '20 at 22:11
  • @Annie if its worth it, when starting the project I could compile the main file. I should also say that if I comment both figures, the problem disappears and it compiles perfectly. About your question, the files and folders are organized as said at the beginning of the question. – Samuel Guerrero Feb 16 '20 at 22:18
  • Let's get the super experts involved! because even for me it is very strange your problem in the final compilation so then we all learn when we are faced with a problem like yours! – Annie Fubini Feb 16 '20 at 22:32
  • @Annie hahaha yes. Thanks a lot for trying though... – Samuel Guerrero Feb 16 '20 at 22:35
  • you are not showing what you have in the "paquetes", but I guess that you are using some spanish settings. – Ulrike Fischer Feb 16 '20 at 22:55
  • @UlrikeFischer I just edited it. You can see what the file has now. – Samuel Guerrero Feb 16 '20 at 23:00
  • 1
    Try if works if you remove the quotes from the graphicspath declaration. – Ulrike Fischer Feb 16 '20 at 23:16
  • @UlrikeFischer Oh my god, that was it lol. Hahaha thanks a lot! wow, such an simple thing! – Samuel Guerrero Feb 16 '20 at 23:23

1 Answers1

1

Remove the quotes from the graphicspath declaration. Quote are unneeded as there are not spaces (and with a current latex also in the other case) and with spanish they actually harm here as spanish makes the " active.

\graphicspath{
  {temas/Introduccion/img_intro/} %images path for the main file
  {img_intro/}                    %images path for THIS subfile
}
Ulrike Fischer
  • 327,261