How to generate beautiful tables in LaTeX

Enter image description here

But I would like something like: Is there a way of getting this? The color and the lines specially. Btw, I use TexStudio and MikTex.

\documentclass[12pt] \usepackage[lmargin=2cm, rmargin=2cm, top=1.5cm, bottom=2cm] \usepackage[T1] \usepackage[utf8] \usepackage[british,UKenglish,USenglish,english,american]
1,034 1 1 gold badge 6 6 silver badges 8 8 bronze badges asked Jul 10, 2021 at 14:38 115 1 1 gold badge 1 1 silver badge 6 6 bronze badges

What exactly do you want to have? The spacing? The lines (see booktabs -package)? The colored background? The caption?

Commented Jul 10, 2021 at 14:44 Remove all | . See tex.stackexchange.com/questions/112343/beautiful-table-samples Commented Jul 10, 2021 at 14:44

Take a look at the booktabs documentation for general tips about table design, and particularly for the horizontal rules created with \toprule , \midrule and \bottomrule . Also take a look at siunitx 's S type column for numerical columns. Take a look at the array package to inject code for formatting of a column (e.g., to make the column print bold), last take a look at the collcell package to assign the effects of a macro to a complete column (e.g., for your molecular formulae).

Commented Jul 10, 2021 at 14:44

Using the center environment inside of table results in extra vertical white space. You may want to replace the center environment with the \centering command.

Commented Jul 10, 2021 at 15:01

please tell us which document class, which font, and which fontsize you employ. And, how wide are the margins?

Commented Jul 10, 2021 at 15:07

4 Answers 4

Here are some suggestions, not made in any particular order:

The framelines in the following screenshot indicate the edges of the text block. They get inserted because I set the showframe option when loading the geometry package.

enter image description here

\documentclass[12pt] \usepackage[hmargin=2cm, top=1.5cm, bottom=2cm, showframe] \usepackage[T1] \usepackage[utf8] \usepackage[british,UKenglish,USenglish,english,american] % why not '\usepackage[spanish]'? % New: \usepackage \sisetup \begin \noindent \textcolor<\Large\textbf> \begin[!h] \small \renewcommand \begin \begin <|p<0.5cm>| p | p | p | p | p |> \hline \textbf & \textbf & \textbf & \textbf & \textbf & \textbf \\ \hline 1 & 234523 & LoreIpsum & 234 & 0 & 0 \\ 2 & 2345 & LoreIpsum & 2365 & 0 & 0 \\ 3 & 3453 & LoreIpsum & 45634 & 0 & 0 \\ 4 & 83452 & LoreIpsum & 2456 & 0 & 0 \\ 5 & 210 & LoreIpsum & 245 & 0 & 0 \\ 6 & 3417 & LoreIpsum & 45634 & 0 & 0 \\ 7 & 4345 & LoreIpsum & 3456 & 0 & 0 \\ 8 & 4334 & LoreIpsum & 3456 & 0 & 0 \\ \hline \end \newline\newline \caption> \label \end \end %% after \noindent \textcolor<\Large\textbf> \begin[!h] \centering \begin \begin l S[table-format=6.0] l S[table-format=5.0] cc @<>> \toprule & & & & \multicolumn> \\ \cmidrule(l) & & & <(Kcal/mol)\textsuperscript> & & \\ \midrule 1 & 234523 & LoremIpsum & 234 & 0 & 0 \\ 2 & 2345 & LoremIpsum & 2365 & 0 & 0 \\ 3 & 3453 & LoremIpsum & 45634 & 0 & 0 \\ 4 & 83452 & LoremIpsum & 2456 & 0 & 0 \\ \addlinespace 5 & 210 & LoremIpsum & 245 & 0 & 0 \\ 6 & 3417 & LoremIpsum & 45634 & 0 & 0 \\ 7 & 4345 & LoremIpsum & 3456 & 0 & 0 \\ 8 & 4334 & LoremIpsum & 3456 & 0 & 0 \\ \bottomrule \end \caption> \label \end \end \end