I am assembling my final dissertation from some articles I have written over the past years. I am using subfile and a main.tex file to collect all the preambles in one place and just plug in all the articles. Every individual article/chapter sits in its own folder with a bunch of other subfiles and images, while the massive bib file that I use for all projects sits in the upper level folder with respect to main.tex. A schematic folder tree can be the following:
- all_tex_projects folder
bibliography.bib- thesis folder
main.tex- chap1 folder
chap1.tex- plots folder with some files
- chap2 folder
chap2.tex- tabs folder with external
tex - plots folder with some graphs
I would like to be able to compile single files individually as well as the main document, with graphs, external tables, and bibliographic references (although the full list of references will be only on the compiled main document). I found ways of having the plots paths change but that breaks the references and vice versa. Is there a comprehensive, elegant solution to this?
MWE:
MAIN.tex
\documentclass{report}
\usepackage[backref=true,
backend=biber,
style=authoryear-comp,
url=false,
doi=false,
isbn=false,
eprint=false,
language=auto,
natbib=true
]{biblatex}
\addbibresource{../bibliography.bib}
\usepackage{csquotes}
\usepackage{subfiles}
\begin{document}
\chapter{Chapter I}
%\graphicspath{{./chap1/plots}{plots/}}
\subfile{./chap1/chap1.tex}
\chapter{Chapter II}
%\graphicspath{{./chap2/plots}{plots/}}
\subfile{./chap2/chap2.tex}
\end{document}
Chap1.tex
\documentclass[../main.tex]{subfiles}
\begin{document}
Some text with a citation from the all-encompassing bib \citep{item} to illustrate next table \ref{tab_in_chap2} with relative path
subfile{../chap2/tables/table.tex}
and a plot too, local to this file
\begin{figure}
\includegraphics{./plots/a_plot.pdf}
\end{figure}
Last, a piece of tex from this local folder
\subfile{./chap1/tables/tab.tex}
\end{document}
subfilesis lost: I'd need to keep track manually of all packages and repeat the preamble every time. I wonder if there's a sweet spot that strikes simplicity and flexibility. – Ceschi Oct 05 '20 at 23:56docmuteyou also only have to worry about ONE preamble, that of the main document. To share this preamble (or only part of it) with child documents to be compiled independently, is as easy as put it in a separate file and\inputit in each document. The problem here could be references to external documents, You can use xr-hyper for this, but I switch external to internal references when used as child documents is another story. – Fran Oct 06 '20 at 07:00docmuteandimportwould handle the .bib file upstream themainfile... – Ceschi Oct 07 '20 at 19:07refsegment=chapterand then\printbibliography[segment=\therefsegment, heading=subbibliography ]at the end of each chapter? Another way could be \begin{refsection}\subimport{whatever/}{whatever} \end{refsection} in the main document ad just\printbibliographyat the end of the subdocuments. – Fran Oct 08 '20 at 00:50