[Tex/LaTex] Macros for redefining \maketitle

macrostitlestitling

I have a document with multiple \maketitle tags. I would like macros that will allow me to redefine the title with a single command. While the code below produces the output I want,

\documentclass{article}
\usepackage{titling}

\begin{document}

\makeatletter
\def\maketitle{%
\par\textbf{\@title}%
\par{\@author}%
\par}
\makeatother

\title{First title}
\maketitle

\makeatletter
\def\maketitle{%
\par\textit{\@title}%
\par{\@author}%
\par}
\makeatother

\title{Second title}
\maketitle

\end{document}

I really need to have macros that encapsulate the redefining of \maketitle. I would like something like this to work:

\documentclass{article}
\usepackage{titling}

\newcommand{\mytitleOne}{\makeatletter
\def\maketitle{%
\par\textbf{\@title}%
\par{\@author}% 
\par}
\makeatother}

\newcommand{\mytitleTwo}{\makeatletter
\def\maketitle{%
\par\textit{\@title}%
\par{\@author}%
\par}
\makeatother}


\begin{document}

\mytitleOne
\title{First title}
\maketitle


\mytitleTwo
\title{Second title}
\maketitle

\end{document}

Best Answer

\documentclass{article}
\usepackage{titling}

\makeatletter
\newcommand\settitlebf{%
\def\maketitle{%
    \par\textbf{\@title}%
    \par\@author%
    \par}
}

\newcommand\settitleit{%
\def\maketitle{%
    \par\textit{\@title}%
    \par\@author%
    \par}
}
\makeatother

\begin{document}

\settitlebf
\title{Title One}
\maketitle

\settitleit
\title{Title Two}
\maketitle

\end{document}
Related Question