2
\documentclass[12pt,a4paper]{article}  
\usepackage{amsmath}  
\usepackage{amsthm}  
\usepackage{amssymb}  
\usepackage{ragged2e}
\usepackage{tabularx}
\usepackage{graphicx}
\begin{document}  
\begin{table}[h!]
    \begin{center}
        \begin{tabular}{ccccc}
            $0$ &$0$ &$-$ &$1$\\
            $0$ &$0$ &$1$ &$-$ \quad &$\checkmark$\\ 
            $-$ &$0$ &$1$ &$0$ \quad &$\checkmark$\\ \hline
            $-$ &$0$ &$1$ &$1$ \quad &$\checkmark$ \\
            $1$ &$0$ &$1$ &$-$ \quad &$\checkmark$\\
            $1$ &$-$ &$1$ &$0$ \\
            $1$ &$1$ &$-$ &$0$ \\   
        \end{tabular}
        \caption{}
    \end{center}
\end{table}
\end{document}
  1. With this, the underline also covers the checkmark column. But I want to exclude the checkmark column. How do I do this?
  2. How do I leave a cell empty in the table?. For example, consider the (1,2), (2,4) cells are supposed to be empty cells.
2
  • 2
    \cline{1-4} instead of \hline.
    – user240002
    Commented Apr 23, 2021 at 6:41
  • 1
    To leave a cell blank, just remove its contents, in this case, remove $-$
    – leandriis
    Commented Apr 23, 2021 at 6:54

2 Answers 2

3

Now, only off-topic, since your question is already solved by comments ;-). I would instead tabular use array and consequently remove all ampersands from table body code:

\documentclass[12pt,a4paper]{article}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{ragged2e}
\usepackage{tabularx}
\usepackage{graphicx}

\begin{document}
\begin{table}[h!]
    \[
        \begin{array}{cc cc c}
            0 &  &- &1  &           \\
            0 &0 &1 &   &\checkmark \\
            - &0 &1 &0  &\checkmark \\
    \cline{1-4}
            - &0 &1 &1  &\checkmark \\
            1 &0 &1 &-  &\checkmark \\
            1 &- &1 &0  &           \\
            1 &1 &- &0  &
        \end{array}
    \]
        \caption{}
\end{table}
\end{document}

enter image description here

Note: It is not good idea to left out ampersands for empty cells at end row. See MWE above and compare codes with your example!

-1

I think you can use https://www.tablesgenerator.com/ for generating tables without worrying about how to code. This tool will simply convert your table (GUI) into Latex code.

1
  • 2
    While tools like the mentioned tablesgenerator can indeed produce latex code that in the end results in a table, this code is often quite messy and more often than not results in an output other than the expected one. Repairing/adjustin such an auto-generated code in order to suit ones needs is often harder than rewriting it from scratch. I thus strongly suggest not relying too much on tool that automatically generate LaTeX code.
    – leandriis
    Commented Apr 23, 2021 at 18:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .