\documentclass{article}
\usepackage{filecontents}
\usepackage{subfiles}
\usepackage{localpackage}

\begin{document}
\subfile{sub/sub.tex}

b
\end{document}
