花式表格:删除单元格并在单元格内分割线

花式表格:删除单元格并在单元格内分割线

我在以下 MWE 中有一个漂亮的表格,但无论如何我都无法删除左下角的单元格,也无法在单元格内拆分行(我想将“排卵日期”和“屏障较差”拆分成两行)。请查看下面的 Beamer MWE:

\documentclass[xcolor={dvipsnames,table}]{beamer}

%%TABLE
\usepackage{multicol}
\usepackage{multirow}
\usepackage{array}
\newcommand*{\arraycolor}[1]{\protect\leavevmode\color{#1}}
\newcolumntype{A}{>{\columncolor{red!20}}c}
\newcolumntype{B}{>{\columncolor{blue!20}}c}
\usepackage{makecell}
\usepackage{setspace}
\usepackage{wasysym}

\mode<presentation> {
    \usetheme[compress]{Singapore}
    \usecolortheme{orchid}
}

\begin{document}

\begin{frame}
    \sffamily
    \arrayrulecolor{white}
    \arrayrulewidth=1pt
    \renewcommand{\arraystretch}{1}
    \rowcolors[\hline]{2}{.!50!White}{}
    \begin{tabular}{@{}A|B|A|B|A}%remove indent
        \rowcolor{.!50!Black}
        \arraycolor{White}\bfseries {\tiny Subject} & \arraycolor{White}\bfseries {\tiny Dry} & \arraycolor{White}\bfseries {\tiny Ovulation date} & \arraycolor{White}\bfseries {\tiny Oiliest} & \arraycolor{White}\bfseries {\tiny Poor barrier}\\
        \bfseries {\tiny 2007} & {\tiny 8, 36} & {\tiny 14} & {\tiny 22} & {\tiny 26}\\
        & \bfseries {\tiny I - DR} & \bfseries {\tiny II - OP} & \bfseries {\tiny III - OL} & \bfseries {\tiny IV - PB}
    \end{tabular}
\end{frame} 

\end{document}

测试

对于这种表格,我需要学习如何:

  • 移除单元格

  • 单元格内的分割线

答案1

像这样吗?(请注意,我已删除所有\tiny指令。)

在此处输入图片描述

(如果标题单元格需要垂直居中而不是顶部对齐,请\renewcommand{\tabularxcolumn}[1]{m{#1}}在加载后插入指令。)tabularx

\documentclass[xcolor={dvipsnames,table}]{beamer}

\usepackage{tabularx}
\newcommand*{\arraycolor}[1]{\protect\leavevmode\color{#1}}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\newcolumntype{A}{>{\columncolor{red!20}}C}
\newcolumntype{B}{>{\columncolor{blue!20}}C}

\mode<presentation>{
    \usetheme[compress]{Singapore}
    \usecolortheme{orchid}
}

\begin{document}
\begin{frame}
    \arrayrulecolor{white}
    \setlength{\arrayrulewidth}{1.5pt}
    \setlength{\extrarowheight}{2pt}
    \begin{tabularx}{\textwidth}{A|B|A|B|A}
        \rowcolor{.!50!Black}
        \arraycolor{White}\bfseries Subject &
        \arraycolor{White}\bfseries Dry & 
        \arraycolor{White}\bfseries Ovulation date &
        \arraycolor{White}\bfseries Oiliest &
        \arraycolor{White}\bfseries Poor barrier \\
        \hline
        \bfseries 2007 &  8, 36 & 14 & 22 & 26 \\
        \hline
        \multicolumn{1}{c}{\cellcolor{white}} % for a "blank" cell
        & \bfseries I - DR 
        & \bfseries II - OP 
        & \bfseries III - OL 
        & \bfseries IV - PB \\
    \end{tabularx}
\end{frame}
\end{document}

相关内容