# Beamer article mode + amsart freezes latex

If i try to get an article from my beamer slide using article mode and amsart style, my compiler (pdfLaTeX, LaTeX) gets stuck in an infinite loop:

\documentclass{amsart}
\usepackage{beamerarticle}
\title{Test}
\author{Test}

\begin{document}

\begin{frame}
\frametitle{Test}
Test frame
\end{frame}

\end{document}


Replacing amsart by article in \documentclass{article} makes everything work well.

If I remove \title AND \author keeping amsart it also works... so

• is it a bug (from beamer)?
• is there a way to use beamer AND amsart AND keep the titlepage info?
-
Changing the order to \documentclass{amsart} \title{Test} \author{Test} \usepackage{beamerarticle} seems to work (but maybe some other things might break?). – Gonzalo Medina Mar 17 at 21:44
Welcome to TeX.sx! Usually, we don't put a greeting or a "thank you" in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Accepting and upvoting answers is the preferred way here to say "thank you" to users who helped you. – Peter Jansson Mar 17 at 21:55

Prepare a file named beameramsart.sty with the following contents:

\ProvidesPackage{beameramsart.sty}
\RequirePackage{etoolbox}

\newcommand{\baa@keepamsart}[1]{%
\@for\next:=#1\do{%
\csletcs{amsart\next}{\next}%
\csletcs{amsart@\next}{\expandafter\string\csname\next\endcsname}%
\expandafter\appto\expandafter\amsartnames\expandafter{\next,}%
}%
}
\newcommand{\baa@restoreamsart}{%
\@for\next:=\amsartnames\do{%
\csletcs{\next}{amsart\next}%
\csletcs{\expandafter\string\csname\next\endcsname}{amsart@\next}%
\csundef{amsart\next}\csundef{amsart@\next}%
}%
}

\baa@keepamsart{title,author,date}
\RequirePackage{beamerarticle}
\baa@restoreamsart

\@onlypreamble\baa@keepamsart
\@onlypreamble\baa@restoreamsart

\endinput


Save this file alongside your LaTeX document or in a place where TeX can find it; on a TeX Live distribution it can be the directory

~/texmf/tex/latex/beameramsart


where ~ stands for your home; on Mac OS X with MacTeX it would be

~/Library/texmf/tex/latex/beameramsart


\documentclass{amsart}
\usepackage{beameramsart}

\begin{document}

\title{Test}
\author{Test}

\maketitle

\begin{frame}
\frametitle{Test}
Test frame
\end{frame}

\end{document}


The problematic commands are saved before loading beamerarticle and restored afterwards; the way of saving them is a bit convoluted because of the reasons given by Joseph.

-
 It works fine, so i can continue using \input{main.tex} in separate master files for article / handout / slides without having to repeat title & author in all master files, keeping DRY is great :-) – jmbarbier Mar 17 at 22:53

This is what I would describe as an 'issue' in beamer, in that it's more properly a bug but one that it's not really safe to fix. What is happening is that \title is normally a very simple command:

\documentclass{article}
\show\title

> \title=macro:
#1->\gdef \@title {#1}.


but amsart redefines it as a 'robust' command. That is normally fine, but beamer makes a copy of \title and installs a new definition. When Till Tantau wrote beamer, he did not anticipate needed to handle robust commands, so the way that the copy is made then leads to a circular definition.

The reason I class this as an 'issue' rather than a bug is that at this stage (beamer has been in use for many years) it's not really possible to alter the code in this area without almost certainly badly breaking some documents. Thus all that can be done is to live with the problem. As pointed out in comments, setting the \title and \author before beamer gets involved is probably the best way out of this.

\documentclass{amsart}
\title{AN Other}
\author{Test}
\usepackage{beamerarticle}

\begin{document}
\maketitle
\begin{frame}
\frametitle{Test}
Test frame
\end{frame}

\end{document}

-