# Why does hanging indent with \everypar mess up table spacing?

I'm trying to add a hanging indent to every paragraph of a particular column of a table:

\documentclass{article}
\usepackage{array}
\newcolumntype{R}{>{\everypar{\hangindent1em\hangafter1}\arraybackslash}m{3in}}
\usepackage[a4paper, total={7in, 9in}]{geometry}
\begin{document}
\begin{tabular}{|p{1.5in}|p{1.5in}|R|}\hline
first column & second column & first line of third column \newline This line is indented. \par This one is not, but if it goes on and on and eventually wraps, the next line is indented. \\\hline
etc. & etc. & etc. \\\hline
\end{tabular}
\end{document}


The problem is that by using \everypar, the space between the top of the cell and the text is reduced, only in cells that have hanging indents: even the third cell in the second row looks fine. How can I avoid this?

When a p (or m) cell is started, \everypar is not void, but it contains

\vrule\@height\ht\@arstrutbox\@width\z@\everypar{}


which is the code that provides the insertion of a strut at the beginning of the paragraph. With your code you're removing this.

\documentclass{article}
\usepackage{array}
\newcommand{\dohang}{\hangindent1em\hangafter1 }
\newcolumntype{R}{%
>{\everypar\expandafter{\the\everypar\dohang\everypar{\dohang}}\arraybackslash}%
m{3in}%
}
\usepackage[a4paper, total={7in, 9in}]{geometry}
\begin{document}
\begin{tabular}{|p{1.5in}|p{1.5in}|R|}\hline
first column & second column &
first line of third column \newline
This line is indented. \par
This one is not, but if it goes on and on and eventually wraps,
the next line is indented. \\\hline
etc. & etc. & etc. \\\hline
\end{tabular}
\end{document}


A different solution that avoids messing with \hangindent, \hangafter and \everypar, using LaTeX lists. The output is the same.

\documentclass{article}
\usepackage{array}
\newcommand{\dohang}{\hangindent1em\hangafter1 }
\newcolumntype{R}{%
>{\tablist}%
m{3in}%
<{\endtablist}%
}

\newenvironment{tablist}
{\list{}{%
\leftmargin=1em
\itemindent=-1em
\listparindent=-1em
\topsep=0pt
\parsep=0pt
\partopsep=0pt}\item[\strut]}
{\endlist\vspace{-\baselineskip}}

\usepackage[a4paper, total={7in, 9in}]{geometry}
\begin{document}
\begin{tabular}{|p{1.5in}|p{1.5in}|R|}\hline
first column & second column &
first line of third column \newline
This line is indented. \par
This one is not, but if it goes on and on and eventually wraps,
the next line is indented. \\\hline
etc. & etc. & etc. \\\hline
\end{tabular}
\end{document}

• @fvogel I added a different solution, with a list. And welcome to TeX.SX! Jan 24, 2015 at 22:11
• Thanks. Why or in what cases is that preferable to the everypar method? Jan 25, 2015 at 2:59
• @fvogel As you discovered, LaTeX uses \everypar in several situations and playing with it is not easy. The \list method, on the other hand, uses standard LaTeX constructions. Jan 25, 2015 at 10:20
• It seems that this solution does not work with longtable. See here: tex.stackexchange.com/questions/336546/…
– phx
Oct 29, 2016 at 13:54