如何将 Tikzpicture 置于中心?

如何将 Tikzpicture 置于中心?

我正在使用在线找到的模板制作演示文稿。问题是我的 tikzpictures 没有位于中心。我试过了\centering\begin{center}但这并不能解决问题。

在此处输入图片描述

\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}

答案1

\centering要求命令后有一个空行才能正常工作。

请注意,最好在小组中完成此操作(尽管frame已经是一个小组)

\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}

在此处输入图片描述

相关内容