2

I am going a little crazy with alignment in the tabular environment.

In the following code I would like both the top-left cell 'Green Die', and the last cell in the 2nd row '6' to be aligned vertically.

I know the alignment issues with the cell '6' have to do with it being the last column, because if I make it the second to last column it is aligned in the middle.

Thanks in advance for any and all help!

\documentclass[11pt]{article}   
\usepackage{array, multirow}
\begin{document}

\newcolumntype{S}{>{\centering\arraybackslash} m{1.2cm} }
\begin{tabular}{|S|S|S|S|S|S|S|}
\hline

\multirow{2}{1.2cm} {\centering Green Die}&\multicolumn{6}{|c|} {Red Die} \\ \cline{2-7}

&1&2&3&4&5& 6\\ [4pt] \hline
1& 1+1=2&&&&&\\ [4pt]\hline
2&&&&&&\\[4pt] \hline
3&&&&&&\\[4pt] \hline
4&&&&&&\\ [4pt]\hline
5&&&&&&\\[4pt] \hline
6&&&&&&\\ [4pt]\hline
\end{tabular}

\end{document}

1 Answer 1

2
\documentclass[11pt]{article}    
\usepackage{array,ragged2e}
\newcolumntype{S}[1]{>{\Centering}m{#1}}

\begin{document}

\def\arraystretch{1.5}
\begin{tabular}{|*{7}{S{1.2cm}|}}\hline
\makebox(0,-10){\parbox{1.2cm}{\centering Green Die}} 
     & \multicolumn{6}{c|} {Red Die} \\\cline{2-7}
 & 1 & 2 & 3 & 4 & 5 & 6\\ \hline
1& 1+1=2&&&&&\\\hline
2&&&&&&\\\hline
3&&&&&&\\\hline
4&&&&&&\\\hline
5&&&&&&\\\hline
6&&&&&&\\\hline
\end{tabular}

\end{document}

enter image description here

5
  • Why does this solution work, and Michael's code not? (Especially with respect to the placement of the '6'.)
    – Alan Munn
    May 6, 2011 at 16:40
  • Thank you! There are several functions I have never used before in your code. I will have to figure them out. It is amazing to me how complicated it is to get some letters in the center of a box.
    – Michael
    May 6, 2011 at 21:07
  • Alan, why the '6' is not centered is quite the mystery for me
    – Michael
    May 6, 2011 at 21:09
  • the additional vertical space is added to the last column.
    – user2478
    May 7, 2011 at 6:09
  • Your last comment is still a bit cryptic to me. Where in your code (compared to Michael's) does the extra vertical space come from? (And can you add @Alan to your response so I will see it.)
    – Alan Munn
    May 7, 2011 at 17:02

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.