Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question
    
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 '11 at 3:20

2 Answers 2

up vote 3 down vote accepted

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}
share|improve this answer
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. –  Gonzalo Medina Jul 31 '11 at 14:13
1  
Alternatively, you could set the parindent in the column specification: {>{\setlength\parindent{1em}}p{2in}} –  Alan Munn Jul 31 '11 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 '11 at 14:19
    
@Alan: Thanks -- I adopted your suggestion (and defined a new column type). –  lockstep Jul 31 '11 at 14:26
1  
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 '11 at 19:35

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 not help.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.