I'm trying to put several short articles together. Each article has a title and multiple authors with corresponding affiliations. To handle this I use authblk and titling packages:
FirstFile.tex
\Title{First File}
\author[2]{B. Second\thanks{B@Second}}
\author[1]{A. Gonzales\thanks{A@Gonzales}}
\author[1,2]{C. Dosch}
\affil[1]{Test A}
\affil[2]{Test B}
\Content{Bla Bla Bla}
SecondFile.tex
\Title{Second file}
\author[1]{C. Iggy}
\author[2]{H. Uno\thanks{H@Uno}}
\affil[1]{Test 1}
\affil[2]{Test 2}
\Content{Bla Bla Bla}
ThirdFile.tex
\Title{Third File}
\author[1]{A. First}
\author[1,2]{M. Middle\thanks{M@Middle}}
\author[2]{Z. Last}
\affil[1]{Test $\alpha$}
\affil[2]{Test $\beta$}
\Content{Bla Bla Bla}
main.tex
\documentclass{article}
%----
\makeatletter
\newcommand{\Content}[1]{\def\@Content{#1}}
\newcommand{\Title}[1]{\def\@Title{#1}}
\makeatother
%----
\usepackage{titling}
\pretitle{\begin{center}\Large\bfseries}
\posttitle{\par\end{center}\vspace{\baselineskip}}
%\preauthor{}
%\postauthor{}
%----
\usepackage{authblk}
\renewcommand\Authfont{\bfseries}
\renewcommand\Affilfont{\rm \sl\small}
%----
\date{}
%===================================% B E G I N %===================================%
\begin{document}
\input{FirstFile.tex}
\makeatletter
\title{\@Title}
\maketitle
\@Content
\global\let\AB@authlist\@empty
%\renewcommand\AB@authlist{}
\renewcommand\AB@affillist{}
\makeatother
\setcounter{affil}{0}
\setcounter{authors}{0}
\emptythanks
\clearpage
%===============
\input{SecondFile.tex}
\makeatletter
\title{\@Title}
\maketitle
\@Content
\renewcommand\AB@authlist{}
\renewcommand\AB@affillist{}
\makeatother
\setcounter{affil}{0}
\setcounter{authors}{0}
\emptythanks
\clearpage
%===============
\input{ThirdFile.tex}
\makeatletter
\title{\@Title}
\maketitle
\@Content
\renewcommand\AB@authlist{}
\renewcommand\AB@affillist{}
\makeatother
\setcounter{affil}{0}
\setcounter{authors}{0}
\emptythanks
\clearpage
\end{document}
When I compile main.tex I get the following error (twice; the other one is in line 61):
[1{C:/ProgramData/MiKTeX/2.9/pdftex/config/pdftex.map}] (SecondFile.tex)
! LaTeX Error: There's no line here to end.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.48 \maketitle
?
I noticed that if I don't reset AB@authlist and AB@affillist, the problem with the line ending doesn't appear. If I uncomment \preauthor{} and \postauthor{}, the problem is also gone but all authors and affiliations are aligned to the left. Putting \centering or \begin{center} \end{center} into \pre and \postauthor{} doesn't solve the alignment problem.
Does anyone know if there is another way to reset the content of AB@authlist and AB@affillist or what else might be causing the line ending problem?
I wouldn't have to use titling package if I could use \maketitle several times. Is it possible to modify \maketitle without titling package in such a way that it could be used multiple times?