[Tex/LaTex] Two \maketitle in the document: an issue with \thanks

titles

I need to have two \maketitles in a document. The titling package handles this almost perfectly. The issue is that I use the \thanks command in the \title and in the \author, and then, in the second \maketitle, the text of the \thanks command is repeated twice. Does anyone know how I can get rid of the second occurrence of the text of the \thanks command?
Thanks,
Eilon

\documentclass[12pt]{article}
\usepackage{titling}
\begin{document}

\begin{titlepage}
\title{First title\thanks{I thank my kids.}}
\author{Author1\thanks{Affiliation of author1. } and Author2\thanks{Affiliation of author2.}}
\maketitle
\end{titlepage}

\begin{titlepage}
\title{Second title}
\maketitle
\end{titlepage}
\end{document}

Best Answer

LaTeX collects all footnotes added by \thanks commands in a macro \@thanks; it has to be emptied before typesetting the second title. To avoid that the second title page resets the page counter, we use the xpatch package and modify the titlepage environment; this is a hack, though. Alternatively, you can set the page number manually using \setcounter{page}{... desired page number ...}.

\documentclass[12pt]{article}
\usepackage{titling}
\usepackage{xpatch}
\makeatletter
\newenvironment{mytitlepage}%
  {\begin{titlepage}\def\@thanks{}}%
  {\end{titlepage}}
\xpatchcmd\titlepage{\setcounter{page}\@ne}{}{}{}
\xpatchcmd\endtitlepage{\setcounter{page}\@ne}{}{}{}
\makeatother
\begin{document}

\begin{mytitlepage}
\title{First title\thanks{I thank my kids.}}
\author{Author1\thanks{Affiliation of author1.}
    and Author2\thanks{Affiliation of author2.}}
\maketitle
\end{mytitlepage}

\begin{mytitlepage}
\title{Second title}
\maketitle
\end{mytitlepage}
\end{document}
Related Question