3

I've been poking around on here trying to work out the best way of keeping my individual chapters and their associated figures in subdirectories. After reading a few threads I've been testing out chapterfolder and import (example at the bottom). Is there any particular advantage to using one or the other? Both seem extremely similar. Thus far the only differences seem to be:

  • The need for a workaround for \includegraphics with chapterfolder
  • chapterfolder automatically inserts the chapter title, whereas I'd need to do that manually with import.

Given that the latter might actually be an advantage (e.g. if I wanted to process the chapter individually without the parent document), I'm currently leaning towards import. Is there anything I'm missing?

Exmple below: what I'd really like to do is not have to add the subdirectory figures to each of my \includegraphics{figures/fig1.pdf} commands - I have a lot of figures to do this for manually, but I am pretty sure there is no way to define a \graphicspath for each subdirectory individually - am I right?

Example:

parent directory contains:
main.tex
subfolder/sub.tex
subfolder/figures/fig1.pdf

where subfolder/sub.tex consists of:

text

\begin{figure}
  \includegraphics{figures/fig1.pdf}
  \caption{caption}
\end{figure}

and main.tex consists of:

Option 1

\documentclass[12pt]{report}

\usepackage{graphicx}    % needed for including graphics
\usepackage{import}

\begin{document}

\subimport{introduction/}{introduction.tex}

\end{document}

or Option 2

\documentclass[12pt]{report}

\usepackage{graphicx}    % needed for including graphics
\usepackage{chapterfolder}
% and we re-write includegraphics
\let\includegraphicsWithoutCF\includegraphics
\renewcommand{\includegraphics}[2][]{\includegraphicsWithoutCF[#1]{\cfcurrentfolder#2}}

\begin{document}

\cfchapter{Introduction}{introduction}{introduction.tex}

\end{document}
3
  • I guess nobody has any opinions on this. I'm sticking with import for now. And going through all my documents typing "figures/" a lot of times...
    – FionaSmith
    Feb 10, 2014 at 11:57
  • Did you find a better solution for this ? I am also having the same problem. Would be great help to know. Thanks.
    – Anusha
    Jul 28, 2014 at 12:40
  • @Anusha As I said in that comment on Feb 10, I stuck with \subimport since nobody pointed out any obvious downsides. If you are just starting up, it's not so much of a big deal to add a subdirectory pointing to the graphics location in each \includegraphics statement. It was a bit annoying for me as I already had quite a lot of work in standalone files I was wanting to incorporate, but it didn't take too long to convert. Sorry for the delay in replying, I was on holiday!
    – FionaSmith
    Aug 4, 2014 at 9:19

1 Answer 1

1

I have been trying to get the same thing done, and here is what has worked for me (if you haven't already figured something out). My situation is similar in that I have a main thesis folder, and then chapter sub folders with additional figure subfolders. The structure is something like:

  • Main Dir
    • mainthesis.tex
    • Chapter1 Dir
      • Chapter1.tex
      • Figures
        • YouCanDoIt.pdf

With as many chapter folders as needed. I'm using the import package (like you are I believe). A simplified version of mainthesis.tex is:

\documentclass[12pt]{article}  %12pt is larger than 11pt

\usepackage{import}
\usepackage{graphicx}
\usepackage{letltxmacro}

% save the meaning of \includegraphics
\LetLtxMacro\latexincludegraphics\includegraphics

% redefine \includegraphics to refer to the subfolder Figures
\renewcommand{\includegraphics}[2][ ]{\latexincludegraphics[#1]{Figures/#2}}

%========= Main Document ============
\begin{document}

\subincludefrom{Chapter1/}{Chapter1}

\end{document}

Where Chapter1.tex looks something like

\section{Introduction}

\subsection{This is the first subsection}
\begin{figure} 
\centering
\includegraphics[width=0.5\textwidth]{YouCanDoIt}
\caption{Motivational Graphic.}
\end{figure}

As far as I can tell, the only limitation with this approach is that all figures in the entire document need to be located in a "Figures" subdirectory to the current working directory. I hope this helps.

1
  • Thanks @brewsclues: it is precisely that limitation that I can't work with! I have a lot of figures and it does my head in having them all in one directory. So I have stuck with my Option 1 above: I've now gone through and added the subdirectory path to all my \includegraphics calls anyway, so no point switching method now!
    – FionaSmith
    Mar 21, 2014 at 8:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .