I have a problem using labels together with the subfiles package. When I'm writing in one section and I try to reference to different section (or for that matter anything within that section) I get an undefined label error. My main.tex:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{graphicx}
\graphicspath{{images/}{../images/}}
\usepackage{subfiles}
\begin{document}
\maketitle
\section{Introduction}
\label{sec:intro}
\subfile{sections/CH1_Introduction}
\section{Theory of Ultrasound Anemometer}
\label{sec:theory}
\subfile{sections/CH2_Theory}
Then, for example, when I write in my 'introduction' section file:
In section \ref{sec:theory} the theory will be discussed ...
Which results in an undefined reference error. Can someone help me? Is the problem of the label command? Or am I doing something else wrong?

xrpackage, I think, might help. See http://tex.stackexchange.com/questions/14364/cross-referencing-between-different-files – Steven B. Segletes Dec 10 '14 at 15:41