TransWikia.com

Table text overlaps while using p

TeX - LaTeX Asked on June 4, 2021

I am trying to write a table with 11 columns with some numerical data. But texts of some cells overlap the next cell. I am using p{dimexpr.09textwidth-2tabcolseprelax} to control the width of each column and small font size. Thanks in Advance. The MWE is

documentclass[3p, final]{elsarticle}

usepackage{caption}
captionsetup[table]{skip=0pt,singlelinecheck=off}
usepackage{booktabs}

journal{Applied Soft Computing}

begin{document}

    begin{table}[!htb]
        label{tab3}
        caption{table 3}
        small
        begin{tabular}{@{}p{dimexpr.09textwidth-2tabcolseprelax}p{dimexpr.09textwidth-2tabcolseprelax}p{dimexpr.09textwidth-2tabcolseprelax}p{dimexpr.09textwidth-2tabcolseprelax}p{dimexpr.09textwidth-2tabcolseprelax}p{dimexpr.09textwidth-2tabcolseprelax}p{dimexpr.09textwidth-2tabcolseprelax}p{dimexpr.09textwidth-2tabcolseprelax}p{dimexpr.09textwidth-2tabcolseprelax}p{dimexpr.09textwidth-2tabcolseprelax}p{dimexpr.09textwidth-2tabcolseprelax}@{}}
            toprule
            Server             & textbf{Dionaea} & textbf{Cowrie} & textbf{Heralding} & textbf{Honeytrap} & textbf{Rdpy} & textbf{Adbhoney} & textbf{Mailoney} & textbf{Tanner} & textbf{Conpot} & textbf{Total Alert}  midrule
            textbf{Africa}    & 65464665         & 846132         & 86124            & 89645446            & 985131        & 95621455             & 956465              & 8465            & 65465            & 865135665645             
            textbf{Australia}       & 86465          & 865465          & 8665             & 656165             & 864565         & 989230              & 9846465              & 6548465           & 9846516            & 8746563               bottomrule
        end{tabular}
    end{table}

end{document}

One Answer

Your table is with normal font size wider than text width, so you need to reduce font size in it to footnotesize. Also I suggest to use S columns defined in the siunitx package for columns with numbers:

documentclass[3p, final]{elsarticle}
%--------------- show page layout. don't use in a real document!
usepackage{showframe}
renewcommandShowFrameLinethickness{0.15pt}
renewcommand*ShowFrameColor{color{red}}
%---------------------------------------------------------------%

usepackage{caption}
captionsetup[table]{skip=0pt,singlelinecheck=off}
usepackage{booktabs}
newcommandmc[1]{multicolumn{1}{c}{#1}}
usepackage{siunitx}

journal{Applied Soft Computing}

begin{document}

    begin{table}[!htb]
caption{table 3}
label{tab3}
    footnotesize
    setlengthtabcolsep{0pt}
    sisetup{tight-spacing,
             group-four-digits}
begin{tabular*}{linewidth}{@{extracolsep{fill}} l 
        S[table-format=8.0]
        S[table-format=6.0]
        S[table-format=5.0]
        S[table-format=8.0]
        S[table-format=6.0]
        S[table-format=8.0]
        S[table-format=7.0]
        S[table-format=7.0]
        S[table-format=7.0]
        S[table-format=12.0]
                             }
    toprule
Server  & mc{Dionaea}  & mc{Cowrie}   & mc{Heralding}    & mc{Honeytrap}
        & mc{Rdpy}     & mc{Adbhoney} & mc{Mailoney}     & mc{Tanner}
        & mc{Conpot}   & mc{Total Alert}   
    midrule
Africa
        & 65464665      & 846132        & 86124             & 89645446
        & 985131        & 95621455      & 956465            & 8465
        & 65465         & 865135665645             
Australia
        & 86465         & 865465        & 8665              & 656165
        & 864565        & 989230        & 9846465           & 6548465
        & 9846516       & 8746563               bottomrule
end{tabular*}
    end{table}
end{document}

enter image description here

(red lines shows text borders)

Correct answer by Zarko on June 4, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP