考虑以下代码:
\documentclass[8pt]{beamer}
% Theme
\usetheme{Frankfurt}
\useinnertheme{rectangles}
\setbeamertemplate{blocks}[default]
% Packages
\usepackage{xcolor}
\usepackage{tikz}
\usepackage{colortbl}
\usepackage{calc}
\usepackage{listings}
\usepackage{makecell}
% Length
\newlength{\tabforhspace}
% Document
\begin{document}
% Frame
\begin{frame}[fragile]
\begin{center}
\setlength{\tabforhspace}{0.1em}%
\def\arraystretch{1.1}%
\tiny%
\begin{tabular}{%
|@{\hspace{\tabforhspace}}l@{\hspace{\tabforhspace}}%
|%
|@{\hspace{\tabforhspace}}c@{\hspace{\tabforhspace}}%
|@{\hspace{\tabforhspace}}c@{\hspace{\tabforhspace}}%
|@{\hspace{\tabforhspace}}c@{\hspace{\tabforhspace}}%
|%
|@{\hspace{\tabforhspace}}c@{\hspace{\tabforhspace}}%
|@{\hspace{\tabforhspace}}c@{\hspace{\tabforhspace}}%
|@{\hspace{\tabforhspace}}c@{\hspace{\tabforhspace}}%
|%
}%
\hline
\lstinline!struct type {}; using T = !%
& \lstinline!type!
& \lstinline!type&!
& \lstinline!type&&!
& \lstinline!const type!
& \cellcolor{gray}\lstinline!const type&!
& \lstinline!const type&&!
\\ \hline
& \lstinline!type!
& \cellcolor{cyan}\lstinline!type&!
& \lstinline!type&&!
& \lstinline!const type!
& \lstinline!const type&!
& \lstinline!const type&&!
\\
\hline
\end{tabular}
\end{center}
\end{frame}
% End
\end{document}
我尝试了不同的选项,但目前似乎没有任何效果。如何使颜色与单元格完美对齐?
答案1
你喜欢获得这样的东西吗?
\documentclass[8pt, table]{beamer}
% Theme
\usetheme{Frankfurt}
\useinnertheme{rectangles}
\setbeamertemplate{blocks}[default]
% Packages
\usepackage{tikz}
\usepackage{calc}
\usepackage{listings}
\usepackage{makecell}
% Document
\begin{document}
% Frame
\begin{frame}[fragile]
\begin{center}
\def\arraystretch{1.1}%
\setlength\tabcolsep{2pt}
\tiny% table can fit in frame even with font size \small
\begin{tabular}{|*{7}{l|}}%
\hline
\lstinline!struct type {}; using T = !%
& \lstinline!type!
& \lstinline!type&!
& \lstinline!type&&!
& \lstinline!const type!
& \cellcolor{gray}\lstinline!const type&!
& \lstinline!const type&&!
\\ \hline
& \lstinline!type!
& \cellcolor{cyan}\lstinline!type&!
& \lstinline!type&&!
& \lstinline!const type!
& \lstinline!const type&!
& \lstinline!const type&&!
\\
\hline
\end{tabular}
\end{center}
\end{frame}
\end{document}