2
\begin{tabular}{ | c | c | c | }
  \hline                       
  1 & 2 & 3 \\ \hline
  4 & 5 & 6 \\ \hline
  7 & 8 & 9 \\
  \hline  
\end{tabular}

If we want to create a table with all the borders (like an MS Word table), is there a simple single option we can use in LaTex to create such table instead of typing "|" and \hline at multiple places (as shown in the above example)?

5
  • 6
    Fortunately not.
    – Fran
    Apr 25, 2015 at 18:13
  • 6
    As far as I know there's nothing in standard packages. But why the hell do you want to mimic ugly typography?
    – Bernard
    Apr 25, 2015 at 18:14
  • 3
    On a completely unrelated matter, the documentation of package booktabs has some nice tips regarding the typesetting of nice tables.
    – Johannes_B
    Apr 26, 2015 at 16:29
  • Never have used ConTeXt myself I am willing to bet that it has this option…
    – cgnieder
    Mar 2, 2017 at 20:02
  • On a completely related matter, the documentation of package booktabs has some nice tips regarding the typesetting of nice tables. The #1 tip is that you should never use vertical lines. The #2 tip is that you should (almost) never use double horizontal lines. A related item to #2 is that people use way too many horizontal lines, and most tables look much nicer without them. For this reason, there's not as much effort in TeX to make vertical and horizontal lines easier to draw.
    – Teepeemm
    Aug 22, 2021 at 1:27

2 Answers 2

1

It’s easy peasy with tblr environment of the new LaTeX3 package tabularray. You can even set hlines and vlines as default.


\documentclass{article}

\usepackage{tabularray}

\begin{document}

\begin{tblr}{
  colspec = {ccc},
  hlines, vlines,
}                      
  1 & 2 & 3 \\
  4 & 5 & 6 \\
  7 & 8 & 9 \\
\end{tblr}

\SetTblrInner{hlines,vlines} % set default hlines and vlines

\bigskip

\begin{tblr}{ccc}      
  1 & 2 & 3 \\
  4 & 5 & 6 \\
  7 & 8 & 9 \\
\end{tblr}

\bigskip

\begin{tblr}{lcr}      
  1 & 2 & 3 \\
  4 & 5 & 6 \\
  7 & 8 & 9 \\
\end{tblr}

\end{document}

enter image description here

0

With {NiceTabular} of nicematrix, you have the key hvlines which draws all the rules.

\documentclass{article}
\usepackage{nicematrix}

\begin{document}
\begin{NiceTabular}{ccc}[hvlines]
  1 & 2 & 3 \\ 
  4 & 5 & 6 \\ 
  7 & 8 & 9 \\
\end{NiceTabular}
\end{document}

Output of the above code

You must log in to answer this question.

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