Eu tenho uma tabela, que é feita usando tabulário. A saída parece boa, se não houver várias linhas/colunas. Porém, a saída é muito ruim se contiver várias linhas. Alguém pode me ajudar?.
\documentclass[9pt,twocolumn]{article}
\usepackage{amsmath,amsfonts,amssymb,balance,tabulary,graphicx,caption,fancyhdr}
\usepackage[utf8]{inputenc}
\usepackage[numbers,super,sort&compress]{natbib}
\usepackage{url,multirow,morefloats,floatflt,cancel,tfrupee}
\usepackage{colortbl}
\usepackage{xcolor}
\makeatletter
%%%For Table column width calculation.
\def\mcWidth#1{\csname TY@F#1\endcsname+\tabcolsep}
%%Hacking center and right align for table
\def\cAlignHack{\rightskip\@flushglue\leftskip\@flushglue\parindent\z@\parfillskip\z@skip}
\def\rAlignHack{\rightskip\z@skip\leftskip\@flushglue \parindent\z@\parfillskip\z@skip}
\definecolor{titlecolor}{RGB}{43, 116, 183}
\definecolor{numbercolor}{RGB}{0, 62, 136}
\definecolor{tableheadrcolor}{RGB}{229, 229, 229}
\definecolor{unitednationsblue}{RGB}{231, 236, 247}
\begin{document}
\title{Table issue}
\begin{table*}[!htbp]
\caption{{} }
\label{table-wrap-50e8bb32765343db8fd393ec8c403ec6}{%
\fontsize{8pt}{10pt}\selectfont
\def\arraystretch{1.5}
\ignorespaces
\centering
\begin{tabulary}{\linewidth}{LLLLLLLLL}
\hline %\rowcolor{tableheadrcolor}
\multicolumn{5}{p{\dimexpr(\mcWidth{1}+\mcWidth{2}+\mcWidth{3}+\mcWidth{4}+\mcWidth{5})}}{\textbf{Table} \textbf{ 1. Zone of inhibition of }t\textbf{ ested microbe}s } &
&
&
&
\\%\rowcolor{unitednationsblue}
\multicolumn{1}{p{\dimexpr(\mcWidth{1})}}{\multirow{3}{\linewidth}{\textbf{S. No.}}} &
\multicolumn{1}{p{\dimexpr(\mcWidth{2})}}{\multirow{3}{\linewidth}{\textbf{Tested Microbes}}} &
\multicolumn{7}{p{\dimexpr(\mcWidth{3}+\mcWidth{4}+\mcWidth{5}+\mcWidth{6}+\mcWidth{7}+\mcWidth{8}+\mcWidth{9})}}{\textbf{Zone of inhibition (diameter in mm)}}\\%\rowcolor{unitednationsblue}
&
&
\multicolumn{1}{p{\dimexpr(\mcWidth{3})}}{\multirow{2}{\linewidth}{\textbf{Control}}} &
\multicolumn{1}{p{\dimexpr(\mcWidth{4})}}{\multirow{2}{\linewidth}{\textbf{Plant}}} &
\multicolumn{1}{p{\dimexpr(\mcWidth{5})}}{\multirow{2}{\linewidth}{\textbf{Concentration of} \textbf{ SeNP}s\textbf{ 50 m}M}} &
\multicolumn{4}{p{\dimexpr(\mcWidth{6}+\mcWidth{7}+\mcWidth{8}+\mcWidth{9})}}{\textbf{Minimum} \textbf{ Inhibitor}y\textbf{ Concentration (MIC})}\\%\rowcolor{unitednationsblue}
&
&
&
&
&
\textbf{10} \textbf{ \ensuremath{\mu }}l &
\textbf{20} \textbf{ \ensuremath{\mu }}l &
\textbf{30} \textbf{ \ensuremath{\mu }}l &
\textbf{40} \textbf{ \ensuremath{\mu }}l\\%\rowcolor{unitednationsblue}
1 &
\textit{Staphylococcus} \textit{ aureu}s &
20 &
- &
18 &
5 &
9 &
11 &
13\\%\rowcolor{unitednationsblue}
2 &
\textit{Bacillus} \textit{ subtili}s &
27 &
- &
16 &
3 &
7 &
10 &
11\\%\rowcolor{unitednationsblue}
6 &
\textit{Aspergillus\textit{}} \textit{ nige}r\textit{} &
- &
- &
20 &
7 &
13 &
15 &
17\\%\rowcolor{unitednationsblue}
\multicolumn{5}{p{\dimexpr(\mcWidth{1}+\mcWidth{2}+\mcWidth{3}+\mcWidth{4}+\mcWidth{5})}}{\multirow{2}{\linewidth}{ Control* - Gentamycin (1 mg/ml) Positive Control for Bacterial strains Fluconazole (1 mg/ml) Positive Control for Fungal strains}} &
&
&
&
\\%\rowcolor{unitednationsblue}
&
&
&
&
&
&
&
&
\\
\hline
\end{tabulary}\par
}
\end{table*}
\end{document}
Responder1
Lembre-se, mantenha as coisas simples...
\documentclass{article}
\usepackage{geometry}
\usepackage{tabulary,booktabs,multirow,lipsum}
\begin{document}
\lipsum[4][1-10]
\begin{table}[h]
\belowcaptionskip10pt
\extrarowheight1ex
\caption{Xxxxxxx xxxxxx xxxxx xxxxxxxx.}
\begin{tabulary}{\linewidth}{clcCCCCCC}\toprule
\multirow{3}{*}{No.}
& \multirow{3}{*}{Tested Microbes}
& \multicolumn{3}{c}{\parbox{10em}{\centering Zone de inhibition (diameter in mm)}}
& \multicolumn{4}{c}{\parbox{10em}{\centering Minimum Inibitory Concentration (MCI)}} \\
\cmidrule(rl){3-5}\cmidrule(rl){6-9}
&
& Control
& Plan
& \parbox{8em}{\centering Concentration of SeNPs 50 mM }
& 10\,µl & 20\,µl & 30\,µl & 40\,µl \\
\midrule
1 & \emph{Staphilococus aureus} & 13 & 14 & 15 & 16 & 17 & 18 & 19\\
2 & \emph{Bacillus subtilis} & ... & ... \\
... & \\\bottomrule
\end{tabulary}
\end{table}
\lipsum[3][1-6]
\end{document}
Responder2
Eu tentei algo, mas é muito difícil ter certeza de que a saída está correta sem saber como deveria ser. Na verdade, definir manualmente as larguras dos multicolumn
's fez a maior parte do trabalho. Você pode considerar escrever seu próprio código para tabelas complicadas como esta. Com o código no final, a tabela de saída fica assim.
Espero que ajude um pouco, com certeza está melhor do que era. Também adicionei ao siunitx
pacote para escrever o símbolo “µl”, onde µ deveria estar na vertical.
\documentclass[9pt,twocolumn]{article}
\usepackage{amsmath,amsfonts,amssymb,balance,tabulary,graphicx,caption,fancyhdr}
\usepackage[utf8]{inputenc}
\usepackage[numbers,super,sort&compress]{natbib}
\usepackage{url,multirow,morefloats,floatflt,cancel,tfrupee}
\usepackage{colortbl}
\usepackage{xcolor}
\usepackage{siunitx}
\definecolor{titlecolor}{RGB}{43, 116, 183}
\definecolor{numbercolor}{RGB}{0, 62, 136}
\definecolor{tableheadrcolor}{RGB}{229, 229, 229}
\definecolor{unitednationsblue}{RGB}{231, 236, 247}
\begin{document}
\title{Table issue}
\begin{table*}[!htbp]
\caption{{} }
\label{table-wrap-50e8bb32765343db8fd393ec8c403ec6}{%
\fontsize{8pt}{10pt}\selectfont
\def\arraystretch{1.5}
\ignorespaces
\centering
\begin{tabulary}{\linewidth}{LLLLLLLLL}
\hline %\rowcolor{tableheadrcolor}
\multicolumn{9}{p{9cm}}{\textbf{Table 1. Zone of inhibition of tested microbes}}
\\%\rowcolor{unitednationsblue}
\multicolumn{1}{p{1cm}}{
\multirow{3}{\linewidth}{\textbf{S. No.}}
}
& \multicolumn{1}{p{3cm}}{
\multirow{3}{\linewidth}{\textbf{Tested Microbes}}
}
& \multicolumn{7}{p{5.4cm}}{
\textbf{Zone of inhibition (diameter in mm)}
}
\\%\rowcolor{unitednationsblue}
&
& \multicolumn{1}{p{1cm}}{
\multirow{2}{\linewidth}{\textbf{Control}}
}
& \multicolumn{1}{p{1cm}}{
\multirow{2}{\linewidth}{\textbf{Plant}}
}
& \multicolumn{1}{p{2.6cm}}{
\multirow{2}{\linewidth}{\textbf{Concentration of SeNPs 50 mM}}
}
& \multicolumn{4}{p{3.2cm}}{
\textbf{Minimum Inhibitory Concentration (MIC})
}
\\%\rowcolor{unitednationsblue}
& & & &
& \textbf{\SI[detect-weight]{10}{\micro\litre}}
& \textbf{\SI[detect-weight]{20}{\micro\litre}}
& \textbf{\SI[detect-weight]{30}{\micro\litre}}
& \textbf{\SI[detect-weight]{40}{\micro\litre}}
\\%\rowcolor{unitednationsblue}
1
& \textit{Staphylococcus aureus}
& 20 & -- & 18 & 5 & 9 & 11 & 13
\\%\rowcolor{unitednationsblue}
2
& \textit{Bacillus subtilis}
& 27 & -- & 16 & 3 & 7 & 10 & 11
\\%\rowcolor{unitednationsblue}
6
& \textit{Aspergillus niger}
& -- & -- & 20 & 7 & 13 & 15 & 17
\\%\rowcolor{unitednationsblue}
\multicolumn{9}{p{10cm}}{
\multirow{2}{\linewidth}{Control* -- Gentamycin (1 mg/ml) Positive Control for Bacterial strains Fluconazole (1 mg/ml) Positive Control for Fungal strains}
}
\\%\rowcolor{unitednationsblue}
& & & & & & & &
\\
\hline
\end{tabulary}\par
}
\end{table*}
\end{document}
Responder3
O design da mesa depende sempre das preferências pessoais de como a mesa deve ser ou de alguns requisitos estritos/rígidos. Suponhamos que o último não seja o seu caso :-)
No design da sua tabela, é sensato considerar o seguinte:
- para unidades use
siunitx
pacote - para expressões químicas use
mhchem
pacote - para notas em uso de tabela
threeparttable
- usando
\multicolum
apenas onde é realmente necessário - para células com texto multilinha use
makecell
o pacote e sua macro com o mesmo nome (isso requer quebra manual de texto)
MWE completo é:
\documentclass[9pt,twocolumn]{article}
\usepackage{booktabs, % new
makecell, % new
multirow,
tabularx, % instead of tabulary
threeparttable} % new
\usepackage[skip=1ex, font=bf, singlelinecheck=off]{caption}
\usepackage{siunitx} % new
\usepackage[version=4]{mhchem} % new
\begin{document}
\begin{table*}
\begin{threeparttable}
\caption{Zone of inhibition of tested microbes}
\label{table-wrap-50e8bb32765343db8fd393ec8c403ec6}
\centering
\sisetup{table-column-width=2.5em, table-format=2.0}
\begin{tabularx}{\linewidth}{@{} c >{\itshape}l cc>{\centering}X SSSS}
\toprule
\multirow{3.4}{*}{\makecell{S.\\ No.}}
\multirow{3.4}{*}{\makecell{S.\\ No.}}
& \multirow{3.4}{*}{\textup{Tested Microbes}}
& \multicolumn{3}{c}{\makecell{Zone de inhibition\\ (diameter in mm)}}
& \multicolumn{4}{c}{\makecell{Minimum Inibitory\\ Concentration (MCI)}} \\
\cmidrule(r){3-5}\cmidrule{6-9}
& & Control\tnote{*}
& Plan
& \makecell{Concentration\\ of \ce{SeNP} \SI{50}{mM}}
& \SI{10}{\micro\litre}
& {\SI{20}{\micro\litre}}
& {\SI{30}{\micro\litre}}
& {\SI{40}{\micro\litre}} \\
\midrule
1 & Staphylococcus aureus & 20 & -- & 18 & 5 & 9 & 11 & 13 \\
2 & Bacillus subtilis & 27 & -- & 16 & 3 & 7 & 10 & 11 \\
6 & Aspergillus niger & -- & -- & 20 & 7 & 13 & 15 & 17 \\
\midrule[\heavyrulewidth]
\end{tabularx}
\begin{tablenotes}[para,raggedright]\footnotesize
\item[*] Gentamycin (\SI{1}{mg/ml}) Positive Control for Bacterial strains,
Fluconazole (\SI{1}{mg/ml}) Positive Control for Fungal strains
\end{tablenotes}
\end{threeparttable}
\end{table*}
\end{document}
Termo aditivo:
Caso o uso tabulary
seja obrigatório, makecell
não poderá ser utilizado. Em vez disso, deve ser usado \parbox
, da mesma forma queFranfazer ema resposta dele:
\documentclass[9pt,twocolumn]{article}
\usepackage{booktabs, % new
multirow,
tabulary, %
threeparttable} % new
\usepackage[skip=1ex, font=bf, singlelinecheck=off]{caption}
\usepackage{siunitx} % new
\usepackage[version=4]{mhchem} % new
\begin{document}
\begin{table*}
\begin{threeparttable}
\caption{Zone of inhibition of tested microbes}
\label{table-wrap-50e8bb32765343db8fd393ec8c403ec6}
\sisetup{table-column-width=2.5em, table-format=2.0}
\begin{tabulary}{\linewidth}{ C >{\itshape}L CC C SSSS}
\toprule
\multirow{3}{2em}{\centering S.\\No.}
& \multirow{3}{*}{\textup{Tested Microbes}}
& \multicolumn{3}{c}{Zone de inhibition (diameter in mm)}
& \multicolumn{4}{c}{\parbox{10em}{\centering
Minimum Inhibitory Concentration (MCI)}} \\
\cmidrule(r){3-5}\cmidrule(l){6-9}
& & Control\tnote{*}
& Plan
& \parbox{8em}{\centering Concentration of SeNPs \SI{50}{mM}\strut}
& \SI{10}{\micro\litre}
& \SI{20}{\micro\litre}
& \SI{30}{\micro\litre}
& \SI{40}{\micro\litre} \\
\midrule
1 & Staphylococcus aureus & 20 & -- & 18 & 5 & 9 & 11 & 13 \\
2 & Bacillus subtilis & 27 & -- & 16 & 3 & 7 & 10 & 11 \\
6 & Aspergillus niger & -- & -- & 20 & 7 & 13 & 15 & 17 \\
\midrule[\heavyrulewidth]
\end{tabulary}
\begin{tablenotes}[para,raggedright]\footnotesize
\item[*] Gentamycin (\SI{1}{mg/ml}) Positive Control for Bacterial strains,
Fluconazole (\SI{1}{mg/ml}) Positive Control for Fungal strains
\end{tablenotes}
\end{threeparttable}
\end{table*}
\end{document}