[Tex/LaTex] Format of text within Tabular environment

formatting

I want to make the words "words words words" be directly below n^k. What I have tried so far has not worked. That is, \newline, \\, and \underset{} cannot accomplish what I desire.

Example Code

\begin{center}
  \begin{tabular}{ | l | l | p{5cm} |}
    \hline
     & Order Matters & Order Doesn't Matter  \\ \hline
    Repetition Allowed & $\displaystyle{n^k} $\par{ words words words}& $\displaystyle {n+k-1 \choose k-1}$ \\ \hline
    No Repetition Allowed& $\frac{n!}{(n-k)!}$ & ${n \choose k}$  \\ \hline
  \end{tabular}
\end{center}

Best Answer

You can only use \par inside a fixed-width p-column. Here is a toned-down implementation of your tabular:

enter image description here

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

\begin{center}
  \begin{tabular}{ l c c }
    \toprule
     & Order Matters & Order Doesn't Matter \\
    \cmidrule{2-3}
    Repetition Allowed & $\underset{\text{words words words}}{n^k}$ & $\binom{n+k-1}{k-1}$ \\[.5\normalbaselineskip]
    No Repetition Allowed & $\frac{n!}{(n-k)!}$ & $\binom{n}{k}$ \\
    \bottomrule
  \end{tabular}
\end{center}

\end{document}

It uses \binom from amsmath instead of the plain-TeX \choose. A \displaystyle version is available as \dbinom.


Another option that allows for paragraph breaks as needed (with the aid of varwidth. A fixed-width column is created using L{<width>} which will produce a Left-aligned column no wider than <width>:

enter image description here

\documentclass{article}
\usepackage{amsmath,booktabs,varwidth,collcell}

\newcommand{\fixedwidthcolumn}[1]{%
  \begin{varwidth}[t]{\fcolwidth}%
    \raggedright
    \strut#1\strut
  \end{varwidth}}

\newcolumntype{L}[1]{>{\gdef\fcolwidth{#1}\collectcell\fixedwidthcolumn}l<{\endcollectcell}}
\begin{document}

\begin{center}
  \begin{tabular}{ l c c }
    \toprule
     & Order Matters & Order Doesn't Matter \\
    \cmidrule{2-3}
    Repetition Allowed & $\underset{\text{words words words}}{n^k}$ & $\binom{n+k-1}{k-1}$ \\[.5\normalbaselineskip]
    No Repetition Allowed & $\frac{n!}{(n-k)!}$ & $\binom{n}{k}$ \\
    \bottomrule
  \end{tabular}

  \bigskip

  \begin{tabular}{ L{130pt} c c }
    \toprule
     & Order Matters & Order Doesn't Matter \\
    \cmidrule{2-3}
    Repetition Allowed & $\underset{\text{words words words}}{n^k}$ & $\binom{n+k-1}{k-1}$ \\[.5\normalbaselineskip]
    No Repetition Allowed & $\frac{n!}{(n-k)!}$ & $\binom{n}{k}$ \\
    \bottomrule
  \end{tabular}

  \bigskip

  \begin{tabular}{ L{130pt} c c }
    \toprule
     & Order Matters & Order Doesn't Matter \\
    \cmidrule{2-3}
    Some text that is long and will most like span multiple lines (but be not wider than \texttt{130pt}) & 
      $\underset{\text{words words words}}{n^k}$ & $\binom{n+k-1}{k-1}$ \\
    No Repetition Allowed & $\frac{n!}{(n-k)!}$ & $\binom{n}{k}$ \\
    \bottomrule
  \end{tabular}
\end{center}

\end{document}
Related Question