[Tex/LaTex] Vertically Aligning text at top in tabular* – [t] is ignored

tablesvertical alignment

I am setting a small tabular environment using tabular* (note the asterisk!), which is supposed to be used as a list item. My problem is that the [t] option I am passing to tabular* is getting ignored and the text in the second column stays center-aligned in the vertical direction.

Here is the result — note for the second item in the second column the text “also short” is centered with respect to the text in the left column, but I want it aligned at the top:
Center-aligned second column

My minimal code sample can be seen below. The relevant command is \mytab I have taken the definitions for the column types from this tex.stackexchange answer.

\documentclass[a4paper,11pt]{article}
\usepackage[empty]{fullpage}

\setlength{\tabcolsep}{0pt}

\setlength{\marginparwidth}{0pt}

% Adjust margins --- this is really ugly
\addtolength{\oddsidemargin}{-0.5in}
\addtolength{\evensidemargin}{-0.5in}
\addtolength{\textwidth}{1.0in}
\addtolength{\topmargin}{-0.5in}
\addtolength{\textheight}{1.0in}

\newlength{\mytablen}
\setlength{\mytablen}{\textwidth}
%\addtolength{\ressubheadingwidth}{-0.7em}


\usepackage{array}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}

%-----------------------------------------------------------
\newcommand{\mytab}[4]{
  \begin{tabular*}{\mytablen}[t]{L{13cm}@{\extracolsep{\fill}}R{5cm}}
    \hline
    \textbf{#1} & #2 \\
    \hline
    \textit{#3} & \textit{#4}\\
    \hline
  \end{tabular*}
}

\begin{document}

\begin{list}{}{\setlength{\leftmargin}{0.6em}\setlength{\topsep}{0.0em}\setlength{\itemsep}{-0.2em}}
\item
  \mytab{Just a single line --- nothing fancy}{Short}
  {A short name --- with some text}{20xx}
\item
  \mytab{Significantly longer title --- will have to be broken into the second line and happily continue there}{Also short}
  {A short name --- with some text}{20xx}
\item
  \mytab{Significantly longer title --- will have to be broken into the second line and (un?)happily continue there}{A pretty long title or name, which will be split.}
  {Here are, going to be, lots and lots, of names}{20xx}
\end{list} %}}}

\end{document}

Best Answer

You have to use the p specifier intead of m when declaring your new column types:

\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}p{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}p{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}p{#1}}

Then there is no need for [t] in the tabular* environment.

MWE:

\documentclass[a4paper,11pt]{article}
\usepackage[empty]{fullpage}

\setlength{\tabcolsep}{0pt}

\setlength{\marginparwidth}{0pt}

% Adjust margins --- this is really ugly
\addtolength{\oddsidemargin}{-0.5in}
\addtolength{\evensidemargin}{-0.5in}
\addtolength{\textwidth}{1.0in}
\addtolength{\topmargin}{-0.5in}
\addtolength{\textheight}{1.0in}

\newlength{\mytablen}
\setlength{\mytablen}{\textwidth}
%\addtolength{\ressubheadingwidth}{-0.7em}


\usepackage{array}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}p{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}p{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}p{#1}}

%-----------------------------------------------------------
\newcommand{\mytab}[4]{
  \begin{tabular*}{\mytablen}{L{13cm}@{\extracolsep{\fill}}R{5cm}}
    \hline
    \textbf{#1} & #2 \\
    \hline
    \textit{#3} & \textit{#4}\\
    \hline
  \end{tabular*}
}

\begin{document}

\begin{list}{}{\setlength{\leftmargin}{0.6em}\setlength{\topsep}{0.0em}\setlength{\itemsep}{-0.2em}}
\item
  \mytab{Just a single line --- nothing fancy}{Short}
  {A short name --- with some text}{20xx}
\item
  \mytab{Significantly longer title --- will have to be broken into the second line and happily continue there}{Also short}
  {A short name --- with some text}{20xx}
\item
  \mytab{Significantly longer title --- will have to be broken into the second line and (un?)happily continue there}{A pretty long title or name, which will be split.}
  {Here are, going to be, lots and lots, of names}{20xx}
\end{list} %}}}

\end{document} 

Output

enter image description here

Related Question