I made a table, but the table does not fit on the page. The code for the table is:
\begin{table}[H]
\centering
\label{my-label}
\begin{tabular}{|l|c|c|c|c|c|}
\hline
& \multicolumn{1}{l|}{} & \multicolumn{1}{l|}{} & \multicolumn{1}{l|}{} & \multicolumn{1}{l|}{} & \multicolumn{1}{l|}{} \\ \hline
& x & 0 & 0 & 0 & 1 \\ \hline
& 1 & x & 0 & 0 & 1 \\ \hline
& 1 & 1 & x & 1 & 1 \\ \hline
& 1 & 1 & 0 & x & 1 \\ \hline
& 0 & 0 & 0 & 0 & x \\ \hline
& 3 & 2 & 0 & 1 & 4 \\ \hline
& 4 & 3 & 1 & 2 & 5 \\ \hline
\end{tabular}
\end{table}
How do I change the width of the table so that it fits on the page?
Best Answer
Your
tabular
environment is currently not allowing line breaks in the header cells, for two reasons. First, the five data columns are of typec
, which doesn't allow line breaks. Second, the header cells are actually typeset using thel
column type, which doesn't allow line breaks either.I suggest you (a) get rid of the
\multicolumn{1}{l}
"wrappers", (b) use atabularx
environment instead of atabular
environment, and (c) use a centered version of theX
column type for the five data columns.I would also get rid of all vertical rules. That'll immediately give the table a more "open" and inviting look.