1

I'm using \usepackage{makecell} to break up some long text inside my tables. I would like to have a hanging indent for that cell. I see some documentation about customizing such aspects, but modifying it to fit this need is beyond me. Thanks for any help.

\begin{table}[]
\centering
\caption{My caption}
\label{my-label}
\begin{tabular}{lc}
\multicolumn{1}{c}{\textbf{Header}}                                        & \multicolumn{1}{r}{\textbf{Header}} \\
\makecell[l]{Some really long text\\ which I would like\\ to break up\\ with a hanging indent} & Short Text                         
\end{tabular}
\end{table}

Edit:

In the makecell documentation here (starting on page 9) you'll see various alignment options, including indenting the first line http://ctan.mirrors.hoobly.com/macros/latex/contrib/makecell/makecell.pdf . However, I would like a hanging indent, as below. I know I can add a forced spacing to each line, but is there a more compact way?

enter image description here

0

2 Answers 2

4

If I understand well what you mean by a hanging indent, I don't think it can be done within makecell, which is done for standard r, l or c cells. However, you can easily obtain it with a p{some length} cell. I took the opportunity to simplify the code for column heads, with the \thead command, and to have a better spacing between caption and table, with the caption package:

\documentclass{article}
\usepackage{array, tabularx, caption, makecell}
\renewcommand\theadfont{\normalsize\bfseries}
\usepackage{amsmath}

\begin{document}

\begin{table}[!htb]
  \centering
  \caption{My caption}
  \label{my-label}
  \begin{tabular}{>{\hangindent=1.5em\hangafter=1}p{4cm}c}
    \thead{Header} & \thead{Header} \\
    Some really long text\newline which I would like\newline to break up\newline with a hanging indent & Short Text
  \end{tabular}
\end{table}

\end{document} 

enter image description here

0

It is possible to do this with \makecell per the documentation:

\begin{tabularx}{\textwidth}{XXX}
  Hello
  & \makecell[{{>{\hangindent1em}X}}]{A very long strng of text which really should be broken at some point hopefully, and should be hung-indented.}
  & World
\end{tabularx}

You can even go a step further, and define a custom column type:

% in preamble
\newcolumntype{I}{>{\hangindent1em}X}

% ...

% in document body
\begin{tabularx}{\textwidth}{XXX}
  Hello
  & \makecell[{I}]{A very long strng of text which really should be broken at some point hopefully, and should be hung-indented.}
  & World
\end{tabularx}

You must log in to answer this question.

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