3

I'm struggling to make a specific cell (4th column) top and left aligned. Not too sure why \makecell is not co-operating but here's my latex code:

\documentclass[10pt,a4paper]{article}
\usepackage[left=1cm, right=1cm, top=2cm]{geometry}
\usepackage{booktabs}
\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{array}
\usepackage{makecell}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\parindent=0em \parskip=20pt
\newcommand\A{\rule{0pt}{2.5ex}}
\newcommand{\tabitem}{~~\llap{\textbullet}~~}
\begin{document}
\begin{center}

\begin{tabular}{llL{5.5cm}L{4.5cm}}
\toprule
\textbf{Variable} & \textbf{Census Code} & \textbf{Description} & \textbf{Study Variables} \\

\midrule
Education & cen\_ind\_std\_highest\_qual\_code & This variable records the highest qualification achieved by an individual. A qualification is a formally recognised award for educational or training attainment by one of the following authorities: 
    \begin{itemize}
        \item New Zealand Qualifications Authority and their recognised approval bodies 
        \item Universities New Zealand 
        \item Associations of Polytechnics of New Zealand 
        \item Association of Colleges of Education in New Zealand 
        \item Recognised overseas authorities
    \end{itemize}
 & \makecell[tl]{\textbf{highest\_qual}: \\ \hspace{\parindent} 0. No formal qualifications \\ \hspace{\parindent} 1. Level 1, 2, or 3 certificate \\ \hspace{\parindent} 2. Level 4, 5, or 6 certificate \\ \hspace{\parindent} 3. Undergraduate degree \\ \hspace{\parindent} 4, Postgraduate degree \\
 \hspace{\parindent} 9. Missing or unidentifiable} \\

\bottomrule 
\end{tabular}   

\end{center}
\end{document} 

enter image description here

1 Answer 1

1

i'm not sure what you like to obtain. however, last column is m type, so all cells' contents in this column is vertically centered regardless if contents is encapsulated in any environment (in your example in makecell).

try to replace m with p column type. than you will (considering suggested changes in your code) obtain:

enter image description here

(red lines indicate text borders)

i suggest to use the enumitem package for lists in your table and omit \makecell environments:

\documentclass[10pt,a4paper]{article}
\usepackage[hmargin=1cm, top=2cm]{geometry}
%\usepackage[latin1]{inputenc}
\usepackage{amsmath, amssymb}
\usepackage{graphicx}
\usepackage{booktabs, makecell}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}p{#1}}
\parindent=0em
\parskip=20pt

\usepackage{enumitem}

%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\begin{document}
    \begin{center}
    \setlist[itemize]{topsep = 1ex, parsep =0pt, leftmargin=*,after=\vspace{-\baselineskip}}
\begin{tabular}{ll L{5.5cm} L{4.5cm}}
\toprule
\textbf{Variable} & \textbf{Census Code} & \textbf{Description} & \textbf{Study Variables} \\
    \midrule
Education
    & cen\_ind\_std\_highest\_qual\_code
        & This variable records the highest qualification achieved by an individual. A qualification is a formally recognised award for educational or training attainment by one of the following authorities:
    \begin{itemize}
        \item New Zealand Qualifications Authority and their recognised approval bodies
        \item Universities New Zealand
        \item Associations of Polytechnics of New Zealand
        \item Association of Colleges of Education in New Zealand
        \item Recognised overseas authorities
    \end{itemize}
            & \textbf{highest\_qual}
                \begin{itemize}[leftmargin=1.5em]
            \item[0.]   No formal qualifications
            \item[1.]   Level 1, 2, or 3 certificate
            \item[2.]   Level 4, 5, or 6 certificate
            \item[3.]   Undergraduate degree
            \item[4.]   Postgraduate degree
            \item[9.]   Missing or unidentifiable
                \end{itemize}   \\
    \bottomrule
\end{tabular}
    \end{center}
\end{document}

edit: you may like the following table format:

enter image description here

in it is used tabularx table environment (it require to load the tabularx package):

\begin{tabularx}{\linewidth}{@{} ll 
    X 
    p{4.5cm} @{}}
\toprule
     %%%% table body, the same as above
\bottomrule
\end{tabularx}
1
  • Awesome, works like a charm :)
    – Lucas
    Sep 23, 2018 at 6:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .