3

I have a main document which calls several modules and also uses images from upper folders, this is the structure of the folders:

  • Icons
  • Common
    • Covers
  • Test
    • All
      • main.tex
    • Module
      • subfile.tex
      • Figures
        • figure.png

This is the code of the main:

\documentclass[10pt,twoside]{article}
\usepackage[a4paper,margin=3cm,bindingoffset=0.5cm,footskip=1.7cm]{geometry} %proper formatting for a4pages
\usepackage{graphicx} %allows the inclusion of graphics and resizing rotating etc.
\usepackage{fancyhdr} %allows use of complex headers and footers
\usepackage{caption}
\usepackage[T1]{fontenc}
\usepackage{pdfpages}
\usepackage[linktocpage=true,hypertexnames=true,hyperfootnotes=false,pdftex]{hyperref}
\usepackage{color}
\usepackage{subfiles} % allows inclusion of chapter files which can also be compiled stand-alone
\usepackage[all]{hypcap} 
\usepackage{watermark}
\usepackage{wallpaper}

\graphicspath{{../../Common/Covers/}} 


\begin{document}


\leftwatermark{\ThisCenterWallPaper{1.0}{bg-page-left.pdf}} %these are in folder covers
\rightwatermark{\ThisCenterWallPaper{1.0}{bg-page-right.pdf}}

% table of contents has own roman numeral numbering
\pagenumbering{roman}
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\headrulewidth}{1pt}
\renewcommand{\footrulewidth}{0pt}

\fancyhead[LE,RO]{\leftmark} % put the chapter name in the right hand corner
\fancyfoot[LE,RO]{\color{white}{\thepage}}
\fancyfootoffset[LE,RO]{2.5cm}
\fancyfoot[LO,RE]{\raisebox{-0.3cm}{Test}}
\fancyfootoffset[LO,RE]{0cm}

\tableofcontents                    % table of contents

\pagenumbering{arabic}

\pagebreak

\section{Introduction}
\label{sec:Intro}

A small introduction 

\pagebreak

\subfile{../Module/Subfile.tex} 


\end{document}

And this is the code of the subfile:

\documentclass[../All/main.tex]{subfiles}


\graphicspath{{\subfix{../../Icons/}}                %don't touch
             {\subfix{../Module/Figures/}}}    %change the name of the folder accordingly

\begin{document}

\section{Name of the Section}


\subsection{Name of the Subsection}


Use the icon \includegraphics[width=13px,height=9px]{/toolboxes/printpreview/pagenext.png} to jump to next page. %this figure is in the Icons folder

This figure is in the Figures folder inside the module

\begin{figure}[h]
    \centering
    \includegraphics[angle= 0, width=0.8\textwidth]{figure.png}
    \caption{Just a cat picture}
\end{figure}


\end{document}

It used to work with previous versions, but since I updated it does not work anymore. Can anybody help me?

1
  • Just one more clarification, I know that if I define the paths in the main and the subfile it works, but I would like to only define the figures path in the subfile, like before
    – fancy_docs
    Commented May 18, 2022 at 7:11

1 Answer 1

3

Between subfiles v1.x and subflies v2.x, there was a major change in the default behaviour. Load subfiles with the option v1 to get the old behaviour back.

\usepackage[v1]{subfiles}

In version v1.x, the \subfile command would processes also the preamble of the subfile as well as all the stuff after \end{document}, which for most users comes unexpected and has some peculiarities.

In version v2.x, the \subfile command includes only the stuff between \begin{document} and \end{document}. In your use case, the \graphicspath command in the preamble of the subfile will be ignored when loading the file with \subfile, and the figure will not be found. The package option v1 restores the old behaviour. For more information, see the documentation of the package.

You must log in to answer this question.

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