2

I am a new beamer user and I am not sure what is going wrong when I am trying to add a Tikz picture on a slide of my beamer presentation, it keeps going on a different frame (i.e. slide) than I want it to. How would I fix this issue?

\begin{frame}
\frametitle{Introduction} % Table of contents slide, comment this block out to remove it
\tableofcontents % Throughout your presentation, if you choose to use \section{} and \subsection{} commands, these will automatically be printed on this slide as an overview of your presentation
\end{frame}

%---------------------------------------------------------------------------------------- % PRESENTATION SLIDES %----------------------------------------------------------------------------------------

%------------------------------------------------ \begin{frame} \section{Section 1}

\subsection{Description.}

\begin{tikzpicture}[ dot/.style={circle,fill, inner sep=1.5pt, outer sep=0pt}, every label/.style={inner sep=0pt}] \newdimen\R \R=1cm

\foreach \i [count=\j] in { 1,2,3,4,5,6} { \node (n\j) [dot, label=60\j:$\i$] at (60\j:\R) {}; \draw[blue,thick] (0,0) -- (n\j); }

{ \foreach \i in {1,2,...,6} \foreach \j in {\i,...,6} \draw (n\i) -- (n\j); } \end{tikzpicture}

\section{Section 2}

\end{frame}

enter image description here

  • If I do \documentclass{beamer} \usepackage{tikz} \begin{document} <your code> \end{document} I get a PDF with two slides, the first one has a table of contents, the second your diagram. Which is exactly what one would expect. What did you expect, and what do you get? – Torbjørn T. May 03 '21 at 21:34
  • I want to have the tikz image in the same frame as my text. – polygonlink1 May 03 '21 at 21:36
  • 2
    I think you're misunderstanding how beamer works. \section and \subsection are actually supposed to be added outside frame environments, and they don't add text to the presentation. If you want a title for the frame, use \frametitle{foo} after \begin{frame}. – Torbjørn T. May 03 '21 at 21:42
  • So how would I go about adding text and tikz images in the same frame? – polygonlink1 May 03 '21 at 21:44
  • Just add the text in the frame ... It's just that \section/\subsection won't be shown in the slides (except for the ToC), but there's nothing stopping you from writing normal text. – Torbjørn T. May 03 '21 at 21:46
  • 2
    I’m voting to close this question because solved in comments? – Dr. Manuel Kuehner May 04 '21 at 18:05
  • 1
    Maybe leave open? The question is answered in comments but in a very high-level way, a real answer may be useful. – Marijn May 04 '21 at 18:55

1 Answers1

4

To help close this question, I put together an MWE to show the differences between sectioning commands (\section and \subsection) and frame titles.

Also how to make a document, class article, (article mode) from a beamer presentation (presentation mode), hiding some frames.

Compiling the code will produce a beamer presentation of 6 frames (F1 to F6): the title (F1), the Overview (F2) showing the structure of sections and subsections using \tableofcontents (but not the list of frames!) and 4 additional frames with content.

The tikz figure is in the frame F4 Connections under the subsection Description.

The code is in beamer mode. Note that the \section and \subsection commands are used outside of the frame environment.

To switch to article mode comment \documentclass{beamer} and uncomment both \documentclass{article} and \usepackage{beamerarticle}.

Frame #5 was marked as \mode <presentation> so it will show in mode presentation, but not in mode article.

The result is a three-page article: a title page, the table of contents showing sections and subsections with the title used in the F2 Overview frame, and pages with the content, where the frame titles appear as \paragraph because for each frame issues a \paragraph*{<frame title>}.

Frame #5 does not appear under section 2, as expected.

Note that the \newpage and \bigskip commands, useful in article mode, had no effect in presentation mode.

To produce a list of frames in beamer mode see https://tex.stackexchange.com/a/56541/161015

Structure of the presentation

ex

Beamer frame #2 using \tableofcontents

b2

Beamer frame #4, the tikz figure

b4

Article mode, table of contents

a2

Article mode, the contents

a3

% !TeX TS-program = pdflatex

\documentclass{beamer} %Un-comment to produce a presentation

%\documentclass{article} %Comment to produce a presentation %\usepackage{beamerarticle} %Comment to produce a presentation

\usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{lmodern}

\usepackage{tikz} \usepackage{graphicx} % for logo

\usetheme{Madrid} \usecolortheme{beaver}

\renewcommand{\contentsname}{} % use the frame name

\begin{document}

\author{The author name}
\title{F1 Beamer template}
\logo{\includegraphics[height=0.8cm]{example-grid-100x100pt}}

% \setbeamertemplate{navigation symbols}{} % hide navigation symbols

\begin{frame}[plain] % cover F1
    \maketitle
    \newpage % works only in  article mode
\end{frame}

\begin{frame} \frametitle{F2 Overview} % Table of contents slide \tableofcontents % Throughout your presentation, if you choose to use \section{} and \subsection{} commands, these will automatically be printed on this slide as an overview of your presentation \newpage % works only in article mode \end{frame}

\section{Section 1}

\begin{frame}{F3 in Section 1} \bigskip% for article mode As any dedicated reader can clearly see, the Ideal of practical reason is a representation of, as far as I know, the things in themselves; as I have shown elsewhere, the phenomena should only be used as a canon for our understanding.

\end{frame}

\subsection{Description}

\begin{frame}{F4 Connections} \centering \bigskip% for article mode \begin{tikzpicture}[ dot/.style={circle,fill, inner sep=1.5pt, outer sep=0pt}, every label/.style={inner sep=0pt}] \newdimen\R \R=1cm
\foreach \i [count=\j] in { 1,2,3,4,5,6} {\node (n\j) [dot, label=60\j:$\i$] at (60\j:\R) {}; \draw[blue,thick] (0,0) -- (n\j); }
{\foreach \i in {1,2,...,6} \foreach \j in {\i,...,6} \draw (n\i) -- (n\j); } \end{tikzpicture} \end{frame}

\section{Section 2}

\mode<presentation>{ % % Only shown in presentation, \begin{frame}{F5 in Section 2}
Shown only in mode presentation. \end{frame} }

\begin{frame}{F6 in Section 2}
\bigskip % for article mode As I have shown elsewhere, Aristotle tells us that the objects in space and time, in the full sense of these terms, would be falsified.
\end{frame}

\end{document}

Simon Dispa
  • 39,141