我已经尝试了所有能想到的方法,但 longtable 就是不允许我在表格顶部添加标题和标签。
但是当我添加标题和图片时,overleaf/texstudio 都崩溃了。这是我的代码:
\documentclass[10pt,a4paper]{article}
\usepackage[hmargin=1cm, top=2cm]{geometry}
\usepackage{amsmath, amssymb}
\usepackage{hyperref}
\usepackage{graphicx}
\usepackage{booktabs, makecell, longtable}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}p{#1}}
\parindent=0em
\parskip=20pt
\usepackage{enumitem}
\begin{document}
\begin{center}
\setlist[itemize]{topsep = 1ex, parsep =0pt, leftmargin=*,after=\vspace{-\baselineskip}}
\begin{longtable}{ll L{5.5cm} L{4.5cm}}
\caption{Table of 2013 Census variables used in this dissertation}
\label{Table 2.1}
\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{longtable}
\end{center}
\end{document}
答案1
编辑: 已经有答案了如何在长表顶部添加标题?。我保留了我的意见,因为它包含有关包裹装载顺序的进一步建议。
由于longtable
实现方式不同,需要 \\
在 前 手动添加换行符\toprule
。我还调整了一些包的加载顺序。
\documentclass[10pt,a4paper]{article}
\usepackage{amsmath, amssymb}
\usepackage{graphicx}
\usepackage{booktabs, makecell, longtable}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}p{#1}}
\setlength\parindent{0pt}
\setlength\parskip{20pt}% <- This should be a glue
\usepackage{enumitem}
\usepackage{hyperref}
\usepackage[hmargin=1cm,top=2cm]{geometry}
\begin{document}
\begin{center}
\setlist[itemize]{topsep=1ex, parsep=0pt, leftmargin=*, after=\vspace{-\baselineskip}}
\begin{longtable}{ll L{5.5cm} L{4.5cm}}
\caption{Table of 2013 Census variables used in this dissertation}
\label{Table-2.1}\\
\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{longtable}
\end{center}
\end{document}