3

I'm having a problem with vertical alignment of cells in a somewhat complicated case. Does anyone know how to have a different vertical alignment for two cells in the same column? And also if you use the "p" alignment on some columns, it affects the alignment of other columns in the table that are set to "m". Below is the example:

Example table A: Using the "m" vertical alignment. Everything here is correct, except for the bullet-pointed items in the 2nd row, 5th and 6th column. These entries should be vertically aligned to the top left, like in Example table B

In latex (Table A):

\documentclass{revtex4-1}
\usepackage{array}
\begin{document}

\begin{table*}
\begin{ruledtabular}
\begin{tabular}{ >{\centering}m{0.8 in} >{\centering}m{0.8in} 
                  >{\centering}m{0.8in} >{\centering}m{0.8in} 
                  >{\centering}m{1.5in} >{\centering\arraybackslash}m{1.5in} }
    \bfseries Heading 1 & \bfseries Heading 2 & \bfseries Heading 3 & \bfseries Heading 4 & \bfseries Heading Heading Heading 5 & \bfseries Heading Heading Heading 6 \\

\hline

text & text & text & text &
    \begin{itemize}
        \item texttexttexttexttex texttexttexttexttexttexttexttext \end{itemize} &
    \begin{itemize}
         \item texttext texttext texttext texttext
        \item texttext texttext texttext texttext\end{itemize} \\

\end{tabular}
\end{ruledtabular}
\end{table*}

\end{document}

Example table B: Now, when using the "p" vertical alignment, the bullet-pointed items are correctly aligned, but everything else gets thrown off in the other columns. Also, I wanted to leave the "Headings" all vertically aligned.

In latex (Table B):

\documentclass{revtex4-1}
\usepackage{array}
\begin{document}

\begin{table*}
\begin{ruledtabular}
\begin{tabular}{ >{\centering}m{0.8 in} >{\centering}m{0.8in} 
                  >{\centering}m{0.8in} >{\centering}m{0.8in} 
                  >{\centering}p{1.5in} >{\centering\arraybackslash}p{1.5in} }
    \bfseries Heading 1 & \bfseries Heading 2 & \bfseries Heading 3 & \bfseries Heading 4 & \bfseries Heading Heading Heading 5 & \bfseries Heading Heading Heading 6 \\

\hline

text & text & text & text &
    \begin{itemize}
        \item texttexttexttexttex texttexttexttexttexttexttexttext \end{itemize} &
    \begin{itemize}
         \item texttext texttext texttext texttext
        \item texttext texttext texttext texttext\end{itemize} \\

\end{tabular}
\end{ruledtabular}
\end{table*}

\end{document}
  • Please always show a complete document that produces the image, it's hard to guess what markup you have used otherwise. A column specifier such as m, p, b only affects the one column not others, and can be changed per cell with \multicolumn{1}{b{..}}{...} – David Carlisle Oct 13 '14 at 19:40
  • Welcome to TeX.SX! – barbara beeton Oct 13 '14 at 19:40
  • 1
    @David Carlisle: I think ruledtabular comes from revtex. – Bernard Oct 13 '14 at 19:49
  • 1
    Note that m doesn't mean to vertically centre the text in the space taken up be that row, it means place the vertical cemtre of _this entry" (the word text here) on the reference line for the row, which is why when they have m and the list entries have p the centre of text lines up with the top of the space above the list – David Carlisle Oct 13 '14 at 19:56
  • 1
    @st77 it's important as people like to test their answers by running your code, and that's hard if it contains undefined commands. – David Carlisle Oct 13 '14 at 19:57
3

You can use nested tabular to control the alignment and enumitem to use a list with less vertical space:

enter image description here

\documentclass{revtex4-1}
\usepackage{array,enumitem}
\begin{document}
\begin{table*}
\begin{ruledtabular}
\begin{tabular}{ >{\centering}p{0.8 in} >{\centering}p{0.8in} 
                  >{\centering}p{0.8in} >{\centering}p{0.8in} 
                  >{\centering}p{1.5in} >{\centering\arraybackslash}p{1.5in} }
    \bfseries Heading 1 & \bfseries Heading 2 & \bfseries Heading 3 & \bfseries Heading 4 & \bfseries Heading Heading Heading 5 & \bfseries Heading Heading Heading 6 \\

\hline

text & text & text & text &
\multicolumn{2}{@{}m{\dimexpr3in+2\tabcolsep}@{}}{%
\begin{tabular}{>{\centering}p{1.5in} >{\centering\arraybackslash}p{1.5in}}
    \begin{itemize}[leftmargin=1em,noitemsep,topsep=0pt,parsep=0pt,partopsep=0pt]
        \item texttexttexttexttex texttexttexttexttexttexttexttext \end{itemize} &
    \begin{itemize}[leftmargin=1em,noitemsep,topsep=0pt,parsep=0pt,partopsep=0pt]
         \item texttext texttext texttext texttext
        \item texttext texttext texttext texttext\end{itemize} \\
\end{tabular}}
\end{tabular}
\end{ruledtabular}
\end{table*}
\end{document}
  • This looks great, I'll try it out. Thanks a lot! – st77 Oct 13 '14 at 20:16
  • David Carlisle: I try your code with two changes: instead of 'revex4-1' I use 'article', and for easy see obtained result I added 'preview' package. Without of 'preivew' I obtained the same result as you, with it, on the top of last column in nested table arise empty space. – Zarko Oct 14 '14 at 5:24
  • @Zarko presumably preview is conflicting with enumitem in some way, I don't know that package, perhaps ask a new question just about that – David Carlisle Oct 14 '14 at 8:01

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.