How do I change the width of the table to the text width in Latex?

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?

• Welcome to TeX.SX! Can you please expand the code snippets that you have posted to a full minimal working example. It is much easier to help you you if we can start with some compilable code that illustrates your problem. A MWE should compile and be as small as possible to demonstrate your problem. You can code-blocks either by indenting them by four spaces or using the {} on the gui - for in-line code use back-ticks. – user30471 Dec 4 '16 at 20:01
• You need narrower column headers. If this is not possible then use the multirow package to have the column labels span more than one row. I'd also drop the \hlines as this will look much better -- see the booktabs manual for a discussion on best practice in writing tables. – user30471 Dec 4 '16 at 20:07

Your tabular environment is currently not allowing line breaks in the header cells, for two reasons. First, the five data columns are of type c, which doesn't allow line breaks. Second, the header cells are actually typeset using the l column type, which doesn't allow line breaks either.

I suggest you (a) get rid of the \multicolumn{1}{l} "wrappers", (b) use a tabularx environment instead of a tabular environment, and (c) use a centered version of the X 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.

\documentclass{article}
\usepackage[letterpaper,margin=1in]{geometry} % choose page size parameters suitable
\usepackage{float,tabularx}
\newcolumntype{C}{>{\centering\arraybackslash}X} % centered version of "X" column type
\begin{document}
\begin{table}[H]
\setlength\extrarowheight{2pt} % create a more open look
\setlength\tabcolsep{3pt}      % default value: 6pt
\caption{Being cool} \label{my-label}
\begin{tabularx}{\textwidth}{@{} l *{5}{C} @{}}
\hline
& Cool as much as possible
& The COP as high as possible
& Have as much input power as possible
& Cool as quick as possible
& System as safe as possible
\\ \hline
Cool as much as possible             & x & 0 & 0 & 0 & 1 \\ \hline
The COP as high as possible          & 1 & x & 0 & 0 & 1 \\ \hline
Have as much input power as possible & 1 & 1 & x & 1 & 1 \\ \hline
Cool as quick as possible            & 1 & 1 & 0 & x & 1 \\ \hline
System as safe as possible           & 0 & 0 & 0 & 0 & x \\ \hline
& 3 & 2 & 0 & 1 & 4 \\ \hline
Weight factor                        & 4 & 3 & 1 & 2 & 5 \\ \hline
\end{tabularx}
\end{table}
\end{document}