TransWikia.com

Table is going out of bounds and taking too much space

TeX - LaTeX Asked by Ishaan Singh on August 4, 2021

Hi can someone please help me neaten this table up. It’s going out of the page and I think want it to be pretty.

documentclass[12pt]{article} % You can set font size here
usepackage
[
        a4paper,% other options: a3paper, a5paper, etc
        % left=2.54cm,
        % right=2.54cm,
        % top=2.54cm,
        % bottom=2.54cm,
        margin = 2.54cm
        % use vmargin=2cm to make vertical margins equal to 2cm.
        % us  hmargin=3cm to make horizontal margins equal to 3cm.
        % use margin=3cm to make all margins  equal to 3cm.
]
{geometry}

usepackage[utf8]{inputenc}

%% Useful packages
usepackage{amsmath,amsthm,amssymb,amsfonts}
usepackage{graphicx}
usepackage{subfigure}
%usepackage[colorinlistoftodos]{todonotes}
usepackage[colorlinks=true, allcolors=blue]{hyperref}
usepackage{float}
usepackage[title]{appendix}
usepackage{multirow}
usepackage{pgfgantt}
usepackage{setspace}


usepackage{tikz}
usetikzlibrary{shapes.geometric, arrows}

renewcommand{familydefault}{sfdefault}
usepackage[square,numbers]{natbib}
bibliographystyle{agsm} %harvard referencing style

usepackage[none]{hyphenat}
title{vspace{-2cm} Simulation Project Report}
author{textbf{Authors: Jing Ting Chong, Ishaan Singh Jolly}}

date{}
begin{document}
begin{table}[h]small
vspace{0.5cm}
caption{Parameter Estimation}
centering
{
begin{tabular}{|c| c |c |c| c|}
hline
Parameters & Inter arrival Times  & Service times for Initial Phase & Service Times for Placing Keyboard and Mouse & Service Times for Assembling the Case 
hline
Distribution & Exponential & Lognormal & Uniform & Uniform
hline
Parameter Estimation & $Lambda: 0.174883079$ & $Mean: 0.932845171$ & $Min(a): 13.4587$ & $Min(a): 4.91495$  
hline
Parameter Estimation & $Average: 5.718106099$ & $ Deviation: 0.375378955$ & $Min(b): 6.00524$ & $Min(b) 3.78655$  
hline
end{tabular}}
end{table}


end{document} 

2 Answers

A place to start from:

enter image description here

documentclass[12pt]{article}
usepackage[a4paper, margin = 2.54cm]{geometry}
usepackage{booktabs}
usepackage{caption}
renewcommand{familydefault}{sfdefault}
usepackage{showframe}
usepackage{makecell}
renewcommand{theadfont}{normalsize}
begin{document}
begin{table}
caption{Parameter Estimation}
centering
begin{tabular}{l c c c c}
toprule
& & multicolumn{3}{c}{Service times for}cmidrule{3-5}
Parameters & thead{Inter arrival Times}  & thead{Initial Phase} & thead{Placing Keyboard & Mouse} & thead{Assembling the Case} 
midrule
Distribution & Exponential & Lognormal & Uniform & Uniform addlinespace
Parameter  & Lambda:     & Mean:       & Min(a): & Min(a):  
Estimation & 0.174883079 & 0.932845171 & 13.4587 & 4.91495   addlinespace
Parameter  & Average:    & Deviation:  & Min(b): & Min(b): 
Estimation & 5.718106099 & 0.375378955 & 6.00524 & 3.78655  
bottomrule
end{tabular}
end{table}


end{document} 

Answered by leandriis on August 4, 2021

The minimal change to your code is by defining a new column type with the same width for all columns, able to fit the table on the page.

The package array provides such capability plus the ability to expand cells vertically for better readability.

Math is not needed, so is better to have the same font in all the cells.

In technical publications it is recommended to avoid vertical lines in tables, when possible. If you choose to do this, you will have to change the style of all the tables in your document.

z

This is the code

documentclass[12pt]{article} % You can set font size here
usepackage[
a4paper,% other options: a3paper, a5paper, etc
% left=2.54cm,
% right=2.54cm,
% top=2.54cm,
% bottom=2.54cm,
margin = 2.54cm
% use vmargin=2cm to make vertical margins equal to 2cm.
% us  hmargin=3cm to make horizontal margins equal to 3cm.
% use margin=3cm to make all margins  equal to 3cm.
]
{geometry}

usepackage[utf8]{inputenc}

%% Useful packages
usepackage{amsmath,amsthm,amssymb,amsfonts}
usepackage{graphicx}
usepackage{subfigure}
%usepackage[colorinlistoftodos]{todonotes}
usepackage[colorlinks=true, allcolors=blue]{hyperref}
usepackage{float}
usepackage[title]{appendix}
usepackage{multirow}
usepackage{pgfgantt}
usepackage{setspace}

usepackage{tikz}
usetikzlibrary{shapes.geometric, arrows}

renewcommand{familydefault}{sfdefault}
usepackage[square,numbers]{natbib}
bibliographystyle{agsm} %harvard referencing style

usepackage[none]{hyphenat}
title{vspace{-2cm} Simulation Project Report}
author{textbf{Authors: Jing Ting Chong, Ishaan Singh Jolly}}

%% ************************* 
usepackage{array} % for newcolumntype and arraystretch <<<<< added
newcolumntype{C}{>{centeringarraybackslash}m{0.16textwidth}}
renewcommand{arraystretch}{1.5} % expand the cell vertically

usepackage{showframe}% show the margins <<<<<<<<
renewcommandShowFrameColor{color{red}}
%% *************************

date{}
begin{document}
    begin{table}[h]
        small
        centering
        caption{Parameter Estimation}
            vspace{1em}    
            begin{tabular}{|C| C |C |C| C|}  % changed <<<<<<
                hline
                Parameters & Inter arrival Times  & Service times for Initial Phase & Service Times for Placing Keyboard and Mouse & Service Times for Assembling the Case 
                hline
                Distribution & Exponential & Lognormal & Uniform & Uniform
                hline
                Parameter Estimation & Lambda: 0.174883079 & Mean: 0.932845171 & Min(a): 13.4587 & Min(a): 4.91495  
                hline
                Parameter Estimation & Average: 5.718106099 & Deviation: 0.375378955 & Min(b): 6.00524 & Min(b): 3.78655  
                hline
        end{tabular}
        end{table} 
    
end{document} 

Personal comment, not related with the question:

Quoting estimation results with so many significant digits is an overkill.

What is the standard deviation of the calculations?

Answered by Simon Dispa on August 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