3

I need to place lots of text in one table cell. I tried to use longtable, but it seems to work, say, only on a row basis and gives terrible result in case when one row isn't fit in a page.

Something like this

\documentclass {article}

\usepackage [utf8] {inputenc}
\usepackage [english] {babel}
\usepackage{lipsum}

\begin{document}

\clearpage
\section{My section}

\begin{longtable}{| c | p{3cm} | p{5cm} | p{3cm} |}
\hline
1   & 2
    & \lipsum 
    & 3 \\ \hline
\hline
\end{longtable}

\section{Another section}

\end{document}

gives a result close to this longtable with long text in a cell

EDIT: If it is completely impossible to have a table with a cell like this, how would you suggest to layout such a data (that is without table-like environment). This is just an ordinary table with heading, specifying the meaning of each column (four of them). One column tend to have lots of text in its cells. That's it.

8
  • That is correct (same will be true of any tex alignment, supertabular, tabu etc. If it is two columns normally it is better to use a list, what is your real case here? Jul 22 '14 at 19:18
  • Better use a larger screenshot of the output instead of the editor window. And how about \begin{multicols}{2}...\end{multicols} instead of a table?
    – user31729
    Jul 22 '14 at 19:19
  • longtable happily splits a table across pages, but will not split a 'cell'....
    – cmhughes
    Jul 22 '14 at 19:20
  • @DavidCarlisle unfortunately the “real” case here is to reproduce layout that is required by my institution and given in MS Word (like this postimg.org/image/4t62sokbh). Jul 22 '14 at 19:25
  • 1
    @ArtemPelenitsyn: I suggested multicols at a point in time, when the precise required was not clear. After that state, I agree with you, multicols is not of use here in this case
    – user31729
    Jul 22 '14 at 21:49
5

If only one column needs to break that can be on the main vertical list with the other columns treated as parboxes hung to the side:

\documentclass {article}

\usepackage [utf8] {inputenc}
\usepackage [latin] {babel}
\usepackage{lipsum}

\newenvironment{foo}[3]
{\list{}{\leftmargin6cm\rightmargin3cm
\itemindent0cm
\labelsep0pt
\labelwidth0cm}%
                \item[\rlap{\hspace{-6cm}\smash{%
\parbox[t]{2.9cm}{#1}%
\hspace{.2cm}%
\parbox[t]{2.9cm}{#2}%
\hspace{\dimexpr\textwidth-8.1cm}%
\parbox[t]{2.9cm}{#3}%
}}]}
 {\endlist}


\begin{document}

\clearpage
\section{My section}

\noindent X\dotfill X

\begin{foo}{1}{2}{3}
\lipsum
\end{foo}
\begin{foo}{11}{22}{33}
\lipsum
\end{foo}



\section{Another section}

\end{document}
3
  • And the rules? \hline?, \vline? How do i do?
    – skpblack
    Jul 23 '14 at 3:09
  • @skpblack you can use \hrule between each foo (or add it to the definition) vertical rules would be a bit trickier, easier if this was always complete pages not starting/ending mid page, or read the booktabs package doc and persuade yourself you don't want vertical rules:-) Jul 23 '14 at 7:14
  • Interesting solution, thank you! I edited my question to ask for different non-table solutions for this task. Right now I'm thinking about iterated boxed description environment with \hrule's between items, but can't adapt this solution tex.stackexchange.com/a/44223/7460 for description Jul 23 '14 at 9:44
0

So far I sticked to framed description solution. The labels in description are given from former table heading. Description environment breaks nicely across pages and framed environment generates sensible rules. I also added hrules between items of description as described here. The final solution looks like this: enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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