# Custom command for begin-frame with package beamerarticle

I want to use one latex-document for an article and beamer-frames. For this I'm using the beamer-article-package.

I noticed that the titles of the beamer-frames are also shown in the article and I don't want this. I search the internet and found a way to modify the beamer-template (in article-mode). Nevertheless, this sometimes disturbs my document-structure in combination with the hyperref package.

So I thought the easiest way would be to use a custom command to define my frame content, but unfortunately this doesn't work as expected, because no frames are created with my custom commands (I also tried it with \newenvironment, but got the same results).

So the question is: What is the problem with my own command to enclose a the begin- and end-frame-command?

Example-Code which produces only one output-frame:

% Comment lines below and uncomment this for beamer
\documentclass[ignorenonframetext]{beamer}

% Comment above and uncomment below for article
%\documentclass[12pt,titlepage,a4paper,fleqn]{article}
%\usepackage{beamerarticle}

\mode<presentation>
{
\newcommand{\MBF}[1]{\begin{frame}{#1}}
\newcommand{\MEF}{\end{frame}}
}

\mode<article>
{
\newcommand{\MBF}[1]{}
\newcommand{\MEF}{}

% You can use this to hide the title, but this disturbs the layout sometimes.
%\setbeamertemplate{frametitle}{}
}

\begin{document}

\begin{frame}{Testframe 1}
First test page
\end{frame}

\MBF{Testframe 2}
Second test page
\MEF
\end{document}


**EDIT: **

As request an example of the broken layout.

Image:

Source:

    \paragraph{Das Kamerakoordinatensystem}

Zusätzlich zu dem Objekt- und Weltkoordinatensystem existiert das Kamerakoordinatensystem. Das Kamerakoordinatensystem beschreibt eine Kamera im Weltkoordinatensystem. \\
Theoretisch könnte das Kamerakoordinatensystem ersetzt werden, indem man alle Geometrien im Weltkoordinatensystem entsprechend transformiert. Aus Gründen der Einfachheit ist es allerdings empfehlenswert ein Kamerakoordinatensystem zu verwenden.

\begin{frame}{Das Kamerakoordinatensystem}
\begin{figure}[H]
\centering
\includegraphics[width=0.8\textwidth]{Images/MathematicalBasics/Koordinatensysteme/Kamerakoordinatensystem}
\caption{Das Kamerakoordinatensystem}
\label{img:mathbasics:kamerakoordinatensystem}
\end{figure}
\end{frame}


Edit 2:

As requested the source code for creating the layout-problem-result: http://pastebin.com/8hgcBfGK

• Bad idea! This will likely cause more problems then it solves. Instead you can just redefine the frametitle in article mode. Mar 16, 2017 at 8:50
• Can you instead show an example where the empty frametitle template disturbs the layout? Mar 16, 2017 at 8:53
• Sure! See my edit. Mar 16, 2017 at 9:07
• Thanks for posting the code. Can you make something compilable that reproduces your problem? I tried to add random text of many different lengths, but I did not manage to create this page break. Maybe a other floating options might help, for example [htbp], but this is just a guess. Mar 16, 2017 at 9:36
• Yes, you can get the code via the added link in the question. When I compile here I get the effect between page three and four. Mar 16, 2017 at 10:23

I would definitely advise against creating a custom command to wrap the frame in. In the long run this causes much more trouble then it solves.

Furthermore it will not cure the underlying problem, as your [H] floating specifier just does give tex any other options then to produce this ugly page break. A few other possibilities:

• use other floating specifier, such as [tbph] which allows the image to be at the top of a page (I would take this option)

• or force all the text on the previous page with \clearpage

%\documentclass[ignorenonframetext]{beamer}

\documentclass[12pt,titlepage,a4paper,fleqn]{article}
\usepackage{beamerarticle}

\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{float}
\usepackage{hyperref}
\usepackage{geometry}
\usepackage{lipsum}
\usepackage{tikz}

\mode<article>
{
\usepackage{fancyhdr}

\setbeamertemplate{frametitle}{}

% Seitenränder definieren
\geometry{a4paper, top=28mm, left=20mm, right=20mm, bottom=40mm, headsep=14mm, footskip=12mm}
}

\begin{document}
\pagestyle{fancy}

\lipsum
\begin{frame}
\begin{figure}[H]
\centering
\begin{tikzpicture}
\draw (0,0) -- (10,10);
\end{tikzpicture}
\end{figure}
\end{frame}

\lipsum
\clearpage
\begin{frame}
\begin{figure}[H]
\centering
\begin{tikzpicture}
\draw (0,0) -- (10,10);
\end{tikzpicture}
\end{figure}
\end{frame}
\lipsum

\newpage

\lipsum
\begin{frame}{Test Frame Title}
\begin{figure}[H]
\centering
\begin{tikzpicture}
\draw (0,0) -- (10,10);
\end{tikzpicture}
\end{figure}
\end{frame}

\lipsum
\begin{frame}{Test Frame Title}
\begin{figure}[htbp]
\centering
\begin{tikzpicture}
\draw (0,0) -- (10,10);
\end{tikzpicture}
\end{figure}
\end{frame}

\lipsum

\end{document}

• Any other idea? Because I actually want to have the figures directly below my text. And I don't want to have a page break before every figure (that would happen when using \clearpage, right?). Mar 16, 2017 at 10:57
• @ThomasSpranger The other idea is to have floating figures. Mar 16, 2017 at 12:09
• Sorry if I get this wrong, but when you mean floating, then the figures won't be next to the places where I define them (!= H modifier). But this is exactly what I want! Mar 16, 2017 at 12:32
• @ThomasSpranger But then you have to have the empty space on the bottom of the previous page, as a) there is not enough room for the image and b) no other text can be there. This means either using \clearpage or another floating barrier. Mar 16, 2017 at 12:36
• I'm aware of that, but my problem is that the last line of the text is put on the next page (with the figure)! Mar 16, 2017 at 13:13