I've been trying to use a template I developed in Overleaf in Texmaker for my thesis. I would like to use the subfiles package so I can compile parts of my (eventually) large document separately, where I would also like the bibliography (produced using biblatex) printed for used citations either when compiling a subfile or when compiling the main file.

I implemented this in Overleaf using the example in the documentation of subfiles https://mirror.apps.cam.ac.uk/pub/tex-archive/macros/latex/contrib/subfiles/subfiles.pdf In section 3.3 for conditional execution of commands.

It is my understanding that when using the package, calling:


At the beginning of the subfile allows it to refer to the main.tex file, and draw the preamble from that file. When I compile the subfile however Texmaker returns an error indicating it cannot find the .bib for the bibliography. The directory structure of my project is as follows:

  • template.sty
  • main.tex
  • thesis.bib
  • /sections/section1.tex

The path for for the bibliography is set in template.sty to be /addbibresource{./thesis.bib}. In Overleaf this works without issue, but in Texmaker I think the when compiling a subfile only it cannot see into the correct directory. The problem is resolved if I move the thesis.bib into the /sections/ folder but this then causes a problem when compiling main.tex. Why does this problem occur and how can I resolve it? Thanks in advance.

Edit - adding code

This is template.sty:

%~~~~~~~~~~~~~~~~~~Bibliography stuff~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

%~~~~~~~~~~~~~~~~~Acronyms and Nomenclature Definitions~~~~~~~~~~~~~~~~~~~~~~~~~~~
% nomenclature:
    name = $t$ ,
    description = test variable,


This is main.tex:







This is thesis.bib:

author = {Huang, Chen-Fen},
school = {National Sun Yat-Sen University},
title = {{Acoustic Wave Scattering from Rough Sea Surface and Seabed}},
year = {1998}

And this is section1-2.tex, which is in the /sections/ folder:

\section{Another section}

Test citation \cite{Huang1998}.

Test glossary \gls{test}.


Glossaries is included as it's part of the compiler recipe I'm running: lualatex -> biber -> makeglossaries -> lualatex -> lualatex

Hope that's clear, thanks again.

  • 1
    Welcome. // Please try to prepare the required 4(?) short files, which will demonstrate your problem in your local installation and post them, i.e. EDIT and add them to your question. Thank you
    – MS-SPO
    Dec 13, 2023 at 16:42

1 Answer 1


In template.sty, replace the line \addbibresource{./thesis.bib} by


This is explained in section 3.2 of the subfiles documentation.

The command \subfix is defined by subfiles.sty, so you have to load this package before, e.g. by reordering the commands in the preamble of main.tex to


Note: It may be easier to use \input statements and comment signs to compile only parts of the document. Use a main file like


By commenting and uncommenting the \input statements it is easy to control which parts of the document are typeset. If you have a really large document, you can repeat this structure one level below in chapters/chapter1:


With this approach, only the main file contains a preamble, and all paths are relative to the main file. If you want to keep the paths relative to the subdirectories, you can use the import package and \import the files instead of \inputting them.

Only if you absolutely need to include files that are complete LaTeX documents themselves, the subfiles package is required to skip the sub-preambles.

You must log in to answer this question.

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