Reglas en columnas específicas

Reglas en columnas específicas

Me gustaría crear una tabla que se vea así:

ingrese la descripción de la imagen aquí

Todavía no puedo insertar las líneas de los títulos correctamente. Aquí está el código:

\documentclass[10pt,conference]{IEEEtran}
\begin{document}

\begin{table}
\caption{Time taken for full encryption/decryption using different crypto algorithms}
\centering
\begin{tabular}{|*{7}{c|}}
\hline
\textbf{CPU}  & \multicolumn{3}{c}{\textbf{Encryption}} & \multicolumn{3}{|c|}{\textbf{Decryption}}
\\\textbf{Time}
& \multicolumn{3}{c}{} &\multicolumn{3}{|c|}{}
\\\textbf{(seconds)}
& \textbf{\textit{TLS}} & \textbf{\textit{CTR}} & \textbf{\textit{CBC}} & \textbf{\textit{TLS}} & \textbf{\textit{CTR}} & \textbf{\textit{CBC}}\\ \hline
Minimum & 2.2612 & 1.4145 & 2.0110 & 2.1037 & 1.4267 & 1.4002\\ \hline
Maximum & 3.0849 & 1.4156 & 2.0232 & 2.7585 & 1.4339 & 1.4059\\ \hline
Average & 2.6684 & 1.4150 & 2.0154 & 2.4186 & 1.4324 & 1.4026\\ \hline
\end{tabular}
\end{table}

\end{document}

Esto genera la siguiente tabla:

ingrese la descripción de la imagen aquí

¿Puedes decirme cómo insertar esa línea que falta?

Respuesta1

Para insertar líneas que abarquen columnas de una columna <a>a otra <b>, puede utilizar \cline{<a>-<b>}. Yo sugeriría usarbooktabsaunque:

ingrese la descripción de la imagen aquí

ingrese la descripción de la imagen aquí

\documentclass[10pt,conference]{IEEEtran}

\usepackage{booktabs}

\begin{document}

\begin{table}
  \caption{Time taken for full encryption/decryption using different crypto algorithms}
  \centering
  \begin{tabular}{|*{7}{c|}}
    \hline
    \textbf{CPU}  & \multicolumn{3}{c}{} & \multicolumn{3}{|c|}{} \\
    \textbf{Time} & \multicolumn{3}{c}{\textbf{Encryption}} &\multicolumn{3}{|c|}{\textbf{Decryption}} \\
    \cline{2-7}
    \textbf{(seconds)} & \textbf{\textit{TLS}} & \textbf{\textit{CTR}} & \textbf{\textit{CBC}} & \textbf{\textit{TLS}} & \textbf{\textit{CTR}} & \textbf{\textit{CBC}} \\
    \hline
    Minimum & 2.2612 & 1.4145 & 2.0110 & 2.1037 & 1.4267 & 1.4002 \\
    \hline
    Maximum & 3.0849 & 1.4156 & 2.0232 & 2.7585 & 1.4339 & 1.4059 \\
    \hline
    Average & 2.6684 & 1.4150 & 2.0154 & 2.4186 & 1.4324 & 1.4026 \\
    \hline
  \end{tabular}
\end{table}

\begin{table}
  \caption{Time taken for full encryption/decryption using different crypto algorithms}
  \centering
  \begin{tabular}{ *{7}{c} }
    \toprule
    & \multicolumn{3}{c}{\textbf{Encryption}} &\multicolumn{3}{c}{\textbf{Decryption}} \\
    \cmidrule(lr){2-4}\cmidrule(lr){5-7}
    \raisebox{\dimexpr1.25\normalbaselineskip-.5\height}[0pt][0pt]{\begin{tabular}{@{}c@{}}
      \textbf{CPU time} \\ \textbf{(seconds)}
    \end{tabular}} & \textbf{\textit{TLS}} & \textbf{\textit{CTR}} & \textbf{\textit{CBC}} & \textbf{\textit{TLS}} & \textbf{\textit{CTR}} & \textbf{\textit{CBC}} \\
    \midrule
    Minimum & 2.2612 & 1.4145 & 2.0110 & 2.1037 & 1.4267 & 1.4002 \\
    Maximum & 3.0849 & 1.4156 & 2.0232 & 2.7585 & 1.4339 & 1.4059 \\
    Average & 2.6684 & 1.4150 & 2.0154 & 2.4186 & 1.4324 & 1.4026 \\
    \bottomrule
  \end{tabular}
\end{table}

\end{document}

Respuesta2

Aquí hay un enfoque que complementa la segunda solución de @ Werner. Me gustaría recomendarle que se deshaga de los innecesarios (y casi vulgares)atrevidoycursivaen las celdas del encabezado. Con un encabezado bien estructurado, no debería ser necesario el uso de negrita y cursiva. Por otra parte, para garantizar que la tabla abarque automáticamente todo el ancho de la columna, es posible que desee utilizar un tabular*entorno en lugar del tabularentorno.

ingrese la descripción de la imagen aquí

\documentclass[10pt,conference]{IEEEtran}
\usepackage{booktabs}
\begin{document}

\begin{table}
\setlength\tabcolsep{0pt} % let tabular* figure out intercolumn whitespace
\caption{CPU time taken for full encryption/decryption using different crypto algorithms}
\begin{tabular*}{\columnwidth}{@{\extracolsep{\fill}}l*{6}{c}}
\toprule
CPU Time  & \multicolumn{3}{c}{Encryption} & \multicolumn{3}{c}{Decryption}\\
\cmidrule{2-4} \cmidrule{5-7}
(seconds)
& TLS & CTR & CBC & TLS & CTR & CBC\\ 
\midrule
Minimum & 2.2612 & 1.4145 & 2.0110 & 2.1037 & 1.4267 & 1.4002\\ 
Maximum & 3.0849 & 1.4156 & 2.0232 & 2.7585 & 1.4339 & 1.4059\\ 
Average & 2.6684 & 1.4150 & 2.0154 & 2.4186 & 1.4324 & 1.4026\\ 
\bottomrule
\end{tabular*}
\end{table}

\end{document}

información relacionada