4
\documentclass{beamer}
\begin{document}

\begin{frame}
\begin{table}
\begin{tabular}{c{15mm} | c | c | c | c}
Television & Radio & Washer & Dryer & Computer \\
\end{tabular}
\end{table}
\end{frame}

\end{document}

I'm making a Beamer presentation, and I want to limit the width of some column so that the entry appears as two lines instead of making the column too wide. But when I specify the width as 15mm, I got

LaTeX Error: Illegal character in array arg.

How can I fix it?

2
  • 3
    Just use 'p{15mm}' instead of 'c{15mm}'.
    – Mensch
    Commented Aug 18, 2014 at 12:30
  • 1
    Or, if you want to maintain the centered alignment of the column, load the array package and use m{15mm}. Commented Aug 18, 2014 at 12:54

2 Answers 2

2

Note that the word "Computer" takes up almost as much space as does the word "Television". Rather than fiddle with one column width at a time in an effort to make the table look OK, I'd use the tabularx environment to assure that all five columns have the same width.

\documentclass{beamer}
\usepackage{tabularx}  % for 'tabularx' environment
\useapackage{ragged2e} % for \Centering macro
\newcolumntype{C}{>{\Centering\arraybackslash}X}
\begin{document}
\begin{frame}
\begin{tabularx}{\textwidth}{| C | C | C | C | C |}
Television & Radio & Washer & Dryer & Computer \\
\end{tabularx}
\end{frame}
\end{document}
3

This question is not specific to beamer, so I'll put a general answer first and then a working example using beamer.

To wrap text in a table column, here are two simple options:

  1. Use tabular and specify one of the columns as a paragraph with p{<width>}. You must specify the width of that column, while the other columns will fit the width of the contents. The wrapped p column will always be left aligned.

    \begin{tabular}{p{15mm} c c}
    
  2. Use one of the other table-making packages. The other answer demonstrates tabularx, which expands the columns to fill a specified width for the whole table.

    With tabulary, you specify the width of the whole table, and then you can either choose traditional tabular-style columns with lowercase alignment commands c, l, and r; or you can use uppercase commands to get a wrapping column. This way you can easily create a wrapping column with any alignment.

    \begin{tabulary}{\textwidth}{C c c}
    

Example for beamer:

The first frame uses tabular and the second, tabulary.

\documentclass{beamer}
\usepackage{tabulary}
\begin{document}

%*******************
\begin{frame}
\begin{table}

\begin{tabular}{p{15mm} | c | c | c | c }
Text that should wrap to multiple lines & Data & Data & Data & Data\\
\end{tabular}

\end{table}
\end{frame}
%*******************
\begin{frame}
\begin{table}

\begin{tabulary}{\textwidth}{C | c | c | c | c }
Text that should wrap to multiple lines & Data & Data & Data & Data\\
\end{tabulary}

\end{table}
\end{frame}
%*******************
\end{document}

You must log in to answer this question.

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