TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am working on a project and i want to slim it down a litle so please help me with the following. I have a document structure like this:

 |  |-/images
 |  |-chapter-1.tex

My document is like this:


in my chapters i use both some images and some heavy tikz plots so i use externalize and draft options for quicker compilation. But i want the images to be placed in the respective chapter folders but for example in chapter 3 this works:


and this doesn't


for some reason xelatex has problems with the relative paths of included chapters. I also want to control the location output and the naming of the externalized tikz documents. Any help with that? I am working with miktex and texworks.

share|improve this question
up vote 5 down vote accepted

The idea is simple, just prepare directory paths (to import both chapter files and images files) whenever you include a new chapter.



        \def\GraphicsPath{\ChapterPath Images/}%

    \includegraphics[#1]{\GraphicsPath #2}}    



\chapter{Chapter One}



  1. Folder Chapter-1 is in Docoment-Root folder.

  2. Chapter-1.tex is in folder Chapter-1.

  3. Tulips.jpg is in folder Chapter-1/Images.


  1. If your TikZ code is not "linked" to the text with nodes, for example, then put such TikZ code into a separate, compilable input file. Use article document class plus preview to get a tight PDF output. You can also use standalone document class instead.

  2. If you table is not long enough to span across multiple pages, then put it into a separate, compilable input file to get a tight PDF output.

  3. It is better not to specify the image extension explicitly when invoking \includegraphics.

  4. Define macros for often-used materials and put them into a package such that you can change their definition later in one place and the changes effect the whole document.

share|improve this answer
See also my another answer here. – kiss my armpit Nov 9 '13 at 9:28
Will these macros work with import or subimport as well ? – Anusha Aug 4 '14 at 14:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.