[Tex/LaTex] How to create a new column type with top alignment

columnstablesvertical alignment

I am trying to create a table which has wrapped text and the text in each cell is ragged right and top aligned. As you can see in the following image I'm not getting the top alignment.

Text is not aligned at the top of each cell

Here is my LaTeX code:

\documentclass[letterpaper]{article}
\usepackage{array}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}    \vspace{0pt}}m{#1}}
\begin{document}
    \begin{table*}[!t]
        \centering
    \begin{tabular}[t]{|L{1.8cm}| L{2.3cm}|}
        \hline
        This is a long line.  It sets the height of the column and is top aligned &i want this to be top aligned too\\\hline
        \end{tabular}
    \end{table*}
\end{document}

I would appreciate any hints for how to fix this.

Thank you!

Best Answer

[ Just to answer the unanswered, converting the comment into an answer ]

Replace m{#1} with p{#1}

\documentclass[letterpaper]{article}
\usepackage{array}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash}p{#1}}
\begin{document}
    \begin{table*}[!t]
        \centering
    \begin{tabular}[t]{|L{1.8cm}|L{2.3cm}|}
        \hline
        This is a long line. It sets the height of the column and is top aligned & I want this to be top aligned too\\\hline
        \end{tabular}
    \end{table*}
\end{document} 

enter image description here

Note that I've removed the spurious \hspace{0pt} \vspace{0pt} from your code.