1

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
    this is essentially a duplicate of https://tex.stackexchange.com/questions/332902/my-table-doesnt-fit-what-are-my-options – David Carlisle Apr 04 '21 at 14:07
  • Hello Sir, I am new to Latex and that link is very informative but is it possible to provide some specific guidance? – Jimjamlorde Apr 04 '21 at 14:13
  • Did you already try to implement one of these suggestions? If so, which of them and why are you not satisfied with what you tried so far. In addition to the techniques mentioned in the answers to the related question, you might want to consider shortening your lengthy column headers in order to avoid repetition. – leandriis Apr 04 '21 at 14:47

2 Answers2

1

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}

leandriis
  • 62,593
0

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}{>{\centering\arraybackslash}m{0.16\textwidth}} \renewcommand{\arraystretch}{1.5} % expand the cell vertically

\usepackage{showframe}% show the margins <<<<<<<< \renewcommand\ShowFrameColor{\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?

Simon Dispa
  • 39,141
  • Thank you Simon! I haven't really calculated the standard deviation of the results. Thanks for the heads up, I will do it. – Jimjamlorde Apr 04 '21 at 17:32