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 would like to get the lorem ipsum text to start on the same row as "A" in the table below. How can I do this?

enter image description here

Here is my code:

\documentclass{article}
\usepackage[hmargin=3cm,vmargin=8cm]{geometry}
\usepackage{array}
\newcolumntype{B}[1]{>{\arraybackslash\hspace{0pt}}p{#1}}
\begin{document}
\begin{tabular}[t]{l@{\hspace{0.7cm}}!{\vrule width 2pt}@{\hspace{0.7cm}}B{10cm}}
X & Y \\
& \\
A \\ B & 
lorem ipsum dolor sit amet, consectetuer adipiscing elit. nam cursus. morbi ut mi. nullam enim leo, egestas id, condimentum at, laoreet mattis, massa. sed eleifend nonummy diam. praesent mauris ante, elementum et, bibendum at, posuere sit amet, nibh. duis tincidunt lectus quis dui viverra vestibulum. suspendisse vulputate aliquam dui. nulla elementum dui ut augue. aliquam vehicula mi at mauris. maecenas placerat, nisl at consequat rhoncus, sem nunc gravida justo, quis eleifend arcu velit quis lacus. morbi magna magna, tincidunt a, mattis non, imperdiet vitae, tellus. sed odio est, auctor ac, sollicitudin in, consequat vitae, orci. fusce id felis. vivamus sollicitudin metus eget eros. \\
& \\
\end{tabular}
\end{document}
share|improve this question
    
you don't have the A with lipsum text on the same row in your code. –  percusse Jan 29 '12 at 18:17
    
Doesn't the \\ between A and B simply make a newline break in the cell? –  dr.bunsen Jan 29 '12 at 18:19
    
No, the first column is declared as l, so it doesn't admit line breaks. –  egreg Jan 29 '12 at 18:47
add comment

2 Answers 2

up vote 3 down vote accepted

The simplest thing you can do is to emulate a line break with a nested tabular environment:

X & Y \\
\begin{tabular}[t]{@{}l@{}}A \\ B \end{tabular} & \lipsum[1] \\

Of course it's better to define a personal command for this:

\newcommand{\breakcell}[2][l]{\begin{tabular}[t]{@{}#1@{}}#2\end{tabular}}

so that the input can become

X & Y \\
\breakcell{A \\ B} & \lipsum[1] \\

With this definition, \breakcell can also be called as \breakcell[c]{...} or \breakcell[r]{...} to change the inner horizontal alignment.

share|improve this answer
1  
Nice one. Works better and looks a lot less cluttered than the multirow solution. –  Michael Palmer Jan 29 '12 at 19:22
    
Thank you, this solution works perfectly. –  dr.bunsen Jan 29 '12 at 19:28
add comment

Here is a solution based on the multirow package:

\documentclass{article}
\usepackage[hmargin=3cm,vmargin=8cm]{geometry}
\usepackage{array,lipsum,multirow}
\newcolumntype{B}[1]{>{\arraybackslash\hspace{0pt}}p{#1}}
\begin{document}
\begin{tabular}[t]{l@{\hspace{0.7cm}}!{\vrule width 2pt}@{\hspace{0.7cm}}B{10cm}}
X & Y \\[20pt]  % use this to insert extra space between table rows
A & \multirow{2}{10cm}{\lipsum[1]} \\
B & \\[5.2cm]  % see note below
Joe & Blow
\end{tabular}
\end{document}

There is one unsatisfactory aspect to this - I had to insert some vertical space after the lorem ipsum to get the proper table row height. I couldn't find an automatic solution for this.

share|improve this answer
add comment

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.