# How do I only call \maketitle if \title{} has been called

I'm merging 5-10 pandoc generated tex files using the docmute package. The individual files build, however when I \subimport or \input them into my main document I get an error:

! LaTeX Error: No \title given


This is because everything outside the \begin{document}...\end{document} is stripped by docmute, so \title{} is not called for the individual documents when merging. Actually, I don't want to call \maketitle at all for the merged documents.

How can I conditionally use maketitle? I've tried various \if combinations, including things like:

\ifdef{\@title}{\maketitle}{}


The initial state of \@title is not that it is undefined, it is defined by

\def\@title{\@latex@error{No \noexpand\title given}\@ehc}


so you want

\makeatletter
\def\zz@title{\@latex@error{No \noexpand\title given}\@ehc}

\ifx\zz@title\@title
% do nothing
\else
\maketitle
\fi

\makeatother