如何固定表格中的列宽

如何固定表格中的列宽

我对以下代码感到厌倦,但总是得到大小不等的列{我需要相同宽度的列(2 端)。

\begin{table}[h]
\resizebox{\textwidth}{!}{%
\begin{tabular}{|p{8cm}|l|l|l|l|l|l|l|l|l|l|l|l|}
\hline

\textbf{Subject} & \multicolumn{4}{l|}{\textbf{First year}} & \multicolumn{4}{l|}{\textbf{Second year}} & \multicolumn{4}{l|}{\textbf{Third year}} \\ \hline
Literature survey on stochastic geometry, heterogeneous cellular networks, caching system, and interference mitigation techniques in cellular networks  & \cellcolor[HTML]{656565} & \cellcolor[HTML]{656565} &  &  &  &  &  &  &  &  &  &  \\ \hline
Develop interference mitigation technique for the single tier caching system &  &  & \cellcolor[HTML]{656565} & \cellcolor[HTML]{656565} &  &  &  &  &  &  &  &  \\ \hline
Study the trade-off between the achievable hit probability gain and the overhead &  &  &  &  & \cellcolor[HTML]{656565} & \cellcolor[HTML]{656565} &  &  &  &  &  &  \\ \hline
Extend the study to heterogeneous cache-enabled cellular network and propose an interference suppression technique for both cross tier and intercell interference &  &  &  &  &  &  & \cellcolor[HTML]{656565} & \cellcolor[HTML]{656565} &  &  &  &  \\ \hline
Study the analysis with introducing cognitive cache-enabled users tier scenario &  &  &  &  &  &  &  &  & \cellcolor[HTML]{656565} & \cellcolor[HTML]{656565} &  &  \\ \hline
Extracting the final recommendations depending on the research conclusions  &  &  &  &  &  &  &  &  &  &  & \cellcolor[HTML]{656565} & \cellcolor[HTML]{656565} \\ \hline
\end{tabular}%
}
\end{table}

答案1

使用tabularx环境而不是仅仅使用环境来tabular从所有中受益\textwidth,同时具有相同宽度的列。

\documentclass{article}
\usepackage[margin=2cm]{geometry}
\usepackage{graphicx,xcolor}
\usepackage{colortbl,tabularx}     
\begin{document}

\begin{table}[h]
\resizebox{\textwidth}{!}{%
\begin{tabularx}{\textwidth}{|p{8cm}|*{12}{X|}}
\hline
\textbf{Subject} & \multicolumn{4}{l|}{\textbf{First year}} & \multicolumn{4}{l|}{\textbf{Second year}} & \multicolumn{4}{l|}{\textbf{Third year}} \\ \hline
Literature survey on stochastic geometry, heterogeneous cellular networks, caching system, and interference mitigation techniques in cellular networks  & \cellcolor[HTML]{656565} & \cellcolor[HTML]{656565} &  &  &  &  &  &  &  &  &  &  \\ \hline
Develop interference mitigation technique for the single tier caching system &  &  & \cellcolor[HTML]{656565} & \cellcolor[HTML]{656565} &  &  &  &  &  &  &  &  \\ \hline
Study the trade-off between the achievable hit probability gain and the overhead &  &  &  &  & \cellcolor[HTML]{656565} & \cellcolor[HTML]{656565} &  &  &  &  &  &  \\ \hline
Extend the study to heterogeneous cache-enabled cellular network and propose an interference suppression technique for both cross tier and intercell interference &  &  &  &  &  &  & \cellcolor[HTML]{656565} & \cellcolor[HTML]{656565} &  &  &  &  \\ \hline
Study the analysis with introducing cognitive cache-enabled users tier scenario &  &  &  &  &  &  &  &  & \cellcolor[HTML]{656565} & \cellcolor[HTML]{656565} &  &  \\ \hline
Extracting the final recommendations depending on the research conclusions  &  &  &  &  &  &  &  &  &  &  & \cellcolor[HTML]{656565} & \cellcolor[HTML]{656565} \\ \hline
\end{tabularx}%
}
\end{table}

\end{document}

在此处输入图片描述

相关内容