3

I am making a presentation, using a template I found online. The problem is that my tikzpictures are not getting in the center. I have tried \centering, \begin{center}. But that does not solve the problem.

enter image description here

\documentclass{beamer}

\usetheme{Madrid}

\usepackage[utf8]{inputenc}
\usepackage[swedish]{babel}
\usepackage{float}
\usepackage{subfig}
\usepackage[]{mcode}
\usepackage{verbatim}
\usepackage{tikz}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{graphicx}
\usepackage[]{mcode}
\usetikzlibrary{calc}
\usepackage{float}
\usepackage{amssymb}

\title{}

\author{}

\date{}

\AtBeginSubsection[]
{
  \begin{frame}<beamer>{Outline}
    \tableofcontents[currentsection,currentsubsection]
  \end{frame}
}


\begin{document}

\begin{frame}{Fortsättning delproblem 3\dots}
\begin{tikzpicture}
  [
    scale=1,
    >=stealth,
    point/.style = {draw, circle,  fill = black, inner sep = 1pt},
    dot/.style   = {draw, circle,  fill = black, inner sep = .2pt},
  ]

  % Punkterna R1, R2 och S
  \node (n1) at (-2,2) [point, label = below:$R_{1}$] {};
  \node (n2) at (-3,0) [point, label = {below right:$R_{2}$}] {};
  \node (n4) at (0,0)   [point, label = {below left:$S$}] {};
\end{tikzpicture}
\end{frame}

\end{document}
  • \centering requires an empty line – user31729 Mar 6 '16 at 18:06
1

\centering requires an empty line after the command to work correctly.

Please note that this should be done best in a group (although frame is a group already)

\documentclass{beamer}

\usetheme{Madrid}

\usepackage[utf8]{inputenc}
\usepackage[swedish]{babel}
\usepackage{float}
\usepackage{subfig}
\usepackage[]{mcode}
\usepackage{verbatim}
\usepackage{tikz}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{graphicx}
\usepackage[]{mcode}
\usetikzlibrary{calc}
\usepackage{float}
\usepackage{amssymb}

\title{}

\author{}

\date{}

\AtBeginSubsection[]
{
  \begin{frame}<beamer>{Outline}
    \tableofcontents[currentsection,currentsubsection]
  \end{frame}
}


\begin{document}

\begin{frame}{Fortsättning delproblem 3\dots}
\begingroup
\centering

\begin{tikzpicture}
  [
    scale=1,
    >=stealth,
    point/.style = {draw, circle,  fill = black, inner sep = 1pt},
    dot/.style   = {draw, circle,  fill = black, inner sep = .2pt},
  ]

  % Punkterna R1, R2 och S
  \node (n1) at (-2,2) [point, label = below:$R_{1}$] {};
  \node (n2) at (-3,0) [point, label = {below right:$R_{2}$}] {};
  \node (n4) at (0,0)   [point, label = {below left:$S$}] {};
\end{tikzpicture}

\endgroup
\end{frame}

\end{document}

enter image description here

  • \begin{center} ... \end{center} also works, with the usual caveats (extra space may be unwanted). – Mike Renfro Mar 6 '16 at 18:07
  • @MikeRenfro: Yes, because of the vertical spacing I did not use \begin{center}...\end{center} – user31729 Mar 6 '16 at 18:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.