1

I am having an alignment issue with the entries that I am entering in my table. I use inform3 class and the output looks like enter image description here

Here are two important things: i) when I use . in any of the entry, it messes up the entire table as shown here. ii) When I use math mode, it changes the numbers. For instance, if I use $67.1$, it shows me 80 for some reason.

\begin{sidewaystable}  
\vspace*{20\baselineskip}
\setcellgapes{0pt}  
\makegapedcells       
\setlength\tabcolsep{2pt}   
\sisetup{group-four-digits}  
  \centering
  \caption{My Table}
  \small                     
    \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}} l  
                                *{2}{S[table-format=5.0]}  
                                *{16}{S[table-format=6.0]} } 
     \toprule[\heavyrulewidth] 
       &        & \multicolumn{4}{l}{{[}1{]}}    & \multicolumn{4}{l}{{[}2{]}}           & \multicolumn{4}{l}{{[}3{]}}         & \multicolumn{4}{l}{{[}4{]}}     \\
    \cmidrule[\heavyrulewidth](lr){3-6}   \cmidrule[\heavyrulewidth](lr){7-10} \cmidrule[\heavyrulewidth](lr){11-14} \cmidrule[\heavyrulewidth]{15-18}   % <--- changed
$\mathbf{|V|}$ & $\mathbf{|m|}$ & \textbf{Status} & \textbf{\begin{tabular}[c]{@{}l@{}}Time\\ (sec)\end{tabular}} & \textbf{\begin{tabular}[c]{@{}l@{}}Gap\\ ($\%$)\end{tabular}} & \textbf{\begin{tabular}[c]{@{}l@{}}BB\\ Nodes\end{tabular}} & \textbf{Status} & \textbf{\begin{tabular}[c]{@{}l@{}}Time\\ (sec)\end{tabular}} & \textbf{\begin{tabular}[c]{@{}l@{}}Gap\\ ($\%$)\end{tabular}} & \textbf{\begin{tabular}[c]{@{}l@{}}BB\\ Nodes\end{tabular}} & \textbf{Status} & \textbf{\begin{tabular}[c]{@{}l@{}}Time\\ (sec)\end{tabular}} & \textbf{\begin{tabular}[c]{@{}l@{}}Gap\\ ($\%$)\end{tabular}} & \textbf{\begin{tabular}[c]{@{}l@{}}BB\\ Nodes\end{tabular}} & \textbf{Status} & \textbf{\begin{tabular}[c]{@{}l@{}}Time\\ (sec)\end{tabular}} & \textbf{\begin{tabular}[c]{@{}l@{}}Gap\\ ($\%$)\end{tabular}} & \textbf{\begin{tabular}[c]{@{}l@{}}BB\\ Nodes\end{tabular}} \\
    \midrule
500  & 10  & {status1}  & 67.1   & 0.00  & 9639     & {status1}     & 25.3  & 0.00  & 2301  & {status2} & 66.9   & 0.00 & 1335     & {status2}     & 201.3  & 0.00 & 1479  \\
    \bottomrule     
    \end{tabular*}  
  \label{table1}
\end{sidewaystable}
3
  • What exactly is the alignment issue?
    – leandriis
    Commented Dec 26, 2019 at 22:52
  • The entry in the Gap column is not centered. Also, I believe, it is probably related to using . in the entry. Here how my table looks when I enter three rows imgur.com/LG19Soe
    – ball_jan
    Commented Dec 26, 2019 at 22:55
  • The issue is due to the table-format option you used. Make sure that it fits the contents of the respective columns.
    – leandriis
    Commented Dec 26, 2019 at 23:23

1 Answer 1

2
  • Please always provide MWE (Minimal Working Example, a small complete document, which we can compile as it is and which reproduce your problem).
  • From one row of table we can't know, if numbers in the other rows are bigger as they are in showed row.
  • Please show image of table in question, link can become dead after while.
  • From provided code can be concluded, that table consist (after first two columns) four groups of data, from which in the first column are text, other three have numbers with different number of integer and decimal digits. This should be reflected in table's columns specification (see MWE below).
  • For column header you can use makecell macro from the package with the same name. Using it the code will become much shorter and clearer.
\documentclass{article}% i still haven't inform3 document class
\usepackage{rotating}
\usepackage{booktabs, makecell}
\usepackage{siunitx}

\usepackage{mathtools}                      % new
\DeclarePairedDelimiter\abs{\lvert}{\rvert} % new
\usepackage{bm}                             % new


\begin{document}
    \begin{sidewaystable}
%\vspace*{20\baselineskip}
\setlength\tabcolsep{0pt}
\sisetup{group-four-digits}
\renewcommand{\cellset}{\bfseries\linespread{0.84}\selectfont}
\renewcommand\cellalign{bc}
  \centering
  \caption{My Table}
  \small
    \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}} 
                        *{2}{S[table-format=3.0]}
                        *{4}{l S[table-format=2.1] S[table-format=1.2] S[table-format=4.0]}
                                }
     \toprule
    &   & \multicolumn{4}{c}{[1]}   & \multicolumn{4}{c}{[2]}           
        & \multicolumn{4}{c}{[3]}   & \multicolumn{4}{c}{[4]}   \\
    \cmidrule(l){3-6}\cmidrule(l){7-10}\cmidrule(l){11-14}\cmidrule(l){15-18}
{$\bf\abs{V}$} 
    & {$\bf\abs{m}$}            & \makecell{Status}         & {\makecell{Time\\ (sec)}} 
    & {\makecell{Gap\\ ($\%$)}} & {\makecell{BB\\ Nodes}}   & {\makecell{Status}} 
    & {\makecell{Time\\ (sec)}} & {\makecell{Gap\\ ($\%$)}} & {\makecell{BB\\ Nodes}} 
    & {\makecell{Status}}       & {\makecell{Time\\ (sec)}} & {\makecell{Gap\\ ($\%$)}} 
    & {\makecell{BB\\ Nodes}}   & {\makecell{Status}}       & {\makecell{Time\\ (sec)}} 
    & {\makecell{Gap\\ ($\%$)}} & {\makecell{BB\\ Nodes}}       \\
    \midrule
500 & 10  
    & status1   & 67.1  & 0.00  & 9639     
    & status1   & 25.3  & 0.00  & 2301  
    & status2   & 66.9  & 0.00  & 1335     
    & status2   & 201.3 & 0.00  & 1479  \\
    \bottomrule
    \end{tabular*}
  \label{table1}
\end{sidewaystable}
\end{document}

enter image description here

2
  • If I use l, it left aligns all the entries. How can I make it right aligned?
    – ball_jan
    Commented Dec 27, 2019 at 16:52
  • 1
    @ball_jan, use r. I like to encourage you to read some introductory text about writing tables. For example en.wikibooks.org/wiki/LaTeX/Tables
    – Zarko
    Commented Dec 27, 2019 at 18:40

You must log in to answer this question.

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