3

I start with this:

\documentclass[border=2mm]{standalone}

\begin{document}
\begin{table}[h!]
    \begin{center}
        \begin{tabular}{c|c|c|c|}  
            \hline
             & hello & hello & hello  \\
            \hline
            1 &  & & \\
            \hline
            2 &  & &\\
            \hline
            3 &  & &\\
            \hline
        \end{tabular}
    \end{center}
\end{table} 
\end{document}

enter image description here

But my objective is get this table structure where I can put a green check or red X:

enter image description here

Tiuri
  • 7,749
Vidal
  • 359

1 Answers1

7

Inspired by this answer, I defined two macros \cmark and \xmark based on the \ding macro from the \pifont package, and added some colors with the xcolor package:

\documentclass[border=2mm]{standalone}
\usepackage{pifont}
\usepackage{xcolor}
\newcommand{\cmark}{\textcolor{green!80!black}{\ding{51}}}
\newcommand{\xmark}{\textcolor{red}{\ding{55}}}
\begin{document}\renewcommand{\arraystretch}{1.2}
\begin{tabular}{|c|c|c|c|}  
    \cline{2-4}
    \multicolumn{1}{c|}{} & hello & hello & hello  \\
    \hline
    1 & \cmark & \cmark & \cmark \\
    \hline
    2 & \cmark & \xmark & \cmark \\
    \hline
    3 & \xmark & \cmark & \xmark \\
    \hline
\end{tabular}
\end{document}

enter image description here

Other things I did to match your sketch:

  • To remove the horizontal line above the first empty cell, I replaced the first \hline by \cline{2-4}.
  • To remove the vertical line before the first empty cell, I added in front of the first line \multicolumn{1}{c|}{}.
  • To add some more space to the symbols in the cells, I redefined \arraystretch to a value of 1.2.
Tiuri
  • 7,749
  • One question Tiuri. When I write alot in the first left column, the \\ is not generated automatically. How can I do a new line when I write a lot in that rectangle? maximum width? Thanks – Vidal May 14 '18 at 10:24
  • 1
    Use e.g. p{2cm} instead of c for the first column specifier in \begin{tabular} to fix the width of the first column and activate automatic line breaks. If that doesn't satisfy your needs, search this site for "linebreaks in table" or similiar, or feel free to ask a new question. – Tiuri May 14 '18 at 10:28
  • Hi!! With p{2cm} works nice. The only downside is that when there are several lines in the first column on the left, the check is not centered on the rectangle, it is at the top of the rectangle – Vidal May 14 '18 at 10:34
  • 1
    I don't have an easy solution to that at hand. I suggest that you use the search function (there exist a lot of questions and answers on vertical alignment of table cells) or ask a specific question about that issue. – Tiuri May 14 '18 at 12:16