
Respuesta1
Algunas sugerencias y comentarios:
La mesa que se muestra en su captura de pantalla es muy "tradicional", es decir, bastante estrecha, poco atractiva y poco atractiva. La impresión general es la de la ventana de una celda de prisión: muchísimos barrotes horizontales y verticales. Su "aspecto" se muestra en la primera tabla a continuación.
Piensa un poco en darle a la mesa un "aspecto" más abierto. Una muy buena forma de hacerlo es (a) omitir todas las líneas verticales y (b) utilizar menos líneas horizontales pero bien espaciadas. Consulte el resultado en la segunda tabla a continuación.
Como variación del segundo enfoque,
tabular*
se podría utilizar un entorno en lugar de untabular
entorno, para permitir especificar previamente el ancho total de la tabla. Generalmente, pero no necesariamente, el ancho total se establece como\textwidth
, es decir, el ancho del bloque de texto.
Un comentario final: ninguno de estos tres enfoques garantiza realmente que la tabla quepa dentro del bloque de texto. Es especialmente probable que este problema ocurra si la tabla tiene muchas columnas. Si ese es un problema que está encontrando, debe publicar una nueva consulta, en la que exponga lo que ha probado hasta ahora.
\documentclass{article}
\usepackage{array,multirow}
\usepackage{booktabs} % for \toprule, \midrule, \cmidrule, and \bottomrule macros
\usepackage{newtxtext} % optional: load Times Roman clone text font
\begin{document}
\begin{table}
\centering
%% A. For the "traditional", i.e., cramped and rather unattractive "look":
\setlength\extrarowheight{2pt} % optional
\begin{tabular}{|l|*{8}{c|}}
\hline
\multirow{2}{*}{\textbf{Mapping Method}} &
\multicolumn{4}{c|}{\textbf{SVM (\%)}} &
\multicolumn{4}{c|}{\textbf{kNN (\%)}} \\
\cline{2-9}
& \textbf{AC} & \textbf{SP} & \textbf{SN} & \textbf{AUC}
& \textbf{AC} & \textbf{SP} & \textbf{SN} & \textbf{AUC} \\
\hline
\dots & & & & & & & & \\ \hline
\dots & & & & & & & & \\ \hline
\dots & & & & & & & & \\ \hline
\dots & & & & & & & & \\
\hline
\end{tabular}
\bigskip\bigskip
%% B. A much more open "look" (no vertical rules, few but well-spaced horizontal rules)
\setlength\extrarowheight{0pt} % reset to default value
\begin{tabular}{@{}l*{8}{c}@{}}
\toprule
\textbf{Mapping Method} &
\multicolumn{4}{c}{\textbf{SVM (\%)}} &
\multicolumn{4}{c@{}}{\textbf{kNN (\%)}} \\
\cmidrule(lr){2-5} \cmidrule(l){6-9}
& \textbf{AC} & \textbf{SP} & \textbf{SN} & \textbf{AUC}
& \textbf{AC} & \textbf{SP} & \textbf{SN} & \textbf{AUC} \\
\midrule
\dots & & & & & & & & \\
\dots & & & & & & & & \\
\dots & & & & & & & & \\
\dots & & & & & & & & \\
\bottomrule
\end{tabular}
\bigskip\bigskip
%% C. Same as "B" , but with overall width set to \textwidth
\setlength{\tabcolsep}{0pt}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} l *{8}{c} }
\toprule
\textbf{Mapping Method} &
\multicolumn{4}{c}{\textbf{SVM (\%)}} &
\multicolumn{4}{c}{\textbf{kNN (\%)}} \\
\cmidrule{2-5} \cmidrule{6-9}
& \textbf{AC} & \textbf{SP} & \textbf{SN} & \textbf{AUC}
& \textbf{AC} & \textbf{SP} & \textbf{SN} & \textbf{AUC} \\
\midrule
\dots & & & & & & & & \\
\dots & & & & & & & & \\
\dots & & & & & & & & \\ %\hline
\dots & & & & & & & & \\
\bottomrule
\end{tabular*}
\end{table}
\end{document}
Respuesta2
La siguiente solución, propuesta originalmente por @Mico enhttps://tex.stackexchange.com/a/192332/197451, debe adaptarse a su propósito:
\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{multirow,tabularx}
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\renewcommand{\arraystretch}{2}
\begin{document}
\emph{Original form: All columns are equally wide.}
\noindent
\begin{tabularx}{\textwidth}{|*{4}{Y|}}
\hline
\multirow{2}{*}{State of Health}
&\multicolumn{2}{c|}{Fasting Value}&After Eating\\
\cline{2-4}
&Minimum &Maximum &2 hours after eating\\
\hline
Healthy &70 &100 &Less than 140\\
\hline
Pre-Diabetes &101 &126 &140 to 200\\
\hline
Diabetes &More than 126 &N/A &More than 200\\
\hline
\end{tabularx}
\bigskip
\emph{Modified form: Columns 1 and 4 are 50\% wider than columns 2 and 3.}
\smallskip\noindent
\begin{tabularx}{\textwidth}{|
>{\hsize=1.2\hsize}Y|
>{\hsize=0.8\hsize}Y|
>{\hsize=0.8\hsize}Y|
>{\hsize=1.2\hsize}Y|}
\hline
\multirow{2}{*}{State of Health}
&\multicolumn{2}{c|}{Fasting Value}&After Eating\\
\cline{2-4}
&Minimum &Maximum &2 hours after eating\\
\hline
Healthy &70 &100 &Less than 140\\
\hline
Pre-Diabetes &101 &126 &140 to 200\\
\hline
Diabetes &More than 126 &N/A &More than 200\\
\hline
\end{tabularx}
\end{document}