0

When I call two separate files(chapters) from a main file, it shows error for graphicx. Details are bellows:

(i) The main file main.tex contains following contents:

\documentclass[a4paper,12pt]{book}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}

\begin{document}
\author{No Author}
\title{Simple Book Example}
\frontmatter
\maketitle
\tableofcontents
\mainmatter
\include{ch1/chapter01}
\include{ch2/chapter02}
\backmatter
\end{document}

(ii) The first chapter chapter01.tex contained in the directory ch1. The chapter01.tex contains the following contents:

\chapter{first chapter}
Text sample
\includegraphics{konigsberg1}   

The image konigsberg1.png contained in ch1.

Similarly, the second chapter chapter02.tex contained in the directory ch2. The chapter02.tex contains the following contents:

\chapter{second  chapter}
Text sample for 2nd ch
\includegraphics{Jordan_curve} 

The image Jordan_curve contained in ch2.

These two directories ch1 and ch2 are contained in the directory where the main file contained.

When I compile with pdflatex in texstudion on MacOS, it shows that

File `konigsberg1' not found.

for line \includegraphics{konigsberg1} and

File `Jordan_curve' not found.

for \includegraphics{Jordan_curve}. But when I comment out includegraphics, then everything is ok.

How can I fix error?

1

Add

\graphicspath{{ch1}{ch2}}

to your preamble

| improve this answer | |

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.