3

I am creating a very simple table with three columns and one row. The alignment and content of each column is as follows:

  • Col. 1 - (H) center, (V) middle, single character
  • Col. 2 - (H) left, (V) top, multiple lines w/ breaks
  • Col. 3 - (H) left, (V) top, wrapping text string

It seems like a simple task. I've looked through countless questions, here and elsewhere, and I can't seem to find a way to do this. Here are a couple things I've tried:

Attempt 1

The only thing this needs is a way to vertically-center the first column. Modifying this code would be my first choice, because it's very simple.

\documentclass{article}
\usepackage{lipsum}
\usepackage{array}

\begin{document}

\begin{tabular}{|>{\centering\arraybackslash}p{0.5in}|p{2in}|p{2in}|}
    \hline
    A &
    Line 1 \newline Line 2 \newline Line 3 \newline Line 4 &
    \lipsum*[75] \\
    \hline
\end{tabular}

\end{document}

enter image description here

Attempt 2

Same as above, except the last column is inside a \parbox. This makes the first column vertically-centered as desired, but the adjusted baseline causes the second column to start halfway down the cell.

\documentclass{article}
\usepackage{lipsum}
\usepackage{array}

\begin{document}

\begin{tabular}{|>{\centering\arraybackslash}p{0.5in}|p{2in}|p{2in}|}
    \hline
    A &
    Line 1 \newline Line 2 \newline Line 3 \newline Line 4 &
    \parbox{2in}{\lipsum*[75]} \\
    \hline      
\end{tabular}

\end{document}

enter image description here

Attempt 3

Creating a table with several rows and \multirow works to align the first column, but it won't allow the text to wrap in the third.

\documentclass{article}
\usepackage{lipsum}
\usepackage{array}
\usepackage{multirow}

\begin{document}

\begin{tabular}{|>{\centering\arraybackslash}p{0.5in}|p{2in}|p{2in}|}
    \hline
    \multirow{4}{*}{A} & Line 1 & \multirow{4}{*}{\lipsum*[75]} \\
    & Line 2 & \\
    & Line 3 & \\
    & Line 4 & \\
    \hline  
\end{tabular}

\end{document}

enter image description here

Any suggestions? I'm looking for a simple method with limited use of extra packages. This code will be compiled and run server-side on a fairly large scale, so the fewer dependencies, the better.

2
  • Welcome to TeX.SX!
    – jub0bs
    Jan 23, 2014 at 20:04
  • Thanks! I've been lurking for a while and have gleaned some fantastic information here. Hopefully I'll be able to offer some help sometime, too!
    – higrafey
    Jan 24, 2014 at 18:30

2 Answers 2

5

enter image description here

\documentclass{article}
\usepackage{lipsum}
\usepackage{array}

\begin{document}

\setlength\extrarowheight{2pt}

\begin{tabular}{|>{\centering\arraybackslash}m{0.5in}|c|}
    \hline
    A &
    \begin{tabular}{@{}p{2in}|p{2in}@{}}
    Line 1 \newline Line 2 \newline Line 3 \newline Line 4 &
    \lipsum*[75]
  \end{tabular} \\
    \hline
\end{tabular}

\end{document}
1
  • That's a really clever solution. Thank you! I played around with the nested tabular beforehand, but never got it working right. Is there any reason I wouldn't want to use this method for other tables with additional columns, specifying the vertical alignment as I go?
    – higrafey
    Jan 24, 2014 at 18:33
1

You might want to try cals package:

enter image description here

\documentclass{article}
\usepackage{lipsum}
\usepackage{cals}

\begin{document}

\begin{calstable}
\colwidths{{0.5in}{1.5in}{2.5in}}

% Add frame around the table
\makeatletter \def\cals@framecs@width{.4pt}\def\cals@framers@width{.4pt}

\brow
\alignC\cell{\vfil A}\alignL
\cell{Line 1 \newline Line 2 \newline Line 3 \newline Line 4}
\cell{\lipsum*[75]}
\erow
\end{calstable}

\end{document}
1
  • The cals package looks pretty neat. I hadn't heard of it before, but I think it might come in handy. I like how the alignment can be specified on a cell-by-cell basis. Thanks for showing it to me!
    – higrafey
    Jan 28, 2014 at 14:29

You must log in to answer this question.

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