LaTeX Beamer Block“三明治风格”

LaTeX Beamer Block“三明治风格”

如何在 LaTeX Beamer 中创建“三明治样式”的块,即同时具有标题和页脚的块。理想情况下,背景颜色甚至可以不同。以下是一张插图(间距不正确):

Image that shows how it should (roughly) look like

答案1

tcolorbox制作三明治盒很容易。这个用的是bicolor皮肤。还有一种beamer皮肤可以制作更多的“a la beamer”盒子,但我不知道如何lower像它一样为文本部分设置不同的背景颜色bicolor

\documentclass{beamer}
\usepackage{tcolorbox}
\tcbuselibrary{skins}

\newtcolorbox{sandwich}[1]{bicolor, colframe=blue!75!black, colback=red!50!white, colbacklower=blue!75!black, collower=white,title=#1}

\begin{document}
\begin{frame}{Sandwich box with tcolorbox}

\begin{sandwich}{Testing 1-2-3}
This is a text
\tcblower
Yet another text
\end{sandwich}

\end{frame}
\end{document}

enter image description here

答案2

MWE

为了完成 Ignasi 的回答,有可能产生更多“比默“三明治盒子圆角,去掉框架并添加阴影,或者同时使用一个beamer皮肤和一个bicolor皮肤,按这个顺序。 MWE 展示了两种情况:

\documentclass{beamer}
\usetheme{Madrid}
\usecolortheme[RGB={128,128,255}]{structure} 
\setbeamercolor*{block title example}{fg=red!50!black,bg= green!80!black!50}
\setbeamercolor*{block body example}{fg=green!20!black, bg= green!15}
\setbeamercolor*{block body alerted}{fg= orange!50!black, bg= orange!15}
\setbeamercolor*{block title alerted}{fg=yellow!50, bg= orange!50!red}
\usepackage[skins]{tcolorbox}


\begin {document}
\begin{frame}{Sandwich box a la Beamer}

\begin{columns}[c]
\begin{column}{.3\linewidth}
\begin{block}{Block}Text\end{block}
\begin{exampleblock}{Example  block}Text\end{exampleblock}
\begin{alertblock}{Alert block}Text\end{alertblock}
\end{column}
\begin{column}{.4\linewidth}

% Without beamer skin: 

\begin{tcolorbox}[
left=1mm,right=1mm,top=1mm,bottom=1mm,middle=1mm,
skin=bicolor,
arc=5pt,
bottomrule=0pt,
leftrule=0pt,
rightrule=0pt,
toprule=0pt,
colback=block body alerted.bg,
colbacklower=block body example.bg,
collower=block title.bg,
colframe=block title.bg, %structure, %blue!75!black,
frame style={left color=block title.bg,
right color=block title example.bg!100!black},
% better shadow than beamer skin
fuzzy shadow={1mm}{-1mm}{-.25mm}{.5pt}{structure!20!black}% blue!30!black!80} 
,title=Testing 1-2-3]
A bicolor box
\tcblower
a la \dotfill \alert{no} Beamer mode 
\end{tcolorbox}

\bigskip

% With beamer skin: 


\begin{tcolorbox}[
left=1mm,right=1mm,top=1mm,bottom=1mm,middle=1mm,
beamer, % Warning: must be before of bicolor skin
skin=bicolor,
colback=block body.bg,
colbacklower=block body example.bg,
collower=block body alerted.fg,
colupper=block body example.fg,
%colframe=block title.bg,
coltitle=block title alerted.fg,
frame style={draw=none,fill=none, left color=block title.bg, right color=block title.bg!70!black},
interior style={left color=block body alerted.bg, right color=block title alerted.bg},
,title=Testing 1-2-3]
A bicolor box
\tcblower
a la Beamer mode
\end{tcolorbox}

\end{column}
\end{columns}


\end{frame}
\end{document}

如上所示,可以有 3 种颜色,甚至渐变色。我建议谨慎使用,适度使用 Beamer 颜色以与演示文稿的其余部分保持一致。请注意,以上代码仅用于展示如何操作,并非旨在成为良好品味的典范(获得优雅的配色方案是您的任务。)

相关内容