[Tex/LaTex] Formatting table border and text alignment in LaTeX table

booktabsformattingrulestabularx

I have the following table in the .tex file:

\documentclass{article}
\usepackage{booktabs}
\begin{document}

\begin{table}[htbp]
  \centering
  \caption{Distribution of Number of Injured Non-Motorists by Injury Severity Level}
    \begin{tabular}{rcccccc}
    \toprule
    \textbf{Injury Severity } & \multicolumn{2}{c}{\textbf{Pedestrian}} & \multicolumn{2}{c}{\textbf{Bicyclist}} & \multicolumn{2}{c}{\textbf{All Non-Motorists}} \\
    \midrule
    Possible injury & 1700  & 67.70\% & 502   & 59.40\% & 2202  & 65.60\% \\
    Non-Incapacitating injury & 523   & 20.80\% & 259   & 30.70\% & 782   & 23.30\% \\
    Incapacitating injury & 250   & 10.00\% & 84    & 9.90\% & 334   & 9.90\% \\
    Fatal injury & 39    & 1.50\% & 0     & 0.00\% & 39    & 1.20\% \\
    \textbf{Total} & \textbf{2512} & \textbf{100.00\%} & \textbf{845} & \textbf{100.00\%} & \textbf{3357} & \textbf{100.00\%} \\
    \bottomrule
    \end{tabular}%
  \label{tab:dvar}%
\end{table}%

\end{document}

This gives me the following table:
Table using Latex code

However, I want it in this specific format for my thesis:

Required formatting

Please note that the outer borders are 2 lines while the inner borders are single line. Also, the numbers are to be aligned along the decimal point.

Can anyone please help me out here?

Best Answer

You can use the tabu package which offers you ready to use features to control the attributes (thickness, color) of the rules; alignment at the decimal separator can be achieved using the dcolumn package:

\documentclass{article}
\usepackage{xcolor}
\usepackage{dcolumn}
\usepackage{tabu}

\newcolumntype{A}{D{.}{.}{2.3}}

\begin{document}

\begin{table}[htbp]
  \centering
  \caption{Distribution of Number of Injured Non-Motorists by Injury Severity Level}
    \extrarowsep=_3pt^3pt
     \begin{tabu}to\linewidth{|[2pt gray]r|c|A|c|A|c|A|[1.5pt gray]}
    \tabucline[1.5pt gray]-
    \bfseries Injury Severity  & \multicolumn{2}{c|}{\textbf{Pedestrian}} & \multicolumn{2}{c|}{\textbf{Bicyclist}} & \multicolumn{2}{c|[1.5pt gray]}{\textbf{All Non-Motorists}} \\
    \tabucline[1.5pt gray]-
    Possible injury & 1700  & 67.70\% & 502   & 59.40\% & 2202  & 65.60\% \\
    Non-Incapacitating injury & 523   & 20.80\% & 259   & 30.70\% & 782   & 23.30\% \\\hline
    Incapacitating injury & 250   & 10.00\% & 84    & 9.90\% & 334   & 9.90\% \\\hline
    Fatal injury & 39    & 1.50\% & 0     & 0.00\% & 39    & 1.20\% \\
    \tabucline[1.5pt gray]-
    \bfseries Total & \bfseries 2512 & \multicolumn{1}{c|}{\bfseries 100.00\%} & \bfseries 845 & \multicolumn{1}{c|}{\bfseries 100.00\%} & \bfseries 3357 & \multicolumn{1}{c|[1.5pt gray]}{\bfseries 100.00\%} \\
    \tabucline[1.5pt gray]-
    \end{tabu}%
 \label{tab:dvar}%
\end{table}%

\end{document}

enter image description here

Just for comparison purposes, the same table without the vertical rules and some of the horizontal ones:

\documentclass{article}
\usepackage{xcolor}
\usepackage{dcolumn}
\usepackage{tabu}

\newcolumntype{A}{D{.}{.}{2.3}}

\begin{document}

\begin{table}[htbp]
  \centering
  \caption{Distribution of Number of Injured Non-Motorists by Injury Severity Level}
    \extrarowsep=_3pt^3pt
     \begin{tabu}to\linewidth{rcAcAcA}
    \tabucline[1.5pt gray]-
    \bfseries Injury Severity  & \multicolumn{2}{c}{\textbf{Pedestrian}} & \multicolumn{2}{c}{\textbf{Bicyclist}} & \multicolumn{2}{c}{\textbf{All Non-Motorists}} \\
    \tabucline[1.5pt gray]-
    Possible injury & 1700  & 67.70\% & 502   & 59.40\% & 2202  & 65.60\% \\
    Non-Incapacitating injury & 523   & 20.80\% & 259   & 30.70\% & 782   & 23.30\% \\
    Incapacitating injury & 250   & 10.00\% & 84    & 9.90\% & 334   & 9.90\% \\
    Fatal injury & 39    & 1.50\% & 0     & 0.00\% & 39    & 1.20\% \\
    \tabucline[1.5pt gray]-
    \bfseries Total & \bfseries 2512 & \multicolumn{1}{c}{\bfseries 100.00\%} & \bfseries 845 & \multicolumn{1}{c}{\bfseries 100.00\%} & \bfseries 3357 & \multicolumn{1}{c}{\bfseries 100.00\%} \\
    \tabucline[1.5pt gray]-
    \end{tabu}%
 \label{tab:dvar}%
\end{table}%

\end{document}

enter image description here

In my opinion, this second version looks much better, but I understand the original requirement for the thesis.

Related Question