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:

/DocumentRoot
 |-main.tex
 |-title.tex
 |
 |-/chapter-1
 |  |-/images
 |  |-chapter-1.tex
 |
 |-/chapter-2
    |-/images
    |-chapter-2.tex


My document is like this:

\begin{document}
\include{./title}
\include{./chapter-1/chapter-1}
\include{./chapter-2/chapter-2}
\include{./chapter-3/chapter-3}
\end{document}


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:

\includegraphics[width=\linewidth]{./chapter-3/images/img.jpg}


and this doesn't

\includegraphics[width=\linewidth]{./images/img.jpg}


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.


Question: options under dropdown menu is not getting selected
Answer: The issue is probably that there is a change listener on the select box which doesn't get called, because setting the selectedIndex property doesn't trigger a change.

A reliable way to trigger this change is to use jQuery's change():

this.evaluate(function() {
    var form = document.querySelector('.form-control');
    form.selectedIndex = 2;
    $(form).change();
});


If you don't already have jQuery in the page, you can inject it like this if you have jQuery locally:

var casper = require('casper').create({
    clientScripts: [ "jquery.min.js" ]
});


or if you don't have it locally:

var casper = require('casper').create({
    remoteScripts: [ "http://code.jquery.com/jquery-2.1.3.min.js" ]
});