# A specific format for nice tables

With this code:

\documentclass[a4paper,12pt]{article}
\usepackage{mathtools,amssymb}
\usepackage{booktabs, isotope}
\begin{document}
\begin{center}
\begin{tabular}{lcc}
\toprule
\textbf{Osservabile} & \textbf{Simbolo} & \textbf{Operatore associato} \\
\toprule
Posizione & $\bar{r}$ & $\bar{r}$ \\
Momento & $\bar{p}$ & $-i\hslash \overline \nabla$ \\
Energia potenziale & $\mathcal{U}$ &  $\mathcal{U}(r)$ \\
Energia cinetica & $\mathcal{K}$ &  $-\dfrac{\hslash^2}{2m}\nabla^2$ \\
Hamiltoniana & $H$ & $-\dfrac{\hslash^2}{2m}\nabla^2+\mathcal{U}(r)$\\
Energia totale & $E$ & $-i\hslash\dfrac{\partial}{\partial t}$\\
\bottomrule
\end{tabular}
\end{center}
\vskip 1cm
\begin{center}
\begin{tabular}{cccc}
\toprule
\textbf{Numeri di massa} & \textbf{Elemento chimico} & \textbf{Prodotto iniziale} & \textbf{Prodotto finale}\\
\midrule
$4n$ &  Torio   &   \isotope[232][90]{Th} &   \isotope[208][82]{Pb} \\
$4n+1$ &  Neptunio   &  \isotope[237][93]{Np}  &  \isotope[209][83]{Bi}  \\
$4n+2$ &  Uranio   &  \isotope[238][92]{U}  & \isotope[206][82]{Pb}  \\
$4n+3$ &  Attinio   &  \isotope[235][92]{U}  &  \isotope[207][82]{Pb} \\
\bottomrule
\end{tabular}
\end{center}
\end{document}


I'm finding to create two tables that they have the same structure of the below picture:

1. I would like to create as the upper image, the label (same color) of the table in upper case with a different character (I use into my book URW Classic as Sans Serif character (\fontfamily) and by default as normal text character is newtxtext, the clone of Times).

See this example for the figure below:

2. A thicker line with the same color as the image if possible;

3. The comment of the table must be with the character newtxtext;

4. A slightly larger space between rows in my second table. Precisely between one chemical element and the other below.

Thank you very much.

## 2 Answers

see, if the following solution is close to what you after:

\documentclass[a4paper,12pt]{article} % <---
\usepackage{mathtools,amssymb}                % <---
\usepackage{booktabs,
makecell}                         % <---
\setcellgapes{3pt}                            % <---
\usepackage{isotope}
\usepackage[table]{xcolor}                    % <---
\arrayrulecolor{teal}                         % <---

\usepackage[skip=1ex]{caption}                % <---
\DeclareCaptionFont{teal}{\color{teal}}   % <---
\captionsetup[table]{font=bf,             % <---
labelfont={teal,bf},
singlelinecheck=off}

\begin{document}
\begin{table}[htb]              % <---
\makegapedcells                 % <---
\caption{My fancy table}        % <---
\begin{tabular}{l*{2}{>{$}c<{$}}}   % <---
\toprule[2pt]                   % toprule thickens you can change according
% to your taste, for example to 3pt or more
\textbf{Osservabile} & \textbf{Simbolo} & \textbf{Operatore associato}  \\
\midrule
Posizione           & \bar{r}       & \bar{r}                           \\
Momento             & \bar{p}       & -i\hslash \overline \nabla        \\
Energia potenziale  & \mathcal{U}   & \mathcal{U}(r)                    \\
Energia cinetica    & \mathcal{K}   & -\dfrac{\hslash^2}{2m}\nabla^2    \\
Hamiltoniana        & H             & -\dfrac{\hslash^2}{2m}\nabla^2+\mathcal{U}(r) \\
Energia totale      & E             & -i\hslash\dfrac{\partial}{\partial t}         \\
\bottomrule
\end{tabular}
\end{table}

\begin{table}[htb]
\caption{My another fancy table}
\makegapedcells
\begin{tabular}{cccc}
\toprule[2pt]      % <---
\thead{Numeri\\ di massa}
& \thead{Elemento\\ chimico}
& \thead{Prodotto\\ iniziale}
& \thead{Prodotto\\ finale}\\   % <---
\midrule
$4n$    &  Torio        &   \isotope[232][90]{Th}   &   \isotope[208][82]{Pb}   \\
$4n+1$  &  Neptunio     &   \isotope[237][93]{Np}   &   \isotope[209][83]{Bi}   \\
$4n+2$  &  Uranio       &   \isotope[238][92]{U}    &   \isotope[206][82]{Pb}   \\
$4n+3$  &  Attinio      &   \isotope[235][92]{U}    &   \isotope[207][82]{Pb}   \\
\bottomrule
\end{tabular}
\end{table}

\end{document}


so far i consider only tables in your mwe (it not contain your table 13.1, if you will provide code for this table content, i will show solution example for it too)

edit: differences between above and your mwe are indicated by % <---. as you can see, above are added packages xcolor for coloring table rules as well font for tables' labels, makecell for adding more vertical spaces around cells contents and for macro \thead, which enable to write column heads in two (or more, if necessary) lines, caption for defining caption style (font family and color, positioning of caption).

in above mwe tables are not horizontally centered. if you like to have them centered, just add \centering after \begin{table}[...]. but in this case the caption will be aligned with left text border. for aligning it width beginning of table, you should use threeparttable as shown in mwe below. in it is also added a way how to select font used in caption and have upper case font in caption label (indicaed by % <===). so far i select iwona, but you can replace it with font of your wish. also the thikness of rules are defined globally.

\documentclass[a4paper,12pt,italian]{article}
\usepackage{babel}
\usepackage{mathtools,amssymb}
\usepackage{booktabs, makecell,
threeparttable}       % <---
\setlength\heavyrulewidth{2pt}    % <---
\setlength\lightrulewidth{1.2pt}  % <---

\setcellgapes{3pt}
\renewcommand\theadfont{\normalsize\bfseries}
\renewcommand\theadgape{}

\usepackage{isotope}
\usepackage[table]{xcolor}
\arrayrulecolor{teal}
\usepackage[skip=0.5ex]{caption}
\DeclareCaptionLabelFormat{uc}{\MakeUppercase{#1}~#2}                % <===
\DeclareCaptionFont{teal}{\color{teal}\fontfamily{iwona}\selectfont} % <===
\captionsetup[table]{font={large,teal,bf},
labelformat=uc,                                 % <===
singlelinecheck=off}

%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\begin{document}
\begin{table}[htb]
\centering                  % <---
\begin{threeparttable}       % <---
\caption{My fancy table}
\makegapedcells
\begin{tabular}{l*{2}{>{$}c<{$}}}
\toprule
\textbf{Osservabile} & \textbf{Simbolo} & \textbf{Operatore associato}  \\
\midrule
Posizione           & \bar{r}       & \bar{r}                           \\
Momento             & \bar{p}       & -i\hslash \overline \nabla        \\
Energia potenziale  & \mathcal{U}   & \mathcal{U}(r)                    \\
Energia cinetica    & \mathcal{K}   & -\dfrac{\hslash^2}{2m}\nabla^2    \\
Hamiltoniana        & H             & -\dfrac{\hslash^2}{2m}\nabla^2+\mathcal{U}(r) \\
Energia totale      & E             & -i\hslash\dfrac{\partial}{\partial t}         \\
\bottomrule
\end{tabular}
\end{threeparttable}        % <---
\end{table}

\begin{table}[htb]
\centering                  % <---
\begin{threeparttable}       % <---
\caption{My another fancy table}
\makegapedcells
\begin{tabular}{cccc}
\toprule
\thead{Numeri\\ di massa}
& \thead{Elemento\\ chimico}
& \thead{Prodotto\\ iniziale}
& \thead{Prodotto\\ finale}\\
\midrule
$4n$    &  Torio        &   \isotope[232][90]{Th}   &   \isotope[208][82]{Pb}   \\
$4n+1$  &  Neptunio     &   \isotope[237][93]{Np}   &   \isotope[209][83]{Bi}   \\
$4n+2$  &  Uranio       &   \isotope[238][92]{U}    &   \isotope[206][82]{Pb}   \\
$4n+3$  &  Attinio      &   \isotope[235][92]{U}    &   \isotope[207][82]{Pb}   \\
\bottomrule
\end{tabular}
\end{threeparttable}        % <---
\end{table}
\end{document}


which gives:

(red lines indicate page borders)

• @Sebastiano, any news? – Zarko Feb 15 at 20:57
• Kind friend Zarko, I've connected now after a hell of a day since yesterday. :-(. I am not very good with tables and my knowledge is modest. I was reflecting on whether your code, copied into my very long code, does not conflict with the compilation. – Sebastiano Feb 15 at 21:32
• @Sebastiano, i was just curious if i understood your question correctly and if i addressed all your issues in it. i hope, that today you are better. – Zarko Feb 15 at 21:36
• My question is: You have put \fontfamily{iwona}. Is it possibile for to write with horizontal strech character TABELLA 1 or 2 with the font URW Classic instead of iwona? (see the last image of my question - number red 3). I must declare \fontfamily{urw}? Same font for the caption: My fance table? – Sebastiano Feb 15 at 21:40
• you can use your font. i just use font which is installed in my system. if you will have problems with this, ask new question (you now, one problem per question :-) ) – Zarko Feb 15 at 22:12
• \arrayrulecolor from the colortbl package for the rule color
• captionsetep and captionof commands from the caption package for the caption settings
• toprule[3pt] for a top rule 3pt thick
• \renewcommand{\arraystretch}{1.5} for increasing row size by a factor of 1.5
• To get the table centered and the caption starting at the table left limit: Put the table content inside a minipage environment of width equal to the table width then put the minipage inside a center environment

!

\documentclass[a4paper,12pt]{article}
\usepackage{mathtools,amssymb}
\usepackage{booktabs, isotope,colortbl,caption}

\arrayrulecolor{cyan}
\captionsetup[table]{labelfont={color=cyan,sc},justification=RaggedRight,singlelinecheck=false,skip=2pt}

\newlength{\mytablewidth}
\newsavebox{\mytablebox}

\renewcommand{\arraystretch}{1.5}

\begin{document}
\begin{center}
\savebox{\mytablebox}
{\begin{tabular}{lcc}
\toprule[3pt]
\textbf{Osservabile} & \textbf{Simbolo} & \textbf{Operatore associato} \\
\toprule
Posizione & $\bar{r}$ & $\bar{r}$ \\
Momento & $\bar{p}$ & $-i\hslash \overline \nabla$ \\
Energia potenziale & $\mathcal{U}$ &  $\mathcal{U}(r)$ \\
Energia cinetica & $\mathcal{K}$ &  $-\dfrac{\hslash^2}{2m}\nabla^2$ \\
Hamiltoniana & $H$ & $-\dfrac{\hslash^2}{2m}\nabla^2+\mathcal{U}(r)$\\
Energia totale & $E$ & $-i\hslash\dfrac{\partial}{\partial t}$\\
\bottomrule
\end{tabular}}
\settowidth{\mytablewidth}{\usebox{\mytablebox}}
\begin{minipage}{\mytablewidth}
\captionof{table}{my first table}
\usebox{\mytablebox}
\end{minipage}
\end{center}
\vskip 1cm
\begin{center}
\savebox{\mytablebox}{\begin{tabular}{cccc}
\toprule[3pt]
\textbf{Numeri di massa} & \textbf{Elemento chimico} & \textbf{Prodotto iniziale} & \textbf{Prodotto finale}\\
\midrule
$4n$ &  Torio   &   \isotope[232][90]{Th} &   \isotope[208][82]{Pb} \\
$4n+1$ &  Neptunio   &  \isotope[237][93]{Np}  &  \isotope[209][83]{Bi}  \\
$4n+2$ &  Uranio   &  \isotope[238][92]{U}  & \isotope[206][82]{Pb}  \\
$4n+3$ &  Attinio   &  \isotope[235][92]{U}  &  \isotope[207][82]{Pb} \\
\bottomrule
\end{tabular}}

\settowidth{\mytablewidth}{\usebox{\mytablebox}}
\begin{minipage}{\mytablewidth}
\captionof{table}{my second table}
\usebox{\mytablebox}
\end{minipage}

\end{center}
\end{document}


• Thank you very much for your work and I have appreciated it. – Sebastiano Feb 15 at 21:46
• You are welcome! @Sebastiano – Hafid Boukhoulda Feb 15 at 21:50
• You're always welcome to me. – Sebastiano Feb 15 at 21:52