How to create a table using latex exactly as follows. The table has to fit 1 column in the 2 column page format but the table headings are too long and the content in the first column also too long. So, I want to split the column headings and content of the first column in multiple lines with the bold format.
Not too sure why \makecell is not co-operating for bold the text and design a solid border all over but here's my latex code:
\begin{table}[h]
\begin{center}
\begin{tabularx}{\linewidth}{|L|L|L|L|L|}
\toprule
\makecell[lt]{Type}
&\makecell[lt]{Financial \\ benefit \\ of the \\users}
& \makecell[lt]{Financial\\ loss of the \\ users}
&\makecell[lt]{Interruption \\ of user’ \\ daily activity}
&\makecell[lt]{Monetary \\ reward \\ for works}\\
\midrule
\makecell[lt]{Category 1: \\ Work in \\ the retail \\ sector}
& \ding{51}
& \ding{51}
&
& \ding{51}\\
\midrule
\makecell[lt]{Category 2: \\ Work in \\ the industry \\ sector}
& \ding{51}
& \ding{51}
& \ding{51}
& \ding{51}\\
\midrule
\makecell[lt]{Category 3: \\ Work in \\ the corporate \\ sector}
& \ding{51}
& \ding{51}
& \ding{51}
& \ding{51}\\
\bottomrule
\end{tabularx}
\end{center}
\end{table}
The package
array
provides you a new tabular cell type
p={fixed width}
whit this cell type, you can define two new cell types that meets your alignemt requirements:
\newcolumntype{F}[1]{%
>{\raggedright\arraybackslash\hspace{0pt}}p{#1}}%
\newcolumntype{T}[1]{%
>{\centering\arraybackslash\hspace{0pt}}p{#1}}%
Full code:
\documentclass{article}
\usepackage{array}
\newcolumntype{F}[1]{%
>{\raggedright\arraybackslash\hspace{0pt}}p{#1}}%
\newcolumntype{T}[1]{%
>{\centering\arraybackslash\hspace{0pt}}p{#1}}%
\begin{document}
\begin{table}
\begin{tabular}{|F{0.2\textwidth}|T{0.2\textwidth}|T{0.2\textwidth}|T{0.2\textwidth}|T{0.2\textwidth}|}
\hline
\textbf{\hfil Type}&
\textbf{Financial benefit of the users}&
\textbf{Financial loss of the users }&
\textbf{Interruption of user daily activity}&
\textbf{Monetary reward for works}\\
\hline
\textbf{Category 1: Work in the retail sector } &\textbf{v}&&v&v \\
\hline
\textbf{Category 2: Work in the industry sector} &v&v&v&v \\
\hline
\textbf{Category 3: Work in the corporate sector} &&v&v&v \\
\hline
\end{tabular}
\end{table}
\end{document}