Tengo una tabla, que se hace usando tabular. La salida se ve bien, si no hay varias filas/columnas. Pero el resultado es muy malo si contiene varias filas. ¿Puede alguien ayudarme?.
\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}
Respuesta1
Recuerda, hazlo simple...
\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}
Respuesta2
Intenté algo, pero es bastante difícil asegurarme de que el resultado sea correcto sin saber cómo debería verse. En realidad, configurar manualmente los anchos de los multicolumn
's hizo la mayor parte del trabajo. Podrías considerar escribir tu propio código para tablas complicadas como ésta. Con el código al final, la tabla de salida se ve así.
Espero que ayude un poco, seguro que está mejor de lo que era. También agregué al siunitx
paquete para escribir el símbolo "μl", donde el μ debe estar en posición 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}
Respuesta3
El diseño de la mesa siempre depende de las preferencias personales de cómo debe verse la mesa o de algunos requisitos estrictos/rígidos. Supongamos que este último no es tu caso :-)
En el diseño de tu mesa es sensato considerar lo siguiente:
- para unidades use
siunitx
el paquete - para expresiones químicas utilice
mhchem
el paquete - para notas en uso de tabla
threeparttable
- usar
\multicolum
solo donde es realmente necesario - para celdas con texto de varias líneas, use
makecell
el paquete y su macro con el mismo nombre (esto requiere dividir el texto manualmente)
MWE completo es:
\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}
Apéndice:
En caso de que su uso tabulary
sea obligatorio, makecell
no podrá utilizarse. En su lugar, debe usarse \parbox
, de manera similar a como lo haceFranmatarsu respuesta:
\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}