Take the 2-minute tour ×
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.

Is there a way to use subfiles, in a way that you can compile the middle chapters, let me explain by example.

main.tex (root folder)
--Chapter 1 (Chapter 1 folder)
----Section 1.1 (Chapter 1 folder)

Capter 1 is subfile in main.tex
Section 1.1 is subfile in Chapter 1 docment

What I can do is that I can build and view every section, and the main.tex, but I cannot build Chapter on its own. The code:

%main.tex
\usepackage{subfiles}
\begin{document}
\subfile{chap1/chapter1}
...
\end{document}

%chapter1.tex
\documentclass[../main.tex]{subfiles}
\begin{document}
\chapter{Introduction}
\subfile{chap1/purpose}
...
\end{document}

%purpose.tex
\documentclass[../main.tex]{subfiles}
\begin{document}
\section{Purpose}
\end{document}

The trouble I am in stems from the relative paths I believe, if I change the subfile in the chapters to:

\subfile(../chap1/purpose)

I can build the chapter and view it. But then it won't work from the main.tex files. Any idea how to do it right ?

Edit: If there is a method or command to get the absolute path, I would be able to solve it easily, is there such a thing ?

share|improve this question
add comment

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.