
다음과 같은 테이블을 만들고 싶습니다.
아직도 제목 줄을 제대로 삽입할 수 없습니다. 코드는 다음과 같습니다.
\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}
그러면 다음 테이블이 생성됩니다.
누락된 줄을 삽입하는 방법을 알려주실 수 있나요?
답변1
<a>
열에서 열로 이어지는 행을 삽입하려면 <b>
를 사용할 수 있습니다 \cline{<a>-<b>}
. 나는 사용하는 것이 좋습니다booktabs
그렇지만:
\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}
답변2
@Werner의 두 번째 솔루션을 보완하는 접근 방식은 다음과 같습니다. 나는 불필요한 것(그리고 경계선에 있는 저속해 보이는 것)을 제거하라고 권하고 싶습니다.용감한그리고이탤릭체헤더 셀에 있습니다. 잘 구조화된 헤더에서는 볼드체와 이탤릭체를 사용할 필요가 전혀 없습니다. 이와 별도로 테이블이 자동으로 열의 전체 너비에 걸쳐 있도록 하려면 tabular*
환경 대신 환경 을 사용할 수 있습니다 tabular
.
\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}