# use bib2gls in individually compiled subfiles

I am trying to use the glossaries-extra package with record (using bib2gls) option for a symbols list in a long document where each chapter can be compiled individually using the subfiles package.

My folder looks like this :

• main.tex
• symbols.bib
• sections :
• chapter1.tex

and here is my MWE :

• main document
\documentclass{article}
\usepackage{subfiles}
\usepackage[record]{glossaries-extra}

\begin{document}
\section{Main document}

Here is some main text. I can reference \gls{test}.

\subfile{./sections/chap1.tex}
\end{document}

• symbols.bib example :
@symbol{test,
name = {test},
description = {symbol description}
}

• chapter1 subfile :
\documentclass[../main.tex]{subfiles}
\begin{document}
\section{Section 1}

I want to reference \gls{test}, it will print fine in main file but I will only get ?? in subfile when compiled individually.
\end{document}


The recipe to compile the main file is, after every file has been saved to do :

pdflatex main
bib2gls main
pdflatex main


and here both references are printed correctly which makes sense because the main will include the subfiles and knows where the .bib is, but when I do :

cd sections/
pdflatex chapter1
bib2gls chapter1
pdflatex chapter1


I get an error saying that it can't find the .bib, and the pdf will print ?? instead of the symbol.

My question is : is there a way to specify the .bib access path in each subfile ?

This way i would produce a chapter1.glstex in the sections/ folder and I guess it would reference the symbols correctly.

• Welcome to TeX.SX! Can you please include some sample symbols.bib file? The preamble of your main document specifies it (\GlsXtrLoadResources[src={symbols}]), but since it is missing, bib2gls gives the Error: symbols.bib (No such file or directory). Jul 8 at 7:51
• Thank you for your answer, I modified my question to include the .bib file Jul 8 at 8:24

Whenever an error message of LaTeX or an external program indicates that a file cannot be found, the reason may be that the missing file has to be addressed by varying pathes, depending on which file is typeset. In such a case, it may help to apply the command \subfix to the file or path names. Examples: [...]
In your case, bib2glg complains about not finding symbols.bib when processing chap1. To fix it, use
\GlsXtrLoadResources[src={\subfix{symbols}}]

in main.tex; note the added \subfix.