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'm trying to create a table where the first column spans 3 rows and the text will wrap several times. The second and third columns will each have 3 rows in them. The cells in the second column will have text that will also wrap several times. All the text must be left center justified.

Below is an example of what I'm trying to create.

Any help would be greatly appreciated.

_________________________________________________________________
                        |                       |               |
                        |Some text will go here |This will      |
                        |that will need to wrap |be empty       |
                        |                       |               |
                        |_______________________|_______________|
Some really long text   |                       |               |
that i would like       |Some text will go here |This will      |
left-center justified   |that will need to wrap |be empty       |
in this column          |                       |               |
                        |_______________________|_______________|
                        |                       |               |
                        |Some text will go here |This will      |
                        |that will need to wrap |be empty       |
                        |                       |               |
_________________________________________________________________
share|improve this question

3 Answers 3

The multirow package provides for spanning rows.

share|improve this answer

Here's how to do it using multirow:

enter image description here

\documentclass{article}
\usepackage{multirow}% http://ctan.org/pkg/multirow
\newcommand{\sometext}{Some text will go here that will need to wrap.}
\begin{document}
\noindent
\begin{tabular}{|p{.4\linewidth}|p{.35\linewidth}|p{.25\linewidth}|}
  \hline
  \multirow{12}{\linewidth}%
    {\sometext\ \sometext\ \sometext} & \sometext\ \sometext & \\ \cline{2-3}
  & \sometext\ \sometext & \\ \cline{2-3}
  & \sometext\ \sometext & \\ \hline
\end{tabular}
\end{document}

Note that the <lines> argument to \multirow

\multirow{<lines>}{<width>}{<content>}

denotes the number of \baselineskips, rather than the number of lines/rows within the table. So, in my example, the second column spans 12 lines, so I used \multirow{12}{\linewidth}{...} to vertically centre and span the full width of the cell.

There is also an optional [<bigstrut>] argument for \multirow that you might want to play with. See the multirow documentation for more.

Note that in the above example, the table stretches out into the margin causing an overfull \hbox warning, even though the paragraph column widths add up to \linewidth (a result of the MWE). This does not take into account the column rule widths (\arrayrulewidth) and separation (\tabcolsep). To accommodate for this (if you want your tabular to spread the entire \linewidth), use the tabularx package and at least one X-column:

\usepackage{tabularx}% http://ctan.org/pkg/tabularx
%...
\noindent%
\begin{tabularx}{\linewidth}{|p{.4\linewidth}|p{.35\linewidth}|X|}
  %...
\end{tabularx}

or correct for the column spacing and rule widths:

\noindent%
\begin{tabular}{%
    |p{\dimexpr.4\linewidth-2\tabcolsep-\arrayrulewidth}|
    p{\dimexpr.35\linewidth-2\tabcolsep-\arrayrulewidth}|
    p{\dimexpr.25\linewidth-2\tabcolsep-\arrayrulewidth}|}
  %...
\end{tabular}
share|improve this answer

If you don't need the rules, you could get away with just the primitive \valign:

\long\def\mytable#1\cr#2\endmytable{\begingroup
  \tabskip=\baselineskip % comes between rows
  \def\cr{\crcr\noalign{\hfil}} % comes between columns
  \def\cellformat{\raggedright\noindent\strut}
  \valign{&\vfil\hsize=.2\hsize\cellformat##\vfil\crcr
    \multispan3\vfil\hsize=.3\hsize\cellformat#1\vfil\cr
    #2\cr}
  \endgroup}

\mytable
  Some really long text that I would like left-center justified in this column.

  Just some more text to show another paragraph and its indentation.
  \cr
  Some text will go here that will need to wrap&
  Some text will go here that will need to wrap&
  Some text will go here that will need to wrap
  \cr
  This will be empty&
  This will be empty&
  This will be empty
\endmytable
\bye
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.