2

I am using the longtable environment. When the table renders, there is an open space between the header row and the body rows, but not between the leading column and the body columns. How can I get both of these spaces open? (Both closed is also interesting but I prefer open.)

enter image description here

\begin{longtable}{| c || c | c | c | c |  }
                \hline
                  +& 0 & $~y\in\mathbb{R}_0~$ & $~\big(\aleph_\mathcal{Y}+ a\big)\in\mathbb{R}_0^\mathcal{X}~\vphantom{\widehat{\overline{\mathbb{R}_0^\mathcal{X}}}} $ & $~\big(\widehat\infty- |a|\big)\in\mathbb{R}_0^1\cup\widehat\infty~   $  \\ [4pt]
                \hline\hline
                 $0 \vphantom{\widehat{\overline{\mathbb{R}_0^\mathcal{X}}}} $&0& $y$  &$\aleph_\mathcal{Y}+ a$ & $\widehat\infty- |a|$ \\ [4pt]
                \hline
                 $~x~\vphantom{\widehat{\overline{\mathbb{R}_0^\mathcal{X}}}} $ & $x$ & $x+y$ &$\aleph_\mathcal{Y}+ \big(a+ x\big)$ &$\widehat\infty- \big(|a|- x\big)$ \\[4pt]
                \hline
                 $~\big(\aleph_\mathcal{X}+ b\big)~\vphantom{\widehat{\overline{\mathbb{R}_0^\mathcal{X}}}} $  & $\aleph_\mathcal{X}+ b$ & $\aleph_\mathcal{X}+ \big(b+y\big)$ &$\aleph_{(\mathcal{X+Y})}+ \big(b+a\big)$ &$\aleph_{(\mathcal{X}+1)}+ \big(b-|a|\big)$\\[4pt]
                \hline
                  $~\big(\widehat\infty- |b|\big)~\vphantom{\widehat{\overline{\mathbb{R}_0^\mathcal{X}}}}   $   & $\widehat\infty- |b|$ &   $\widehat\infty- \big(|b|-y\big)$ &$\aleph_{(1+\mathcal{ Y})}- \big(|b|-a\big)$  &$\aleph_{2}- \big(|b|+|a|\big)$\\[4pt]
                \hline
            \end{longtable}  

3 Answers 3

3

You can read the doc of tabularray to learn how to set caption or other.

Open

If you want open, you need to calculate the leftpos and rightpos, you can read rounding error (?) when doing double or triple line borders in table · Issue #216 · lvjr/tabularray. If you set the sep between two rule is 1.2pt, the default rule width is 0.4pt, the pos is equal to 0.4/(0.4*2+1.2)=0.2.

\documentclass{article}
\usepackage{tabularray}
\begin{document}
\begin{longtblr}
[
label=none,
]
{
colspec={Q[c,m]Q[c,m]Q[c,m]Q[c,m]Q[c,m]},
rulesep=1.2pt,
hline{2}={1}{1}{rightpos=.2},
hline{2}={2}{1}{rightpos=.2},
hline{2}={1}{2-Z}{leftpos=.2},
hline{2}={2}{2-Z}{leftpos=.2},
hline{1,3-Z}={1}{rightpos=.2},
hline{1,3-Z}={2-Z}{leftpos=.2},
vline{1,3-Z}={belowpos=0},
vline{2}={1}{-}{belowpos=0},
vline{2}={2}{-}{belowpos=0},
}
test & test & test & test & test \\
test & test & test & test & test \\
test & test & test & test & test \\
test & test & test & test & test \\
test & test & test & test & test \\
\end{longtblr}
\end{document}

enter image description here

Close

If you want to close, it is more simple.

\documentclass{article}
\usepackage{tabularray}
\begin{document}
\begin{longtblr}
[
label=none,
]
{
colspec={Q[c,m]Q[c,m]Q[c,m]Q[c,m]Q[c,m]},
rulesep=1.2pt,
hline{1,3-Z}={},
hline{2}={1}{-}{},
hline{2}={2}{-}{},
vline{1,3-Z}={belowpos=1},
vline{2}={1}{-}{belowpos=1},
vline{2}={2}{-}{belowpos=1},
}
test & test & test & test & test \\
test & test & test & test & test \\
test & test & test & test & test \\
test & test & test & test & test \\
test & test & test & test & test \\
\end{longtblr}
\end{document}

enter image description here

2
  • Thanks! Do you have any thoughts on getting them both open? I think that will look a good bit better. May 14, 2023 at 11:39
  • 1
    @hodopsmith I have updated my answer.
    – Clara
    May 14, 2023 at 12:10
2

Like this:

enter image description here

By ude of the hhline package:

\documentclass[a4paper]{article}
\usepackage{amssymb}
\usepackage{hhline}
\usepackage{longtable}

\begin{document}
\begin{longtable}{| c || c | c | c | c |  }
    \hhline{|-||----|}  % <----
      +& 0 & $~y\in\mathbb{R}_0~$ & $~\big(\aleph_\mathcal{Y}+ a\big)\in\mathbb{R}_0^\mathcal{X}~\vphantom{\widehat{\overline{\mathbb{R}_0^\mathcal{X}}}} $ & $~\big(\widehat\infty- |a|\big)\in\mathbb{R}_0^1\cup\widehat\infty~   $  \\ [4pt]
    \hhline{:=::====:}  % <----
     $0 \vphantom{\widehat{\overline{\mathbb{R}_0^\mathcal{X}}}} $&0& $y$  &$\aleph_\mathcal{Y}+ a$ & $\widehat\infty- |a|$ \\ [4pt]
    \hline
     $~x~\vphantom{\widehat{\overline{\mathbb{R}_0^\mathcal{X}}}} $ & $x$ & $x+y$ &$\aleph_\mathcal{Y}+ \big(a+ x\big)$ &$\widehat\infty- \big(|a|- x\big)$ \\[4pt]
    \hline
     $~\big(\aleph_\mathcal{X}+ b\big)~\vphantom{\widehat{\overline{\mathbb{R}_0^\mathcal{X}}}} $  & $\aleph_\mathcal{X}+ b$ & $\aleph_\mathcal{X}+ \big(b+y\big)$ &$\aleph_{(\mathcal{X+Y})}+ \big(b+a\big)$ &$\aleph_{(\mathcal{X}+1)}+ \big(b-|a|\big)$\\[4pt]
    \hline
      $~\big(\widehat\infty- |b|\big)~\vphantom{\widehat{\overline{\mathbb{R}_0^\mathcal{X}}}}   $   & $\widehat\infty- |b|$ &   $\widehat\infty- \big(|b|-y\big)$ &$\aleph_{(1+\mathcal{ Y})}- \big(|b|-a\big)$  &$\aleph_{2}- \big(|b|+|a|\big)$\\[4pt]
    \hhline{|-||----|}  % <----
\end{longtable}
\end{document}
3
  • If hhline can cut the bottom rules between column 1 and 2?
    – Clara
    May 14, 2023 at 12:12
  • @Clara it can (just replace hline by the hhline used on the last line) May 14, 2023 at 12:29
  • @DavidCarlisle Thank you!
    – Clara
    May 14, 2023 at 12:32
1

I'd like to encourage you to pursue a different route toward formatting happiness: Instead of spending time on fixing the appearance of the intersections of double vertical and horizonta lines, I'd like to encourage you to (a) get rid of all vertical lines (trust me, they won't be missed) and (b) use fewer, but well-spaced horizontal lines.

Under this alternative, the multitude of \vphantom and [4ex] spacing adjuster are also no longer needed. And the reduction in code complexity might be welcome as well, right?

As shown in the following screenshot, whitespace can be every bit as effective at forming a visual barrier as a straight (vertical or horizontal) line. Who knows, the absence of visual clutter may even invite some of your readers to pause and spend time looking at the table.

enter image description here

\documentclass{article} % or some other suitable document class
\usepackage[margin=1in]{geometry} % set page parameters as needed
\usepackage{mathtools,amssymb,longtable,array,booktabs}
\newcolumntype{C}{>{$\displaystyle}c<{$}} % automatic math mode
\DeclarePairedDelimiter\abs\lvert\rvert

\begin{document} 

\begin{longtable}{@{} CCCCC @{}} % all cells are in math mode by default

\toprule
  + 
& 0 
& y\in\mathbb{R}_0 
& (\aleph_{\mathcal{Y}} + a)\in\mathbb{R}_0^{\mathcal{X}}  
& ({\widehat\infty} - \abs{a})\in\mathbb{R}_0^1\cup{\widehat\infty} \\
\midrule
\endhead

\bottomrule
\endfoot


  0  
& 0
& y  
& \aleph_{\mathcal{Y}} + a 
& {\widehat\infty} - \abs{a} \\ 
\addlinespace

  x  
& x 
& x + y 
& \aleph_{\mathcal{Y}} + (a + x) 
& {\widehat\infty} - (\abs{a} - x) \\
\addlinespace

  (\aleph_{\mathcal{X}} + b)   
& \aleph_{\mathcal{X}} + b 
& \aleph_{\mathcal{X}} + (b + y) 
& \aleph_{(\mathcal{X + Y})} + (b + a) 
& \aleph_{(\mathcal{X} + 1)} + (b - \abs{a}) \\
\addlinespace

  ({\widehat\infty} - \abs{b})      
& {\widehat\infty} - \abs{b} 
& {\widehat\infty} - (\abs{b} - y) 
& \aleph_{(1 + \mathcal{ Y})} - (\abs{b} - a)  
& \aleph_{2} - (\abs{b} + \abs{a}) \\

\end{longtable}   

\end{document}

You must log in to answer this question.

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