投影仪中的表格单元格颜色未对齐

投影仪中的表格单元格颜色未对齐

考虑以下代码:

\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}

相关内容