[Tex/LaTex] Custom command for begin-frame with package beamerarticle

beamerbeamerarticlemacros

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:
Wrong Layout

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

Best Answer

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}
Related Question