2

I was trying to create a double entry table but as I'm extremely new to Latex using the nicematrix/nicetabular packages seemed a bit daunting. I decided to try my luck messing around with the "regular" tabular command whilst using the multicolumn and multirow commands so I can get used to them. I arrived at an esthetically satisfactory result except for the vertical line circled in the image below. How can I remove that line from that particular cell only? Thanks in advance

Code used :

\documentclass{article}
\usepackage{amsmath}
\usepackage{multirow}
\usepackage{amssymb}

\begin{article}
\begin{center}
    \begin{tabular}{ c | c | c | c | c |}
      \multicolumn{4}{r}{$\displaystyle\lim_{x \to a} f(x)$} \\ \cline{3-5}
      \multirow{4}{*}{$\displaystyle\lim_{x \to a} g(x)$}
      & & $-\infty$ & $l_1 \in \mathbb{R}$ & $+\infty$ \\ \cline{2-5}
      & $-\infty$ & $-\infty$ & $-\infty$ & ? \\ \cline{2-5}
      & $l_2 \in \mathbb{R}$ & $-\infty$ & $l_1 + l_2$ & $+\infty$ \\ \cline{2-5}
      & $+\infty$ & ? & $+\infty$ & $+\infty$ \\ \cline{2-5}
    \end{tabular}
  \end{center}
  
\end{article}
1

3 Answers 3

3

As a quick hack, you can use \multicolumn{1}{c}{} to switch of the lines for a given cell.

I think your table would look better if the limits would be centred with respect to the filled cells in the first row/column:

\documentclass{article}
\usepackage{amsmath}
\usepackage{multirow}
\usepackage{amssymb}

\begin{document}
\begin{center}
    \begin{tabular}{ c | c | c | c | c |}
     \multicolumn{1}{c}{}  & \multicolumn{1}{c}{} & \multicolumn{3}{c}{$\displaystyle\lim_{x \to a} f(x)$} \\ \cline{3-5}
      \multicolumn{1}{c}{} &  & $-\infty$ & $l_1 \in \mathbb{R}$ & $+\infty$ \\ \cline{2-5}
      \multirow{3}{*}{$\displaystyle\lim_{x \to a} g(x)$} & $-\infty$ & $-\infty$ & $-\infty$ & ? \\ \cline{2-5}
      & $l_2 \in \mathbb{R}$ & $-\infty$ & $l_1 + l_2$ & $+\infty$ \\ \cline{2-5}
      & $+\infty$ & ? & $+\infty$ & $+\infty$ \\ \cline{2-5}
    \end{tabular}
  \end{center}
  
\end{document}

enter image description here

3
  • 1
    +1. Since the table's contents are all math-y, it may be worth switching from a tabular to an array environment.
    – Mico
    Aug 17, 2023 at 13:57
  • @Nadimanator You're welcome! I made the multicolumn/multirow smaller to only span columns/rows 3-5. This way your limits are centred with respect to the filled cells and don't look so off-centred. Aug 17, 2023 at 14:02
  • @Mico Thanks! If switching to anything, I'd rather go the tabularray road to make merging cells easier. Aug 17, 2023 at 14:03
2

Here how you can do that tabular with nicematrix.

  • I have used {NiceArray} since all the entries are in math mode.

  • In the environments of nicematrix, you merge cells both horizontally and vertically with the command \Block.

  • In your case, all the rules you want are drawn by using the keys first-row, first-col, corners and hvlines. The keys first-row and first-col means there are a "first row" and a "first col" outside the main tabular (and hence, outside the rules...). The keys corners computes empty corners (in this case, the empty cell in the position "north-west") and the key hvlines draws all the rules excepted in the corners, the first row and the first col (and the commands \Block).

\documentclass{article}
\usepackage{nicematrix}
\usepackage{amssymb}

\begin{document}

\NiceMatrixOptions{cell-space-limits=3pt}

\begin{center}

$\begin{NiceArray}{cccc}[first-row,first-col,corners,hvlines]
 & & \Block{1-3}{\displaystyle\lim_{x \to a} f(x)} \\ 
 &  & -\infty & l_1 \in \mathbb{R} & +\infty \\ 
  \Block{3-1}{\displaystyle\lim_{x \to a} g(x)} & -\infty & -\infty & -\infty & ? \\ 
 & l_2 \in \mathbb{R} & -\infty & l_1 + l_2 & +\infty \\ 
 & +\infty & ? & +\infty & +\infty \\ 
\end{NiceArray}$

\end{center}
  
\end{document}

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

Output of the above code

0

Version with tabularray package:

\documentclass{article}
\usepackage{tabularray}
\UseTblrLibrary{amsmath}
\usepackage{amssymb}

\begin{document}
    \begin{center}
\begin{tblr}{hline{1,2} = {3-Z}{solid}, hline{3-Z} = {2-Z}{solid},
             vline{2} = {3-Z}{solid}, vline{3-Z} = {1-Z}{solid},
             colspec  = { *{5}{Q[c, wd=4em, mode=dmath]} },
             rowsep  = {5pt}
             }
% table body
    &   & \SetCell[c=3]{}   \lim_{x \to a} f(x)
            &   &               \\
    &   &   -\infty 
            &   l_1 \in \mathbb{R}
                &  +\infty    
                                \\
\SetCell[r=3]{} \lim_{x \to a} g(x)
    &   -\infty
        &   -\infty
            &   -\infty
                & ?              \\ 
    &   l_2 \in \mathbb{R}
            &   -\infty
                &   l_1 + l_2
                    &   +\infty \\
    &   +\infty
        & ? &   +\infty
                &   +\infty     \\
\end{tblr}
    \end{center}
\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 .