我想知道如何制作幻灯片中垂直居中的图表。该图表是使用 tikz 绘制的。代码如下。非常感谢!
\documentclass[usenames,dvipsnames,xcolor=table]{beamer}
\mode<presentation>
{
\usetheme{AnnArbor} % or try Darmstadt, Madrid, Warsaw, ...
\usecolortheme{wolverine} % or try albatross, beaver, crane, ...
\usefonttheme{default} % or try serif, structurebold, ...
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{caption}[numbered]
}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{datetime}
\usepackage{caption}
\usepackage{subfigure}
\usepackage{comment}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{hyperref}
\definecolor{plum(traditional)}{rgb}{0.56, 0.27, 0.52}
\definecolor{darkpastelgreen}{rgb}{0.01, 0.75, 0.24}
\definecolor{hotpink}{rgb}{1.0, 0.41, 0.71}
\definecolor{lavenderindigo}{rgb}{0.58, 0.34, 0.92}
\definecolor{mygray1}{gray}{0.8}
\definecolor{mygray2}{gray}{0.6}
\definecolor{mygray3}{gray}{0.4}
\definecolor{mygray4}{gray}{0.2}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage[style=authoryear]{biblatex}
\addbibresource{Distraction_slides_reference.bib}
\usepackage{tikz}
\usetikzlibrary{patterns,arrows,decorations.pathreplacing,calc,intersections,through,backgrounds}
\usepackage{slashed}
\usepackage{upgreek}
\newdimen\XCoord
\newdimen\YCoord
\newcommand*{\ExtractCoordinate}[1]{\path (#1); \pgfgetlastxy{\XCoord}{\YCoord};}%
\newtheorem{proposition}{Proposition}
\newtheorem{assumption}{Assumption}
\newtheorem*{axiom}{Axiom}
\newtheorem*{definition*}{Definition}
\newtheorem*{theorem*}{Theorem}
\newtheorem*{lemma*}{Lemma}
\newtheorem*{proposition*}{Proposition}
\newtheorem*{assumption*}{Assumption}
\newtheorem{remark}{Remark}
\newtheorem{conjecture}{Conjecture}
\DeclareMathOperator*{\argmax}{arg\,max}
\providecommand{\ux}[1]{#1}
\renewcommand{\ux}[1]{\underline{#1}}
\setbeamertemplate{theorems}[numbered]
\setbeamercovered{transparent}
\title{A}
\author{B}
\institute{C}
\date{09/03/2021}
\begin{document}
\begin{frame}{}
\begin{figure}[H]
\centering
\begin{tikzpicture}[xscale=0.6,yscale=0.6]
\draw [fill] (-11.5,6) circle [radius=0.7];
\draw [fill=gray] (-10,6) circle [radius=0.45];
\draw [fill=gray] (-8.8,6) circle [radius=0.45];
\draw [fill=gray] (-7.6,6) circle [radius=0.45];
\draw [fill=gray] (-6.4,6) circle [radius=0.45];
\draw [fill] (-3.5,6) circle [radius=0.7];
\draw [fill=gray] (0,2.4) circle [radius=0.45];
\draw [fill=gray] (2,2.4) circle [radius=0.45];
\draw [fill=gray] (4,2.4) circle [radius=0.45];
\draw [fill=gray] (6,2.4) circle [radius=0.45];
\draw (0,7.8) -- (-3,6.2);
\draw (0,7.8) -- (3,6.2);
\draw (3,6.2) -- (1,4);
\draw (3,6.2) -- (5,4);
\draw (1,4) -- (0,2.8);
\draw (1,4) -- (2,2.8);
\draw (5,4) -- (4,2.8);
\draw (5,4) -- (6,2.8);
\end{tikzpicture}
\end{figure}
\end{frame}
答案1
@Ignasi 的回答Latex beamer:如何水平/垂直居中文本,忽略其他内容
就我的情况来说,
\begin{frame}{}
\begin{tikzpicture}[overlay, remember picture]
\node[anchor=center] at (current page.center) {
\begin{tikzpicture}[xscale=0.6,yscale=0.6]
blabla
\end{tikzpicture}
};
\end{tikzpicture}
\end{frame}
答案2
图形环境之前和之后能\vfill
起作用吗?就像这样,代码被精简了:
\documentclass{beamer}
\usepackage{tikz}
\mode<presentation>
{
\usetheme{AnnArbor} % or try Darmstadt, Madrid, Warsaw, ...
\usecolortheme{wolverine} % or try albatross, beaver, crane, ...
\usefonttheme{default} % or try serif, structurebold, ...
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{caption}[numbered]
}
\begin{document}
\begin{frame}
% possibly add vfill here:
%\vfill
\begin{tikzpicture}[xscale=0.4,yscale=0.4]
\draw [fill] (-11.5,6) circle [radius=0.7];
\draw [fill=gray] (-10,6) circle [radius=0.45];
\draw [fill=gray] (-8.8,6) circle [radius=0.45];
\draw [fill=gray] (-7.6,6) circle [radius=0.45];
\draw [fill=gray] (-6.4,6) circle [radius=0.45];
\draw [fill] (-3.5,6) circle [radius=0.7];
\draw [fill=gray] (0,2.4) circle [radius=0.45];
\draw [fill=gray] (2,2.4) circle [radius=0.45];
\draw [fill=gray] (4,2.4) circle [radius=0.45];
\draw [fill=gray] (6,2.4) circle [radius=0.45];
\draw (0,7.8) -- (-3,6.2);
\draw (0,7.8) -- (3,6.2);
\draw (3,6.2) -- (1,4);
\draw (3,6.2) -- (5,4);
\draw (1,4) -- (0,2.8);
\draw (1,4) -- (2,2.8);
\draw (5,4) -- (4,2.8);
\draw (5,4) -- (6,2.8);
\end{tikzpicture}
% possibly add vfill here:
%\vfill
\end{frame}
\end{document}