5

I have a LaTeX table in which I have some math code. I have two questions: how to display the math in display style instead of inline, and how to resolve these formatting issues as shown below?

\documentclass{article}
\usepackage{array,amsmath}
\begin{document}

\begin{tabular}{| >{$}c<{$} | >{$}c<{$} | >{$}c<{$} |}
\hline
& \text{Fair dice} & \text{Unfair dice} \\
\hline
\text{Win} & \frac{1}{6}*\frac{999}{1000} & \frac{1}{4}*\frac{1}{1000}\\
\text{Loss} & \frac{5}{6}*\frac{999}{1000} & \frac{3}{4}*\frac{1}{1000}\\
\hline
\end{tabular}

\end{document}

enter image description here

As shown, the numbers are sticking to each other and are in inline mode. How to make it to display style and also space them a little so that they don't touch each other?

3 Answers 3

5

Use \displaystyle to get display style mathematics, and use an optional argument to \\ to get extra space between rows. You can use a rule with zero width to put a space below a hline.

\documentclass{article}
\usepackage{array,amsmath}
\begin{document}

\begin{tabular}
{| >{$\displaystyle}c<{$} | >{$\displaystyle}c<{$} | >{$\displaystyle}c<{$} |}
\hline
& \text{Fair dice} & \text{Unfair dice} \\
\hline
\rule{0pt}{18pt}\text{Win} & \frac{1}{6}*\frac{999}{1000} & 
                               \frac{1}{4}*\frac{1}{1000}\\[10pt]
               \text{Loss} & \frac{5}{6}*\frac{999}{1000} & 
                               \frac{3}{4}*\frac{1}{1000}\\[10pt]
\hline
\end{tabular}

\end{document}

table

5
  • To get the second and third columns to be typeset in displaymath style automatically, simply change the column specification from >{$}c<{$} to >{$\displaystyle}c<{$}.

  • To get some breathing space between the cell contents and the horizontal rules, you could insert typographic struts.

  • The first column needn't be set up to be in math mode by default.

enter image description here

\documentclass{article}
\usepackage{array,amsmath}

%% Define a few struts
%% (code by Claudio Beccari, TeX and TUG News, Vol. 2, 1993)
\newcommand\Tstrut{\rule{0pt}{2.9ex}}       % "top" strut
\newcommand\Bstrut{\rule[-1.2ex]{0pt}{0pt}} % "bottom" strut
\newcommand\TBstrut{\Tstrut\Bstrut}         % "top and bottom" struts

\begin{document}
\begin{tabular}{| c | >{$\displaystyle}c<{$} 
                    | >{$\displaystyle}c<{$} |}
\hline
& \text{Fair dice} & \text{Unfair dice\TBstrut} \\
\hline
 Win & \frac{1}{6}\cdot\frac{999\Tstrut}{1000} & \frac{1}{4}\cdot\frac{1}{1000}\\[2.5ex]
Loss & \frac{5}{6}\cdot\frac{999}{1000\Bstrut} & \frac{3}{4}\cdot\frac{1}{1000}\\
\hline
\end{tabular}
\end{document}
4

One way to obtain not only a \displaystyle font size but also the vertical spacing of the displaymath environment:

mwe

\documentclass{article}
\usepackage{array,amsmath,booktabs}
\begin{document}
\begin{tabular}{lm{1.2in}m{1.2in}}\toprule  
     & \hfil Fair dice                        &   \hfil Unfair dice                  \\\midrule
Win  & \[\frac{1}{6}\times\frac{999}{1000}\]  &  \[\frac{1}{4}\times\frac{1}{1000}\] \\
Loss & \[\frac{5}{6}\times\frac{999}{1000}\]  &  \[\frac{3}{4}\times\frac{1}{1000}\] \\\bottomrule
\end{tabular}
\end{document}

You must log in to answer this question.

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