I have a master document and for each chapter a separate file like:
main.tex
% preamble etc.
\input{chapter1}
\input{chapter2}
\input{chapter3}
% and so on
chapter1.tex
% Some figure with a label, tex code not shown, just the label
\label{fig:chicken}
% Some figure with a label, tex code not shown, just the label
\label{fig:monkey}
This two-legs animal is a chicken as shown in \cref{fig:chicken} % OK! Works within the same chapter! fig. 1
chapter2.tex
Here I like to refer to \ref{fig:monkey} % results in ??
Referring to a label in another chapter results in a double question mark (I did compile multiple times). LyX has the option to set a master document for each "included" tex-file. Document > Settings > Select default master document.
How can I do this in TeXstudio? I've already set main.tex as the master document but can't find a way to refer from its childs back to the master document like in LyX.
Best Answer
It's important to add the \label{} after or inside \caption{}
main.tex
chapter1.tex
chapter2.tex
Output