# Table Formatting - Width

Okay so I am having some trouble with tables in Latex. I tried to find a solution within the already asked questions out there, but I haven't been able to either make sense or get these to work. Here is my table code:

    \begin{table}[ht]
\caption{Model Input Information: Materials}
\centering
\begin{tabular}{c c c}
\toprule
Available Materials & Material Input Parameters & Description \\
\midrule
Fused Silica (delta eV = 9) & alpha & Avalanche Coefficient [\si{\cm\squared\per\joule}] \\
Fused Silica (delta eV = 7.5) & delta eV & Material Band Gap [\si{\electronvolt}] \\
\ce{GaAs} & me & Effective Electron Mass [\si{\kilogram}] \\
\ce{ZnSe} & n0 & Linear Refractive Index \\
\ce{Ge} & n2 & Non-Linear Refractive Index \\
\ce{HfO_2} & T & Effective Decay Constant [fs] \\
\ce{TiO_2} & & \\
\ce{Ta_2O_5} & & \\
\ce{Al_2O_3} & & \\
\ce{SiO_2} & & \\
\bottomrule
\end{tabular}
\label{table:MaterialInputs}
\end{table}


The table looks good but it extends way too far right, almost to the edge of the page. I need a way to fix this. I've tried using p within the tabular command to set the widths manually, but I don't like what it does when wrapping the text. It creates hyphens on words instead of bringing them down a line.

Any suggestions would be greatly appreciated!

• you want raggedright setting rather than hyphenation so (with array package) >{\raggedright\arraybackslash}p{3cm} will give you a ragged right 3cm column. Please always post complete documents showing all packages needed (booktabs and whatever defined \ce in this case) Mar 19, 2014 at 22:01
• Which package defines the \ce macro? What's the intended width of the textblock? Please advise.
– Mico
Mar 19, 2014 at 22:16

This shows fixed width columns with ragged setting:

\documentclass{article}

\usepackage{array,mhchem,booktabs,siunitx}% please don't leave it to people to guess these

\begin{document}

\begin{table}[htp]% don't forget p
\caption{Model Input Information: Materials}
\centering
\begin{tabular}{
>{\raggedright\arraybackslash}p{4cm}
c
>{\raggedright\arraybackslash}p{2.5cm}}
\toprule
Available Materials & Material Input Parameters & Description \\
\midrule
Fused Silica (delta eV = 9) & alpha & Avalanche Coefficient [\si{\cm\squared\per\joule}] \\
Fused Silica (delta eV = 7.5) & delta eV & Material Band Gap [\si{\electronvolt}] \\
\ce{GaAs} & me & Effective Electron Mass [\si{\kilogram}] \\
\ce{ZnSe} & n0 & Linear Refractive Index \\
\ce{Ge} & n2 & Non-Linear Refractive Index \\
\ce{HfO_2} & T & Effective Decay Constant [fs] \\
\ce{TiO_2} & & \\
\ce{Ta_2O_5} & & \\
\ce{Al_2O_3} & & \\
\ce{SiO_2} & & \\
\bottomrule
\end{tabular}
\label{table:MaterialInputs}
\end{table}

\end{document}

• +1 for % please don't leave it to people to guess these ;)
– user11232
Mar 19, 2014 at 23:24
• Thank you very much!! And thank you for the tip, I am pretty new to this site and latex alike. Mar 19, 2014 at 23:57

You can use the makecell package: it lets you change line in a cell, defines a command for column heads and you can enlarge the vertical spacing of the rows, usually too tight. I also added the caption package, so the vertical spacing between the caption and the table.

        \documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{array, booktabs}
\usepackage{siunitx}
\usepackage{makecell}
\usepackage{caption}
\def\ce#1{\ensuremath{\mathrm{#1}}}

\begin{document}

\begin{table}[ht]
\caption{Model Input Information: Materials}
\centering
\begin{tabular}{ccc}
\toprule
\midrule
\makecell*{Fused Silica\\ (delta eV = 9)} & alpha & \makecell{Avalanche Coefficient\\{ [\si{\cm\squared\per\joule}]}} \\
\makecell*{Fused Silica\\ (delta eV = 7.5)} & delta eV & \makecell{Material Band Gap\\{[\si{\electronvolt}]}} \\
\makecell*{\ce{GaAs}} & me & Effective Electron Mass [\si{\kilogram}]\\
\makecell*{\ce{ZnSe}} & n0 & Linear Refractive Index \\
\makecell*{\ce{Ge}} & n2 & Non-Linear Refractive Index \\
\makecell*{\ce{HfO_2}} & T & Effective Decay Constant [fs] \\
\makecell*{\ce{TiO_2}} & & \\
\makecell*{\ce{Ta_2O_5}} & & \\
\makecell*{\ce{Al_2O_3}} & & \\
\makecell*{\ce{SiO_2}} & & \\
\bottomrule
\end{tabular}
\label{table:MaterialInputs}
\end{table}

\end{document}


N.B.: As I do'nt have the mhchem package installed I redefined the \ce command in order to make it look more like a real chemistry formula.