Question 1
A while ago, I used some code from here, which fitted my requirements perfectly. However, I'd like a different table, and playing around with the code (I'm quite new to Latex) has not yielded any encouraging results. Basically I'd like a table like the one below (produced in Excel because I can't produce it in Latex at the moment):
Currently I am getting the following - note the numbers in notes are from an old table
My MWE (don't worry about alignment when it appears in the article class - I'm using a customised template which already has all the margins etc set out). I'd also like the Notes column to have a slightly greater width than the other columns because I will be putting more text in there. Also you might notice the (See Appendix ??) - that is my second question.
\documentclass{article}
\usepackage{booktabs}
\usepackage{array}
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}
\renewcommand\arraystretch{1.2}
\usepackage{threeparttable}
\begin{document}
\begin{table}[H]
\centering
\renewcommand\arraystretch{1.2}
\begin{threeparttable}
\caption{Description of Independent Variables}
\begin{tabular}{@{}p{0.20\textwidth}*{4}{L{\dimexpr0.20\textwidth-2\tabcolsep\relax}}@{}}
\toprule
& {\bfseries Independent Variable} & {\bfseries Code} & {\bfseries Units} & \bfseries{Notes} \\
\midrule
First-year GPA & FYGPA & Continuous & Overall first-year Grade Point Average & 5 -- 6 \\
Adjusted Matric GPA & AMGPA & Continuous & The average includes the top four subjects, excluding Mathematics, Additional Mathematics, Mathematics Paper 3 and English (First or Second Language. See Appendix~\ref{chapter:AppendixB}). & 11 -- 14 \\
\bottomrule
\end{tabular}
\end{threeparttable}
\end{table}
\end{document}
Question 2
I have a 'chapter' which is actually an Appendix. I've labelled the Appendix in the following way:
\chapter{Appendix B}
\label{AppendixB}
\lhead{Appendix B \emph{Adjusted Matric GPA }}
Now when I wanted to cross-reference this Appendix in my text, I get a ??. My cross-reference is the following:
See Appendix~\ref{chapter:AppendixB})
Why is Latex not picking up the label?
Question 3
My table is going to extend over one page once I put all my variables in. I see the longtable package is recommended for this job. However, simply replacing the \begin{table}...\end{table} with \begin{longtable}...\end{longtable} in my MWE is bringing up a whole host of additional errors (for example, it doesn't like the \centering command and says \caption -> \noalign). What should I be aware of when using the longtable package over the table package?
tabular
bylongtable
and leave out thetable
environment completely. In some senselongtable
implements both environments at once and has its own support for captions; see the documentation.