我在 Beamer 中使用大都市主题,我想将房屋图像置于框架标题的中心(在空间中)。我该怎么做?下面有一个 MWE。
多谢。
\documentclass[t,aspectratio=169]{beamer}
\usetheme[progressbar=frametitle,block=fill]{metropolis}
\setbeamertemplate{frame numbering}[fraction]
\useoutertheme{metropolis}
\useinnertheme{metropolis}
\usefonttheme{metropolis}
\usecolortheme{owl}
\usepackage{amsmath,amsfonts,amscd,bezier, amssymb, ifthen,amsthm}
\usepackage{graphics}
\usepackage{xcolor}
\usepackage[T1]{fontenc}
\usepackage{float}
\usepackage{pgfplots} % it is required for the legend
\usepackage{mathtools}
\usepackage{changepage}
\usepackage[most]{tcolorbox}
\title{XXXXXXX}
\subtitle{xxxxxxx}
\author{}
\institute{yyyyy}
\date{}
\everymath{\displaystyle}
\setbeamercolor*{item}{fg=yellow}
\setbeamersize{text margin left=3mm,text margin right=1mm}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newenvironment<>{varblock}[2][.9\textwidth]{%
\setlength{\textwidth}{#1}
\begin{actionenv}#3%
\def\insertblocktitle{#2}%
\par%
\usebeamertemplate{block begin}}
{\par%
\usebeamertemplate{block end}%
\end{actionenv}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\metroset{background=dark}
\metroset{block=fill}
%\setcounter{page}{0}
\begin{frame}
\titlepage
\thispagestyle{empty}
\end{frame}
\begin{frame}{\color{red}{Exercises:} {\includegraphics[scale=0.05]{house}}}
\begin{alertblock}{Exercise 1:}
blabla bla
\end{alertblock}
%https://br.depositphotos.com/2467738/stock-illustration-vector-illustration-of-house.html
\begin{alertblock}{Exercise 2:}
blablabla.
\end{alertblock}
\end{frame}
\end{document}
答案1
您可以使用该adjustbox
包使图像垂直居中:
\documentclass[t,aspectratio=169]{beamer}
\usetheme[progressbar=frametitle,background=dark]{moloch}% modern fork of the metropolis theme
\setbeamertemplate{page number in head/foot}[totalframenumber]
\usecolortheme{owl}
\usepackage{
%amsmath,amsfonts,amscd,
bezier,
%amssymb,
ifthen,
%amsthm
}
%\usepackage{graphics}
%\usepackage{xcolor}
\usepackage[T1]{fontenc}
%\usepackage{float}
\usepackage{pgfplots} % it is required for the legend
\usepackage{mathtools}
\usepackage{changepage}
\usepackage[most]{tcolorbox}
\usepackage[export]{adjustbox}
\title{XXXXXXX}
\subtitle{xxxxxxx}
\author{}
\institute{yyyyy}
\date{}
\everymath{\displaystyle}
\setbeamercolor*{item}{fg=yellow}
\setbeamersize{text margin left=3mm,text margin right=1mm}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newenvironment<>{varblock}[2][.9\textwidth]{%
\setlength{\textwidth}{#1}
\begin{actionenv}#3%
\def\insertblocktitle{#2}%
\par%
\usebeamertemplate{block begin}}
{\par%
\usebeamertemplate{block end}%
\end{actionenv}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%\setcounter{page}{0}
\begin{frame}
\titlepage
\thispagestyle{empty}
\end{frame}
\begin{frame}{\color{red}{Exercises:} {\includegraphics[height=1.5cm,valign=c]{example-image-duck}}}
\begin{alertblock}{Exercise 1:}
blabla bla
\end{alertblock}
\begin{alertblock}{Exercise 2:}
blablabla.
\end{alertblock}
\end{frame}
\end{document}
答案2
如果你想水平居中,你可以使用
\begin{frame}{\rlap{\color{red}{Exercises:}}%
\hfill\includegraphics[height=\ht\strutbox]{example-image}\hfill
\llap{right}}
和\rlap
导致\llap
文本与\hfill
s 重叠。右侧的文本主要用于显示行尾的位置。
如果要使其相对于文本垂直居中,可以使用
\begin{frame}{{\color{red}{Exercises:}} \raisebox{\dimexpr 0.5\ht\strutbox-0.5\dp\strutbox-0.5\height}%
{\includegraphics[height=40pt]{example-image}}}
请注意,会\beamer@frametitlebox
扩展以适合图像。
答案3
您可以\centering
在之前添加\insertframetitle
。接下来,我们定义并安装这样的模板。
在文档的序言中添加以下定义:
\makeatletter
\defbeamertemplate*{frametitle}{centered}{%
\nointerlineskip%
\begin{beamercolorbox}[%
wd=\paperwidth,%
sep=0pt,%
leftskip=\metropolis@frametitle@padding,%
rightskip=\metropolis@frametitle@padding,%
]{frametitle}%
\metropolis@frametitlestrut@start%
\centering\insertframetitle%
\nolinebreak%
\metropolis@frametitlestrut@end%
\end{beamercolorbox}%
}
\makeatother