# Indenting wrapped words in tabular environment

How do I indent wrapped words in a tabular environment?

I would like my table to look like this:

+-----------+-----------+
+-----------+-----------+
| cell 1    | cell 2    |
+-----------+-----------+
| cell 3    | Wrapped   |
|           |   words   |
|           |   with    |
|           |   indent. |
+-----------+-----------+
| cell 4    | cell 5    |
+-----------+-----------+
Thanks

-

You can use \hangindent. Here's an example:

\documentclass{article}
\usepackage{lipsum}
\pagestyle{empty}
\begin{document}

\begin{tabular}{lp{3in}}
hello & \hangindent=2em\lipsum[1]
\end{tabular}

\end{document}


The syntax is

\hangindent=<dim>


To get this to apply to entries in the second column, you can use the array package and then use the prefix notation >{\handindent=2em} before declaring the column type.

\documentclass{article}
\usepackage{array}
\usepackage{lipsum}
\usepackage[margin=0.5in]{geometry}
\pagestyle{empty}
\begin{document}

\begin{tabular}{l>{\hangindent=2em}p{4in}}
hello & \lipsum[1] \\
hello & \lipsum[2] \\
hello & \lipsum[3]
\end{tabular}

\end{document}


Other similar commands

Other useful commands along these lines are:

\hangafter=<num>


Here <num> can be a positive or negative number. <num> specifies how many lines are to be indented. A negative value indicates that the indentation is applied to the first <num> lines. A positive value indicates that the indentation is applied to the lines <num+1>, <num+2>,...

\parshape <num>
<indent> <length>
...
<indent> <length>


Here <num> indicates how many lines the \parshape applies to. <indent> indicates how much the nth line should be indented. <length> indicates how wide the line is to be. There should be as many <indent> <length> pars has <num>. Once the first <num> lines have been formatted, the remaining lines, if any, will retain the formatting of the last line.

Here's a solution to your problem using \parshape

\documentclass{article}
\usepackage{lipsum}
\pagestyle{empty}
\begin{document}

\begin{tabular}{lp{3in}}
hello & \parshape 2
0pt 3in
2em \dimexpr3in-2em\relax
\lipsum[1]
\end{tabular}

\end{document}


Finally, here's an example using \hangafter (not quite the effect you want, but nevertheless a possibility):

\documentclass{article}
\usepackage{lipsum}
\pagestyle{empty}
\begin{document}

\begin{tabular}{lp{3in}}
hello & \hangindent=2em
\hangafter=3
\lipsum[1]
\end{tabular}

\end{document}


-
The my problem was that I put "\hangindent=1em \hangafter=1" only in front of my table's first column entries, thinking it would apply to all the columns. – Geremia Sep 29 '13 at 3:55
Is there a way to make ""\hangindent=1em \hangafter=1" apply automatically to each cell, so I don't have to keep repeating "\hangindent=1em \hangafter=1" all over the place? thanks – Geremia Sep 29 '13 at 3:56
@Geremia I've updated my answer to show how to apply this format to all entries in a particular column. – A.Ellett Sep 29 '13 at 4:06
That's pretty neat. thanks – Geremia Sep 29 '13 at 6:14