将表格从文章转换为投影仪

将表格从文章转换为投影仪

我使用 \usepackage[table,xcdraw]{xcolor} 和 \usepackage{tabu} 制作了以下表格,用于文章类文档,并且运行正常。但是,现在我需要在 Beamer 演示文稿中使用它,却出现很多错误,我做错了什么?

\begin{table}[h]
\centering
\taburulecolor[HTML]{00CD5C}
\begin{tabu}{|c|c|c|c|}
\hline
{\color[HTML]{00CD5C} \makecell{Nº Atos \\ Médicos \\ Anuais}} & {\color[HTML]{00CD5C} \makecell{Seguro \\ A}} & {\color[HTML]{00CD5C} \makecell{Seguro \\ B}} & {\color[HTML]{00CD5C} \makecell{Seguro \\ C}} \\ \hline
{\color[HTML]{006CAD} 10}                     & {\color[HTML]{006CAD} 92}       & {\color[HTML]{006CAD} 92}       & {\color[HTML]{006CAD} 56}       \\ \hline
{\color[HTML]{006CAD} 20}                     & {\color[HTML]{006CAD} 92}       & {\color[HTML]{006CAD} 124}      & {\color[HTML]{006CAD} 108}      \\ \hline
{\color[HTML]{006CAD} 30}                     & {\color[HTML]{006CAD} 110}      & {\color[HTML]{006CAD} 188}      & {\color[HTML]{006CAD} 160}      \\ \hline
{\color[HTML]{006CAD} 40}                     & {\color[HTML]{006CAD} 146}      & {\color[HTML]{006CAD} 252}      & {\color[HTML]{006CAD} 212}      \\ \hline
{\color[HTML]{006CAD} 50}                     & {\color[HTML]{006CAD} 182}      & {\color[HTML]{006CAD} 316}      & {\color[HTML]{006CAD} 264}      \\ \hline
{\color[HTML]{006CAD} 60}                     & {\color[HTML]{006CAD} 218}      & {\color[HTML]{006CAD} 380}      & {\color[HTML]{006CAD} 316}      \\ \hline
{\color[HTML]{006CAD} 70}                     & {\color[HTML]{006CAD} 254}      & {\color[HTML]{006CAD} 444}      & {\color[HTML]{006CAD} 368}      \\ \hline
{\color[HTML]{006CAD} 80}                     & {\color[HTML]{006CAD} 290}      & {\color[HTML]{006CAD} 508}      & {\color[HTML]{006CAD} 420}      \\ \hline
{\color[HTML]{006CAD} 90}                     & {\color[HTML]{006CAD} 326}      & {\color[HTML]{006CAD} 572}      & {\color[HTML]{006CAD} 472}      \\ \hline
{\color[HTML]{006CAD} 100}                    & {\color[HTML]{006CAD} 362}      & {\color[HTML]{006CAD} 636}      & {\color[HTML]{006CAD} 524}      \\ \hline
{\color[HTML]{006CAD} 110}                    & {\color[HTML]{006CAD} 398}      & {\color[HTML]{006CAD} 700}     & {\color[HTML]{006CAD} 576}      \\ \hline
{\color[HTML]{006CAD} 120}                    & {\color[HTML]{006CAD} 434}      & {\color[HTML]{006CAD} 764}     & {\color[HTML]{006CAD} 628}      \\ \hline
\end{tabu}
\caption{Preço de atos médicos}
\label{Tab:Seg2}
\end{table}

答案1

您需要使用beamerdocumentclass 并稍微减小表格中文本的字体大小:

\documentclass{beamer}
\setbeamertemplate{caption}[numbered]
\usepackage{makecell, tabu}

\begin{document}
\begin{frame}
\frametitle{Table}
    \begin{table}
    \small
\taburulecolor[HTML]{00CD5C}
\begin{tabu}{|c|c|c|c|}
\hline
{\color[HTML]{00CD5C} \makecell{Nº Atos \\ Médicos \\ Anuais}} & {\color[HTML]{00CD5C} \makecell{Seguro \\ A}} & {\color[HTML]{00CD5C} \makecell{Seguro \\ B}} & {\color[HTML]{00CD5C} \makecell{Seguro \\ C}} \\ \hline
{\color[HTML]{006CAD} 10}                     & {\color[HTML]{006CAD} 92}       & {\color[HTML]{006CAD} 92}       & {\color[HTML]{006CAD} 56}       \\ \hline
{\color[HTML]{006CAD} 20}                     & {\color[HTML]{006CAD} 92}       & {\color[HTML]{006CAD} 124}      & {\color[HTML]{006CAD} 108}      \\ \hline
{\color[HTML]{006CAD} 30}                     & {\color[HTML]{006CAD} 110}      & {\color[HTML]{006CAD} 188}      & {\color[HTML]{006CAD} 160}      \\ \hline
{\color[HTML]{006CAD} 40}                     & {\color[HTML]{006CAD} 146}      & {\color[HTML]{006CAD} 252}      & {\color[HTML]{006CAD} 212}      \\ \hline
{\color[HTML]{006CAD} 50}                     & {\color[HTML]{006CAD} 182}      & {\color[HTML]{006CAD} 316}      & {\color[HTML]{006CAD} 264}      \\ \hline
{\color[HTML]{006CAD} 60}                     & {\color[HTML]{006CAD} 218}      & {\color[HTML]{006CAD} 380}      & {\color[HTML]{006CAD} 316}      \\ \hline
{\color[HTML]{006CAD} 70}                     & {\color[HTML]{006CAD} 254}      & {\color[HTML]{006CAD} 444}      & {\color[HTML]{006CAD} 368}      \\ \hline
{\color[HTML]{006CAD} 80}                     & {\color[HTML]{006CAD} 290}      & {\color[HTML]{006CAD} 508}      & {\color[HTML]{006CAD} 420}      \\ \hline
{\color[HTML]{006CAD} 90}                     & {\color[HTML]{006CAD} 326}      & {\color[HTML]{006CAD} 572}      & {\color[HTML]{006CAD} 472}      \\ \hline
{\color[HTML]{006CAD} 100}                    & {\color[HTML]{006CAD} 362}      & {\color[HTML]{006CAD} 636}      & {\color[HTML]{006CAD} 524}      \\ \hline
{\color[HTML]{006CAD} 110}                    & {\color[HTML]{006CAD} 398}      & {\color[HTML]{006CAD} 700}     & {\color[HTML]{006CAD} 576}      \\ \hline
{\color[HTML]{006CAD} 120}                    & {\color[HTML]{006CAD} 434}      & {\color[HTML]{006CAD} 764}     & {\color[HTML]{006CAD} 628}      \\ \hline
\end{tabu}
\caption{Preço de atos médicos}
\label{Tab:Seg2}
    \end{table}
\end{frame}
\end{document}

在此处输入图片描述

附录:不建议使用tabu。软件包未维护。相反,简单的tabular就足够了。

\documentclass[xcolor=table]{beamer}
\setbeamertemplate{caption}[numbered]
\newcommand\MC[1]{\begin{tabular}{@{} >{\color[HTML]{00CD5C}}c @{} } #1 \end{tabular}}

\begin{document}
\begin{frame}
\frametitle{Table}
    \begin{table}
    \small
    \arrayrulecolor[HTML]{00CD5C}
\begin{tabular}{|*{4}{>{\color[HTML]{006CAD}}c|} }
    \hline
\MC{Nº Atos \\ Médicos \\ Anuais}
    &   \MC{Seguro \\ A}
        &   \MC{Seguro \\ B}
            &   \MC{Seguro \\ C}    \\
    \hline
10  & 92  & 92  & 56  \\ \hline
20  & 92  & 124 & 108 \\ \hline
30  & 110 & 188 & 160 \\ \hline
40  & 146 & 252 & 212 \\ \hline
50  & 182 & 316 & 264 \\ \hline
60  & 218 & 380 & 316 \\ \hline
70  & 254 & 444 & 368 \\ \hline
80  & 290 & 508 & 420 \\ \hline
90  & 326 & 572 & 472 \\ \hline
100 & 362 & 636 & 524 \\ \hline
110 & 398 & 700 & 576 \\ \hline
120 & 434 & 764 & 628 \\ \hline
\end{tabular}
\caption{Preço de atos médicos}
\label{Tab:Seg2}
    \end{table}
\end{frame}
\end{document}

在此处输入图片描述

笔记: 也用于演示table环境,captions很少使用(参见下面的@Mico 评论)。看看您是否可以接受删除它们。

相关内容