我想按以下方式排列我的文本和图像投影机中的一帧。
是否可以在文本下放置更多图片,例如三张图像或更多?
答案1
这是不是最简单的方法,但是这会根据框的数量调整图像框的宽度(\numofboxes
相应地设置计数器)
\documentclass[demo]{beamer}
\usepackage{calc}
\usepackage{blindtext}
\newcounter{numofboxes}
\newcounter{numofgaps}
\newlength{\textsectionwidth}
\newlength{\truetextsectionwidth}
\newlength{\gapwidth}
\newlength{\boxwidth}
\setlength{\gapwidth}{2\tabcolsep}
\setlength{\textsectionwidth}{\textwidth}
\begin{document}
% Set the number of boxes
\setcounter{numofboxes}{2}
\setcounter{numofgaps}{\numexpr\number\value{numofboxes}-1}
% Calculate the boxlengths
\setlength{\truetextsectionwidth}{\textsectionwidth-\number\value{numofgaps}\gapwidth}
\setlength{\boxwidth}{\truetextsectionwidth/\number\value{numofboxes}}
\begin{frame}{A frame with two images}
\begin{tabular}{*{\number\value{numofboxes}}c}
\multicolumn{\number\value{numofboxes}}{p{\textsectionwidth}}{%
\small\blindtext
}\tabularnewline
\includegraphics[scale=1,width=\boxwidth]{fig1} & \includegraphics[scale=0.2,width=\boxwidth]{fig2} \tabularnewline
\end{tabular}
\end{frame}
\setcounter{numofboxes}{4}
\setcounter{numofgaps}{\numexpr\number\value{numofboxes}-1}
\setlength{\truetextsectionwidth}{\textsectionwidth-\number\value{numofgaps}\gapwidth}
\setlength{\boxwidth}{\truetextsectionwidth/\number\value{numofboxes}}
\begin{frame}{A frame with four images}
\begin{tabular}{*{\number\value{numofboxes}}c}
\multicolumn{\number\value{numofboxes}}{p{\textsectionwidth}}{%
\small\blindtext
}\tabularnewline
\includegraphics[scale=1,width=\boxwidth]{fig1} & \includegraphics[scale=0.2,width=\boxwidth]{fig2} & \includegraphics[scale=0.2,width=\boxwidth]{fig3} & \includegraphics[scale=0.2,width=\boxwidth]{fig4} \tabularnewline
\end{tabular}
\end{frame}
\end{document}
答案2
另一种方法是使用textblock
带选项的环境textblockcolor
。width=xx\linewidth
如果需要更多图形,请进行更改。
代码
\documentclass{beamer}
\usepackage[absolute,overlay]{textpos}
\usepackage{graphicx,xcolor}
\begin{document}
\begin{frame}
\begin{textblock*}{\linewidth}(1cm,1cm)
\textblockcolor{cyan}
This is a long text.This is a long text.This is a long text.This is a long text.
\vspace{3cm}
\end{textblock*}
\begin{textblock*}{\linewidth}(1cm,5cm) % {block width} (coords)
\centering
\textblockcolor{}
\colorbox{cyan}{\includegraphics[width=0.31\linewidth,height=4cm]{example-image-a}}\hfil
\colorbox{cyan}{\includegraphics[width=0.31\linewidth,height=4cm]{example-image-b}}\hfil
\colorbox{cyan}{\includegraphics[width=0.31\linewidth,height=4cm]{example-image-c}}
\end{textblock*}
\end{frame}
\end{document}
答案3
有多种方法可以做到这一点,最简单的方法可能是这样的:
\documentclass{beamer}
\begin{document}
\begin{frame}
A bunch of text. A bunch of text. A bunch of text. A bunch of text. A bunch of text. A bunch of text.
A bunch of text. A bunch of text. A bunch of text. A bunch of text. A bunch of text. A bunch of text.
A bunch of text. A bunch of text. A bunch of text. A bunch of text. A bunch of text. A bunch of text.
\bigskip
\includegraphics[width=0.3\linewidth,height=1.5cm]{example-image-a}\hfill
\includegraphics[width=0.3\linewidth,height=1.5cm]{example-image-b}\hfill
\includegraphics[width=0.3\linewidth,height=1.5cm]{example-image-c}
\end{frame}
\end{document}