[Tex/LaTex] Top alignment for a specific cell

tablestabularx

I tried to top align the cell for "Education" by \makecell[t] and it didn't work out. So I tried to top align the whole table and used \begin{tabularx}{\linewidth}[t] but it still didn't change anything. Though I only need "Education" to be top aligned, I would also be happy to know how to top align the whole table. Much appreciated in advance![enter image description here]1

\documentclass{article}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{makecell}

\begin{document}
    \begin{table}[htbp]
        \small
        \caption{Definition of Variables}

        \begin{tabularx}{\linewidth}[t]{ r X }
            \toprule
            Variable & Description \\
            \midrule
            SR1+  & Positive SR1 \\
            SRdummy1 & Dummy variable that equals one if SR1 is positive and zero otherwise \\
            SR2+  & Positive SR2 \\
            SRdummy2 & Dummy variable that equals one if SR2 is positive and zero otherwise \\
            LnInc & The Natural logarithm of the household income  \\
            Age   & The age of the household head \\
            \makecell[t]{Education} & \makecell[l]{The Education level of the household head;\\
                equals 1 with level of non-educational; \\ 
                equals 2 with level of primary school; \\ 
                equals 3 with level of junior high school; \\ 
                equals 4 with level of high school; \\ 
                equals 5 with level of secondary/vocational school; \\ 
                equals 6 with level of college/vocational; \\ 
                equals 7 with level of undergraduate degree; \\ 
                equals 8 with level of Master's degree; \\ 
                equals 9 with level of PhD degree; }  \\
            Kid   & The number of kids (age under 16) in the household \\
            Old   & The number of elders (age over 60) in the household \\
            HHsize & Number of persons living together in the household \\
            Male  & Dummy variable that equals one if the household head is male and zero otherwise \\
            Married & Dummy variable that equals one if the household head is married and zero otherwise \\
            Party & Dummy variable that equals one if the household head is a member of the Communist Party of China and zero otherwise \\
            Job   & Dummy variable that equals one if the household head is employed and zero otherwise \\
            House & Dummy variable that equals one if the household holds real estate asset and zero otherwise \\
            \bottomrule
        \end{tabularx}
        \label{tab:definition}

    \end{table}

\end{document}

Best Answer

There is no need for makecell here. The column has specifier X that allows line breaks by \newline:

Example with indented follow-up lines:

\documentclass{article}
\usepackage{array}
\usepackage{caption}% fix spacing for \caption above the table
\usepackage{tabularx}
\usepackage{booktabs}

\begin{document}
    \begin{table}
        \small
        \caption{Definition of Variables}
        \begin{tabularx}{\linewidth}[t]{ r >{\hangindent1em\hangafter1 }X }
            \toprule
            Variable & Description \\
            \midrule
            SR1+  & Positive SR1 \\
            SRdummy1 & Dummy variable that equals one if SR1 is positive and zero otherwise \\
            SR2+  & Positive SR2 \\
            SRdummy2 & Dummy variable that equals one if SR2 is positive and zero otherwise \\
            LnInc & The Natural logarithm of the household income  \\
            Age   & The age of the household head \\
            Education & The Education level of the household head;\newline
                equals 1 with level of non-educational;\newline
                equals 2 with level of primary school;\newline
                equals 3 with level of junior high school;\newline
                equals 4 with level of high school;\newline
                equals 5 with level of secondary/vocational school;\newline
                equals 6 with level of college/vocational;\newline
                equals 7 with level of undergraduate degree;\newline
                equals 8 with level of Master's degree;\newline
                equals 9 with level of PhD degree;  \\
            Kid   & The number of kids (age under 16) in the household \\
            Old   & The number of elders (age over 60) in the household \\
            HHsize & Number of persons living together in the household \\
            Male  & Dummy variable that equals one if the household head is male and zero otherwise \\
            Married & Dummy variable that equals one if the household head is married and zero otherwise \\
            Party & Dummy variable that equals one if the household head is a member of the Communist Party of China and zero otherwise \\
            Job   & Dummy variable that equals one if the household head is employed and zero otherwise \\
            House & Dummy variable that equals one if the household holds real estate asset and zero otherwise \\
            \bottomrule
        \end{tabularx}
        \label{tab:definition}
    \end{table}
\end{document}

Result

If the vertical space allows it, a little separation between the entries looks nicer:

\documentclass{article}
\usepackage{caption}% fix spacing for \caption above the table
\usepackage{tabularx}
\usepackage{booktabs}

\begin{document}
    \begin{table}
        \small
        \caption{Definition of Variables}
        \begin{tabularx}{\linewidth}[t]{ r X }
            \toprule
            Variable & Description \\
            \midrule
            SR1+  & Positive SR1 \\
            \addlinespace
            SRdummy1 & Dummy variable that equals one if SR1 is positive and zero otherwise \\
            \addlinespace
            SR2+  & Positive SR2 \\
            \addlinespace
            SRdummy2 & Dummy variable that equals one if SR2 is positive and zero otherwise \\
            \addlinespace
            LnInc & The Natural logarithm of the household income  \\
            \addlinespace
            Age   & The age of the household head \\
            \addlinespace
            Education & The Education level of the household head;\newline
                equals 1 with level of non-educational;\newline
                equals 2 with level of primary school;\newline
                equals 3 with level of junior high school;\newline
                equals 4 with level of high school;\newline
                equals 5 with level of secondary/vocational school;\newline
                equals 6 with level of college/vocational;\newline
                equals 7 with level of undergraduate degree;\newline
                equals 8 with level of Master's degree;\newline
                equals 9 with level of PhD degree;  \\
            \addlinespace
            Kid   & The number of kids (age under 16) in the household \\
            \addlinespace
            Old   & The number of elders (age over 60) in the household \\
            \addlinespace
            HHsize & Number of persons living together in the household \\
            \addlinespace
            Male  & Dummy variable that equals one if the household head is male and zero otherwise \\
            \addlinespace
            Married & Dummy variable that equals one if the household head is married and zero otherwise \\
            \addlinespace
            Party & Dummy variable that equals one if the household head is a member of the Communist Party of China and zero otherwise \\
            \addlinespace
            Job   & Dummy variable that equals one if the household head is employed and zero otherwise \\
            \addlinespace
            House & Dummy variable that equals one if the household holds real estate asset and zero otherwise \\
            \bottomrule
        \end{tabularx}
        \label{tab:definition}
    \end{table}
\end{document}

Result \addlinespace

Related Question