12

I can manually try and indent, but it only works on the first 'paragraph' within the cell, and the \hspace won't even work with the second paragraph. Is there an easier way?

\ctable[
    cap= A short caption,
    caption= This is a longer caption,
    ]{lp{2in}p{2in}}{}{\FL
    title1 & title2 & title3\ML
    label &
    \hspace{1em} This is paragraph one.  This is paragraph one.\newline
    \hspace{1em} This is paragraph two.  This is paragraph two.&
    \hspace{1em} This is paragraph one.  This is paragraph one.\newline
    \hspace{1em} This is paragraph two.  This is paragraph two.\NN
    label2 &
    \hspace{1em} This is paragraph one.  This is paragraph one.\newline
    \hspace{1em} This is paragraph two.  This is paragraph two.&
    \hspace{1em} This is paragraph one.  This is paragraph one.\newline
    \hspace{1em} This is paragraph two.  This is paragraph two.\LL
    }

As an alternative, I might try simulating a table with minipages, but after briefly trying that, it seems like this should be e

1
  • Thanks everyone. Was not aware of \endgraf, which is a useful tip. I think ultimately, I'm going to switch to nesting a list inside these tables instead of trying to hack paragraphs into place, which makes for cleaner markup and still breaks up content within each cell.
    – glallen
    Aug 4, 2011 at 3:20

2 Answers 2

4

Use the \endgraf macro -- it works the same way as \par, but is also allowed in places where \par isn't. (Thanks to egreg for the tip.)

\documentclass{article}

\usepackage{ctable}
\newcolumntype{q}[1]{>{\setlength{\parindent}{1em}}p{#1}}

\begin{document}

\ctable[
    cap= A short caption,
    caption= This is a longer caption,
    ]{lq{2in}q{2in}}{}{\FL
    title1 & title2 & title3\ML
    label &
    This is paragraph one.  This is paragraph one.\endgraf
    This is paragraph two.  This is paragraph two.&
    This is paragraph one.  This is paragraph one.\endgraf
    This is paragraph two.  This is paragraph two.\NN
    label2 &
    This is paragraph one.  This is paragraph one.\endgraf
    This is paragraph two.  This is paragraph two.&
    This is paragraph one.  This is paragraph one.\endgraf
    This is paragraph two.  This is paragraph two.\LL
    }

\end{document}
6
  • 1
    If you use \setlength\parindent{1em} just before the cells contents (This is paragraph one. This is...) you can suppress all the \hspace commands. Jul 31, 2011 at 14:13
  • 2
    Alternatively, you could set the parindent in the column specification: {>{\setlength\parindent{1em}}p{2in}}
    – Alan Munn
    Jul 31, 2011 at 14:17
  • @Gonzalo: I suspected something like that, but do not know where exactly to put \setlength{parindent}{1em} in my MWE.
    – lockstep
    Jul 31, 2011 at 14:19
  • @Alan: Thanks -- I adopted your suggestion (and defined a new column type).
    – lockstep
    Jul 31, 2011 at 14:26
  • 2
    If you want that the \parindent is the same as the usual one, you can say \AtBeginDocument{\edef\normalparindent{\the\parindent}} and \setlength\parindent{\normalparindent} in the definition of the column type q.
    – egreg
    Jul 31, 2011 at 19:35
11

Around line ends/beginnings, LaTeX swallows spaces. To force these spaces to stay in place, use \hspace*{<length>}:

\ctable[
  cap= A short caption,
  caption= This is a longer caption,
  ]{lp{2in}p{2in}}{}{\FL
  title1 & title2 & title3\ML
  label &
  \hspace{1em} This is paragraph one.  This is paragraph one.\newline
  \hspace*{1em} This is paragraph two.  This is paragraph two.&
  \hspace{1em} This is paragraph one.  This is paragraph one.\newline
  \hspace*{1em} This is paragraph two.  This is paragraph two.\NN
  label2 &
  \hspace{1em} This is paragraph one.  This is paragraph one.\newline
  \hspace*{1em} This is paragraph two.  This is paragraph two.&
  \hspace{1em} This is paragraph one.  This is paragraph one.\newline
  \hspace*{1em} This is paragraph two.  This is paragraph two.\LL
  }

Setting paragraph spacing in ctable

Another alternative stems from the fact the paragraph indentation is removed within tables since their typesetting may be somewhat different from that of regular text. Consequently, setting \parindent to the appropriate value within \ctable should do the trick:

...
\setlength{\parindent}{1em}This is ... \endgraf &
\setlength{\parindent}{1em}This is ... \endgraf \\
...

However, you have to use \endgraf in order to terminate paragraphs together with the \setlength command here since neither \par nor \newline would help.

You must log in to answer this question.

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