0

I was working with this table. I had to change it to tabular in order for centering to work. Now I want to remove the part of the vertical lines on the top row and the part of the horizontal line on the first column. Is there a way to do so?

\begin{figure}[ht!]
\centering

\begin{tabular}{r|c|c|c|}
    & \hspace*{2cm} & $\bm{b^{i^*}}$ & \hspace*{2cm} \\ \hline
    &  0    & 0 & 0 \\ \hline
$i_*^*$ &  & $\mathbf{0}$ & 0  \\ \hline
$i_*^*+1$ & $\ne 0$ & {} $\ne 0$ &  \\ \hline
k & $\ne 0$ & {} $\ne 0$ &  \\ \hline
j & $\ne 0$ & {} $\ne 0$ &  \\ \hline
\end{tabular}

\end{figure}

3 Answers 3

2

It's easier if you use array in math mode, which eases input.

I present two realizations of your table, with columns from 2 to 4 having equal size. In the second realization, the second row is “detached” from the table proper.

\documentclass{article}
\usepackage{amsmath}
\usepackage{bm}
\usepackage{array}

\usepackage{booktabs} % for the second realization

\begin{document}

$\begin{array}{r|w{c}{1cm}|w{c}{1cm}|w{c}{1cm}|}
\multicolumn{1}{r}{} & \multicolumn{3}{c}{\bm{b^{i^*}}} \\
\cline{2-4}
                   &  0    & 0          & 0 \\
\cline{2-4}
           i_*^*   &       & \mathbf{0} & 0 \\
\cline{2-4}
           i_*^*+1 & \ne 0 & \ne 0      &   \\
\cline{2-4}
           k       & \ne 0 & \ne 0      &   \\
\cline{2-4}
           j       & \ne 0 & \ne 0      &   \\
\cline{2-4}
\end{array}$

\bigskip

$\begin{array}{rw{c}{1cm}w{c}{1cm}w{c}{1cm}}
\toprule
& \multicolumn{3}{c}{\bm{b^{i^*}}} \\
\cmidrule{2-4}
                   &  0    & 0          & 0 \\
\midrule
           i_*^*   &       & \mathbf{0} & 0 \\
           i_*^*+1 & \ne 0 & \ne 0      &   \\
           k       & \ne 0 & \ne 0      &   \\
           j       & \ne 0 & \ne 0      &   \\
\bottomrule
\end{array}$

\end{document}

enter image description here

3

With {NiceTabular} of nicematrix.

\documentclass{article}

\usepackage{nicematrix}
\usepackage{mathtools,bm}

\begin{document}

\begin{table}
\centering

\begin{NiceTabular}{ccc}[first-row,first-col,hvlines,columns-width=15mm]
    & & $\bm{b^{i^*}}$ & \\ 
    &  0    & 0 & 0 \\ 
$i_*^*$ &  & $\mathbf{0}$ & 0  \\ 
$i_*^*+1$ & $\ne 0$ & {} $\ne 0$ &  \\ 
$k$ & $\ne 0$ & {} $\ne 0$ &  \\ 
$j$ & $\ne 0$ & {} $\ne 0$ &  \\ 
\end{NiceTabular}

\end{table}

\end{document}

You need several compilations (because nicematrix uses PGF/Tikz nodes under the hood).

Output of the above code

1
\documentclass{article}
\usepackage{bm}
\begin{document}

\begin{figure}[ht!]
  \centering
  \begin{tabular}{r|c|c|c|}
    \multicolumn{1}{c}{}   &\multicolumn{1}{c}{ \hspace*{2cm}} &\multicolumn{1}{c}{ $\bm{b^{i^*}}$} & \multicolumn{1}{c}{\hspace*{2cm}} \\ \cline{2-4}
                           &  0    & 0 & 0 \\ \cline{2-4}
    $i_*^*$ &  & $\mathbf{0}$ & 0  \\ \cline{2-4}
    $i_*^*+1$ & $\ne 0$ & {} $\ne 0$ &  \\ \cline{2-4}
    k & $\ne 0$ & {} $\ne 0$ &  \\ \cline{2-4}
    j & $\ne 0$ & {} $\ne 0$ &  \\ \cline{2-4}
  \end{tabular}

\end{figure}

\end{document}

Table

You must log in to answer this question.

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