0

I'd like to have a table aligned by decimal point. I'm using tabu instead of table for exploit rowfont because I need row with smaller character. I've read different posts on dcolumn and siunitx packages but I didn't solve my problem. Here is part of my table:

\documentclass{article}
\usepackage[latin1]{inputenc}  
\usepackage[british]{babel}
\usepackage[T1]{fontenc}
\usepackage{indentfirst}
\usepackage{fancyhdr}
\usepackage{natbib} 
\usepackage{graphicx}
\usepackage{amsmath} 
\usepackage{breqn}
\usepackage{amssymb}
\usepackage{latexsym}
\usepackage[labelfont=bf]{caption}
\usepackage{tabu}
\usepackage{rotating}
\usepackage{collcell}
\usepackage{datatool}
\usepackage{multirow}
\usepackage{array,colortbl,xcolor}

\begin{document} 

\begin{sidewaystable}[]
\begin{center}
\resizebox*{\textheight}{0.70\textwidth}{%
\setlength\extrarowheight{5mm}
\Huge
\begin{tabu}{|c|l|ccccc|ccccccccc|cccc|cc|}
\cline{3-20}
    \multicolumn{2}{c}{}                                  & \multicolumn{5}{|c|}{P1}                    & \multicolumn{9}{c|}{P2}                                                                                             & \multicolumn{4}{c|}{P4}       & \multicolumn{2}{c}{}     \\ \hline
    X1                                      & \multicolumn{1}{|c|}{X2}   & $\omega^*$ & $\alpha_1$ & $\alpha_0$   & $\beta_1$ & $\beta_2$ & $m$          & $\alpha_{1,d}$ & $\beta_{1,d}$ & $\beta_{1,w}$ & $\beta_{1,m}$ & $\theta_d$ & $\theta_h$ & $\omega_d$ & $\omega_h$ & $a$      & $b$      & $c$      & $\pi$    & $\mathcal{L}(\boldsymbol{y})$        & $BIC$   \\ \hline
    \multirow{10}{*}{T1}       & M1                        & 0.042      & \textbf{0.304}      & -0.005       & 0.345     & 0.309     & -           & -              & -             & -             & -             & -          & -          & -          & -          & 3.189   & 0.738   & 1.185  & 0.999  & -20939.5 & 41963.7 \vspace*{-6mm} \\ \rowfont{\huge}
                                &                            &            & 0.007      & {[}0.043{]}  & 0.016     & 0.016     &             &                &               &               &               &            &            &            &            & 0.172   & 0.052   & 0.099  & 0.000  &          &         \\ \hline
    \end{tabu}%
    }
    \end{center}
    {\footnotesize Table description.}
    \end{sidewaystable}

\end{document}

Are there any solution? Thanks!!!!

Tonechas
  • 976
  • 1
    Welcome to TeX.SX! Could you please turn your code fragment into a compilable minimal working example (MWE) by adding the documentclass and the relevnt packages that are needed to reproduce your issue? – leandriis Mar 18 '19 at 19:49
  • These are the main packages that I'm using:

    \usepackage{graphicx} \usepackage{amsmath} \usepackage{breqn} \usepackage{amssymb} \usepackage{latexsym} \usepackage[labelfont=bf]{caption} \usepackage{tabu} \usepackage{rotating} \usepackage{datatool} \usepackage{multirow} \usepackage{array,colortbl,xcolor}

    Thanks for your help!

    – antonio Mar 18 '19 at 21:33
  • What about the documentclass and why do you use \Huge font size? With such a large font size a table with 22 columns will not fit onto a standard page. Using \resizebox to scale a table doeas lead to inconsistend sizes and as you can pbserve in your example, an extremely distorted (and unreadable) text. By the way, you can add information to your question by unsing the edit button. – leandriis Mar 18 '19 at 21:39
  • @antonio Where are \begin{document} and \end{document} into tex code? – Sebastiano Mar 18 '19 at 21:51
  • The problem is that I have too many columns and rows. With \resizebox I fit the table in one page and \Huge makes the character more "readable". Anyway I will split the table in 2 pages as soon as the decimal point alignment is achieved. Sorry, but I'm a beginner in latex. – antonio Mar 18 '19 at 21:57
  • I would strongly advise against the usage of \resizebox especially in combination with the \Huge font size as I don't see any improved readability: https://i.stack.imgur.com/JbwqK.png Instead you might be interested in redesigning your table (e.g. by splitting or transposing). – leandriis Mar 18 '19 at 22:04
  • Regarding the alignment of numbers in tables with respect to their decimal markers using the siunitx package (especially if one number is bold) see: https://tex.stackexchange.com/a/66256/134144 – leandriis Mar 18 '19 at 22:07
  • Thanks for your advice. You see the table so deformed because it lacks of many rows. In this short table one cannot use \resizebox and \Huge. – antonio Mar 18 '19 at 22:11
  • @leandriis I saw tex.stackexchange.com/a/66256/134144 but I didn't solve my problem. – antonio Mar 18 '19 at 22:18
  • @antonio: Here is a short excerpt of your table and an example on how you could use the siunitx package to horizontally center the numbers: \documentclass{article} \usepackage{siunitx} \usepackage{etoolbox} \robustify\bfseries \sisetup{detect-weight=true,detect-inline-weight=math} \begin{document} \begin{tabular}{|c|l| S[table-format=1.3] S[table-format=1.3] S[table-format=-1.3] } X1 & \multicolumn{1}{c|}{X2}& {$\omega^*$} & {$\alpha_1$} & {$\alpha_0$} \\ \hline T1 & M1 & 0.042 & \bfseries 0.304 & -0.005 \\ & & & 0.007 & [0.043] \\ \hline \end{tabular} \end{document} – leandriis Mar 18 '19 at 22:36
  • Thanks for this short-table example. The problem with my complex table persist, but I will start from your code to solve it. I think that the best way is to simplify the table structure also to have a better pdf view. – antonio Mar 22 '19 at 09:38

0 Answers0