beamer – Using Subfiles Package for Beamer Documents

beamersubfiles

When using subfiles package for beamer documents, I got wrong header bars in frames of sub files. My main file is as follows:

% main.tex
\documentclass{beamer}
\usepackage{subfiles}
\begin{document}
\subfile{sub}
\end{document}

And the sub file is as follows:

% sub.tex
\documentclass[main]{subfiles}
\begin{document}
\begin{frame}
\frametitle{Hello}
Hello World!
\end{frame}
\end{document}

The result of sub.pdf is wrong. What's the problem with subfiles package?

enter image description here

Best Answer

Instead of subfiles (which I think uses standalone) you can directly use standalone and its support to beamer presentations. Try with:

% main.tex
\documentclass{beamer}
\usepackage{standalone}% <--------
\usetheme{Warsaw}
\begin{document}
\input{sub}%<---- input not include
\end{document}

and

% sub.tex
\documentclass[beamer]{standalone}%<-- standalone instead of subfiles
\begin{document}
\begin{frame}%<---- (or standaloneframe, I'm not sure)
\frametitle{Hello}
Hello World!
\end{frame}
\end{document}