3

First time asking a question, would like to apologize ahead if the question isn't in the right format.

I want the cells in row 1 to not have any horizontal lines. I want the first cell in row 2 to not have any outside border lines. I want the first two cells in row 3 to not have any lines and I want the first 3 cells in row 4 to not have any outside border lines. I have seen something similar to what I require but the triangle is not the right shape. This is what I have tried

\begin{tabular}{c|*{3}{c|}}
    & $_2$ & $_3$ & $_4$ \\ \cline{2-4}
    \hline
  $_1$ & 8 & 9 & 12     \\ \cline{1-1} \cline{3-4}
  \hline
  \multicolumn{1}{@{}c@{}|}{} & $_2$ & 15 & 13     \\ \hline
    &  &  $_3$&  11\\
\end{tabular}

Any help will be appreciated

3
  • 3
    Welcome. // If you copy your code into a new file and compile, it won‘t succeed. Please add the missing lines to your code. // A sketch of your intended table might help, too. Thank you
    – MS-SPO
    Commented May 20 at 14:30
  • 2
    See tex.meta.stackexchange.com/q/228 for advice preparing examples for questions.
    – cfr
    Commented May 20 at 14:39
  • 1
    Hello and welcome. Can you add a freehand figure to make your question clearer?
    – AndréC
    Commented May 20 at 18:06

3 Answers 3

6

I'm not sure if this is what you want, but here is a possibility with the nicematrix package.

The option hvlines draws all horizontal and vertical rules, except:

  • the option corners excludes empty cells in the four corners (together with empty rectangles containing the corners). In this case we only care about the southwest corner, so corners=SW is used.
  • the options first-row and first-col exclude the first row and column respectively.

enter image description here

\documentclass{article}

\usepackage{nicematrix}

\begin{document}

\NiceMatrixOptions{code-for-first-row=\scriptsize, code-for-first-col=\scriptsize}
\begin{NiceTabular}{ccc}[hvlines, corners=SW, first-row, first-col]
& 2 & 3 & 4\\
1 & 8 & 9 & 12\\
2 && 15 & 13\\
3 &&& 11
\end{NiceTabular}

\end{document}
1
  • Hi Sandy, Thanks for answering me. This will work definitely. Have a great day further. Commented May 21 at 8:59
5

I have assumed you meant: "I want the cells in row 1 to not have any vertical lines", because that seems more logical to me.

\documentclass{article}
\newcommand\M{\multicolumn{1}{c}}
\newcommand\MI{\multicolumn{1}{c|}}
\begin{document}

\centering

\begin{tabular}{c|*{3}{c|}}
 \M{} & \M{$_2$} & \M{$_3$} & \M{$_4$} \\ \cline{2-4}
    %\hline
  \MI{$_1$} & 8 & 9 & 12     \\ \cline{2-4}
  \M{} & \MI{$_2$} & 15 & 13     \\ \cline{3-4}
  \M{} & \M{} &  \MI{$_3$} & 11 \\ \cline{4-4}
\end{tabular}

\end{document}

enter image description here

1
  • Hi Pieter, This is perfect. It will work as is. Thanks so much!! Commented May 21 at 9:00
1

With correctly connecting corners (see first diagram) or with a Young tableau (see second diagram)

\documentclass{article}
\usepackage{hhline,array}

\usepackage{ytableau}

\begin{document}

\[
\newcommand{\z}[1]{\multicolumn{1}{c}{\scriptstyle#1}}
\newcommand{\0}[1]{\multicolumn{1}{c|}{\scriptstyle#1}}
\newcommand{\1}[1]{\multicolumn{1}{w{c}{1em}|}{#1}}
\begin{array}{ c *{3}{w{c}{1em}} }
\z{}  & \z{2} & \z{3}  & \z{4}  \\ \hhline{~|-|-|-|}
\0{1} & \1{8} & \1{9}  & \1{12} \\ \hhline{~|-|-|-|}
      & \0{2} & \1{15} & \1{13} \\ \hhline{~ ~|-|-|}
      &       & \0{3}  & \1{11} \\ \hhline{~ ~ ~|-|}
\end{array}
\]

\[
\begin{ytableau}
\none & \none[\scriptstyle 2] & \none[\scriptstyle 3] & \none[\scriptstyle 4] \\
\none[\scriptstyle 1] & 8 & 9 & 12 \\
\none & \none[\scriptstyle 2] & 15 & 13 \\
\none & \none & \none[\scriptstyle 3] & 11
\end{ytableau}
\]

\end{document}

enter image description here

You must log in to answer this question.

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