
Como posso criar uma tabela como esta em Latex?
Eu tentei, mas não funcionou. Preciso também que ela seja enumerada para que apareça na Lista de Tabelas. Não importa se não for colorido, desde que as duas primeiras linhas estejam em negrito.
\begin{center}
\begin{tabular}{ |c|c|c|c|c| }
\hline
\multicolumn{5}{|c|}{Number of cells per type} \\
\hline
a& b& c& d& e\\
\hline
44 & 39 & 7 & 32 &22 \\
\hline
\end{tabular}
\end{center}
Responder1
Eu sugiro que você use booktabs
para mesas profissionais.
\documentclass[11pt,openright]{book}
\usepackage{array}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\renewcommand{\arraystretch}{1.2}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{caption}
\begin{document}
\listoftables
\chapter{My chapter}
\begin{table}[htb]\centering
\caption{Your table\label{tab:yourtab}}
\begin{tabularx}{.5\linewidth}{ |C|C|C|C|C| }
\hline
\multicolumn{5}{|c|}{\bfseries Number of cells per type} \\
\hline
\bfseries a& \bfseries b& \bfseries c& \bfseries d& \bfseries e\\
\hline
44 & 39 & 7 & 32 &22 \\
\hline
\end{tabularx}
\end{table}
\begin{table}[htb]\centering
\caption{My suggestion\label{tab:mytab}}
\begin{tabularx}{.5\linewidth}{*5C}
\toprule
\multicolumn{5}{c}{\bfseries Number of cells per type} \\
\midrule
\bfseries a& \bfseries b& \bfseries c& \bfseries d& \bfseries e\\
\midrule
44 & 39 & 7 & 32 &22 \\
\bottomrule
\end{tabularx}
\end{table}
\end{document}
Responder2
Há também uma ferramenta online muito útil chamadaGerador de tabelas.
Ele permite que você insira seus dados (você pode até carregá-los de um arquivo) e adaptá-los no estilo WYSIWYG. Em seguida, ele gerará o código LaTeX correto para você copiar/colar em seu documento.
Editar: conforme sugerido por Sanctus, aqui está o código que o Tables Generator me gera (após 2 minutos de entrada de dados).
Ele fornece resultados muito bons para tabelas relativamente simples com configurações padrão (cores, bordas, estilo de fonte, etc.), mas se você precisar de algo sofisticado, provavelmente não fornecerá o suficiente. Mas sempre uso isso como ponto de partida, para fazer a estrutura geral funcionar. Todo o resto eu posso me adaptar.
\documentclass{article}
\usepackage[table,xcdraw]{xcolor}
\usepackage{graphicx}
\usepackage{booktabs}
\begin{document}
% Please add the following required packages to your document preamble:
% \usepackage[table,xcdraw]{xcolor}
% If you use beamer only pass "xcolor=table" option, i.e. \documentclass[xcolor=table]{beamer}
\begin{table}[]
\begin{tabular}{|c|c|c|c|c|}
\hline
\rowcolor[HTML]{DAE8FC}
\multicolumn{5}{|c|}{\cellcolor[HTML]{DAE8FC}\textbf{\tiny{Number of cells per type}}} \\ \hline
\rowcolor[HTML]{DAE8FC}
\textbf{a} & \textbf{b} & \textbf{c} & \textbf{d} & \textbf{e} \\ \hline
44 & 39 & 7 & 32 & 22 \\ \hline
\end{tabular}
\end{table}
\end{document}
Responder3
Não misture dicas visuais e metáforas: se você usar linhas coloridas, não use regras horizontais. E, com certeza, você pode omitir todas as regras verticais – elas não são necessárias.
\documentclass{article}
\usepackage[table,svgnames]{xcolor}
\usepackage{array} % for '\extrarowheight' macro
\begin{document}
\begin{center}
\sffamily
\setlength\extrarowheight{2pt} % optional
\setlength\tabcolsep{9pt} % default: 6pt
\begin{tabular}{ ccccc }
%\hline
\rowcolor{LightBlue} \multicolumn{5}{c}{Number of cells per type} \\
%\hline
\rowcolor{LightBlue} a & b & c & d & e\\
%\hline
44 & 39 & 7 & 32 & 22 \\
\hline
\end{tabular}
\end{center}
\end{document}
Responder4
Misturar e combinar cores e usar algo como ponto de partida
\documentclass[10pt,a4paper]{article}
\usepackage[table,xcdraw]{xcolor}
\begin{document}
\listoftables\newpage
\begin{table}[]
\begin{tabular}{!{\color{cyan}\vrule}l!{\color{cyan}\vrule}l!{\color{cyan}\vrule}l!{\color{cyan}\vrule}l!{\color{cyan}\vrule}l!{\color{cyan}\vrule}}
\arrayrulecolor{cyan}\hline
\rowcolor[HTML]{38FFF8}
\multicolumn{5}{!{\color{cyan}\vrule}l!{\color{cyan}\vrule}}{\cellcolor[HTML]{38FFF8}Number of cells per type} \\ \arrayrulecolor{cyan}\hline
\rowcolor[HTML]{38FFF8}
a & b & c & d & e \\ \arrayrulecolor{cyan}\hline
1 & 2 & 3 & 4 & 5 \\ \hline
\end{tabular}
\caption{a}
\end{table}
\end{document}
obter:
PS: Fique à vontade para brincar com as cores (no momento não tenho o necessário para descobrir as cores) e tive preguiça de não inserir seus números (desculpe ;-)
)