带有阴影过渡、圆角和阴影的表格(像主题块一样)

带有阴影过渡、圆角和阴影的表格(像主题块一样)

这是我在这里的第一个问题。

我想让我的表格看起来像块,以具有相应的风格。问题:

  • 如何创建从表格标题到正文的阴影过渡(如块)
  • 如何添加阴影。(本论坛上的不同解决方案似乎对我的代码不起作用。)

这是我的简约代码,它产生以下输出:

\documentclass{beamer}  
\usetheme{Berlin}  
\setbeamertemplate{blocks}[rounded][shadow=true]

% Packages  
\usepackage[USenglish]{babel}  
\usepackage{times}  
\usepackage{tikz}  
\usepackage{parskip}  
\usepackage{tabularx}  
\usepackage{booktabs}  
\usepackage{colortbl}

% This is for rounded corners  
\usetikzlibrary{calc}  
\pgfdeclarelayer{background}  
\pgfdeclarelayer{foreground}  
\pgfsetlayers{background,main,foreground}

% Define colors  
\definecolor{TblTitle}{RGB}{38,38,134}  
\definecolor{TblBody}{RGB}{233,233,243}

\begin{document}                                                    

\begin{frame}  
\begin{block}{Block 1}  
\begin{itemize}  
\item item 1  
\item item 2  
\end{itemize}  
\end{block}

\begin{tikzpicture}  
\node(tbl){  
\begin{tabularx}{\textwidth}{p{0.5\textwidth}p{0.5\textwidth}}  
\textcolor{white}{Column 1} & \textcolor{white}{Column 2} \\  
\begin{itemize}  
\item item 3  
\item item 4  
\end{itemize} &   
\begin{itemize}  
\item item 5  
\item item 6  
\end{itemize} \\[-1em]  
\end{tabularx}};  
\begin{pgfonlayer}{background}    
\draw[rounded corners,top color=TblTitle,  
bottom color=TblTitle,draw=white]  
($(tbl.north west)+(0.12,0)$)  
rectangle ($(tbl.north east)-(0.12,0.9)$);  
\draw[rounded corners,top color=TblBody,  
bottom color=TblBody,draw=white]   
($(tbl.south west)+(0.12,0.5)$)  
rectangle ($(tbl.south east)-(0.12,0)$);  
\draw[top color=TblBody,bottom color=TblBody,draw=TblBody]  
($(tbl.north east)-(0.13,0.6)$)  
rectangle ($(tbl.south west)+(0.13,0.2)$);  
\end{pgfonlayer}  
\end{tikzpicture}  
\end{frame}

\end{document}

表和块

答案1

这个怎么样:

\documentclass{beamer}  
\usetheme{Berlin}  
\setbeamertemplate{blocks}[rounded][shadow=true]

% Packages  
\usepackage[USenglish]{babel}  
\usepackage{times}  
\usepackage{tikz}  
\usepackage{parskip}  
\usepackage{tabularx}  
\usepackage{booktabs}  
\usepackage{colortbl}

% This is for rounded corners  
\usetikzlibrary{calc}  
\pgfdeclarelayer{background}  
\pgfdeclarelayer{foreground}  
\pgfsetlayers{background,main,foreground}

% Define colors  
\definecolor{TblTitle}{RGB}{38,38,134}  
\definecolor{TblBody}{RGB}{233,233,243}

\begin{document}                                                    

\begin{frame}[t]

\begin{block}{Block 1}  
\begin{itemize}  
\item item 1  
\item item 2  
\end{itemize}  
\end{block}

\tikzset{blocknode/.style={inner sep=0,text width=0.5\textwidth,below right}}

\begin{block}{\tikz{\node[blocknode] {asdf}; \node[blocknode] at (0.5\textwidth,0) {qwertz};}}
\begin{tikzpicture}
\node[blocknode] {\begin{itemize}\item a\item b\end{itemize}};
\node[blocknode] at (0.5\textwidth,0) {\begin{itemize}\item c\item d\end{itemize}};
\end{tikzpicture}
\end{block}

\begin{block}{\tikz{\node[blocknode] {qwer wert ertz rtzu tzui zuio uiop}; \node[blocknode] at (0.5\textwidth,0) {asdf sdfg dfgh fghj ghjk hjkl yxcv xcvb cvbn vbnm};}}
\begin{tikzpicture}
\node[blocknode] {\begin{itemize}\item asdf sdfg dfgh fghj ghjk hjkl yxcv xcvb cvbn vbnm \item b\end{itemize}};
\node[blocknode] at (0.5\textwidth,0) {\begin{itemize}\item c\item qwer wert ertz rtzu tzui zuio uiop\end{itemize}};
\end{tikzpicture}
\end{block}

\end{frame}

\end{document}

在此处输入图片描述

答案2

不必试图使表格看起来像一个块,而是可以使用将项目彼此相邻放置sidebysidetcolorbox选项(只有标题中的间距有点奇怪):

\documentclass{beamer}
\usepackage[many]{tcolorbox}

\usetheme{Berlin}  
\setbeamertemplate{blocks}[rounded][shadow=true]

\tikzset{beamer@color/.style={fill=none,top color=tcbcolback,bottom color=tcbcolback}}

\tcbset{
tcbeamer/.style={
  code={
    \usebeamercolor{block body}
    \usebeamercolor{block title}
    \usebeamercolor{normal text}
  },
  skin=beamer,
  boxrule=0mm,
  titlerule=1mm,
  drop fuzzy shadow=black,
  width=\textwidth+7pt,
  enlarge left by=-3pt,
  bottom=0pt,
  top=0pt,
  left=1pt,
  right=1pt,
  arc=4pt,
  outer arc=4pt,
  toptitle=0pt,
  bottomtitle=-1pt,
  colback=block body.bg,
  colframe=block title.bg,
  fonttitle=\usebeamerfont{block title}\color{block title.fg},
  }
}

\begin{document}

\begin{frame}

\begin{tcolorbox}[tcbeamer,sidebyside,title={\parbox{.45\linewidth}{Column 1}\hfill\parbox{.45\linewidth}{Column 2}},lower separated=false] 
    \begin{itemize}
    \item item 1
    \item item 2
    \end{itemize}
\tcblower
    \begin{itemize}
    \item item 1
    \item item 2
    \end{itemize}
\end{tcolorbox}

%
\begin{block}{Test exampleblock}
This is a block provided by the \texttt{beamer} class.
\end{block}

\end{frame}

\end{document}

在此处输入图片描述

使用新的 tcolorbox 内部主题可以进一步简化代码 (https://www.ctan.org/pkg/beamertheme-tcolorbox

\documentclass{beamer}
\usepackage[many]{tcolorbox}

\usetheme{Berlin}  
\setbeamertemplate{blocks}[rounded][shadow=true]

\useinnertheme[rounded,shadow]{tcolorbox}

\begin{document}

\begin{frame}

\begin{tcolorbox}[sidebyside,title={\parbox{.45\linewidth}{Column 1}\hfill\parbox{.45\linewidth}{Column 2}},lower separated=false] 
    \begin{itemize}
    \item item 1
    \item item 2
    \end{itemize}
\tcblower
    \begin{itemize}
    \item item 1
    \item item 2
    \end{itemize}
\end{tcolorbox}

\begin{block}{Test exampleblock}
This is a block provided by the \texttt{beamer} class.
\end{block}

\end{frame}

\end{document}

相关内容