17

I have a really long table and it does not fit the page. So, I want it to span on several pages. When I google about my issue, I came accross longtable. However, it seems like longtable do not support tabular format. Is there a way to resolve this issue?

\documentclass[jou,apacite]{apa6}
\usepackage{multirow}
\usepackage{array}
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
\usepackage{longtable}
\begin{document}

\begin{longtable*}[!t]
\renewcommand{\arraystretch}{1.3}
\caption{My data}
\centering
\begin{tabular}{|p{2.8cm}|p{0.6cm}|p{1.6cm}|p{2.2cm}|P{0.8cm}|p{2.6cm}|p{2.5cm}|}
\hline
\textbf{Name} & \textbf{Year} & \textbf{ID} & \textbf{Address} & \textbf{Salary} & \textbf{Skills} & \textbf{Qualifications} \\
\hline
Some text & some text & some text & 5 & some text & Som text
\hline
\end{tabular}
\label{table3}
\end{longtable*}
\end{document}

Please let me know if any further details are needed. :)

EDIT

I did not just post the question without looking at any materials or other questions. I also tried the solution in How to convert table to longtable being able to break across pages?. However, that did not work either. That is why I posted the question.

Mensch
  • 65,388
EmJ
  • 368

1 Answers1

13

You have several issues in your given code, for example command \label has to follow \caption ...

You should not use verticals lines and instead of \hline have better a look to package booktabs (type texdoc booktabs on your terminal/console) ...

How you get the title back for the second page I left over for you. Please read the manual of longtable (type texdoc longtable on your terminal/console) ...

With the following corrected code

\documentclass[jou,apacite]{apa6}
\usepackage{multirow}
\usepackage{array}
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
\usepackage{longtable}

\usepackage{showframe} % to visualize writing area and margins ...
\usepackage{blindtext} % to generate dummy text


\begin{document}

\Blindtext
\renewcommand{\arraystretch}{1.3}

\begin{longtable}{|p{2.8cm}|p{0.6cm}|p{1.6cm}|p{2.2cm}|P{0.8cm}|p{2.6cm}|p{2.5cm}|}
\caption{My data}
\label{tab:table3}\\
\hline
\textbf{Name} & \textbf{Year} & \textbf{ID} & \textbf{Address} & \textbf{Salary} & \textbf{Skills} & \textbf{Qualifications} \\
\hline
Some text & some text & some text & 5 & some text & Som text &\\
\hline
Some text & some text & some text & 5 & some text & Som text &\\
\hline
Some text & some text & some text & 5 & some text & Som text &\\
\hline
Some text & some text & some text & 5 & some text & Som text &\\
\hline
Some text & some text & some text & 5 & some text & Som text &\\
\hline
Some text & some text & some text & 5 & some text & Som text &\\
\hline
Some text & some text & some text & 5 & some text & Som text &\\
\hline
Some text & some text & some text & 5 & some text & Som text &\\
\hline
Some text & some text & some text & 5 & some text & Som text &\\
\hline
\end{longtable}
\blindtext
\end{document}

you get the result:

enter image description here

Mensch
  • 65,388
  • Thanks a lot :) However, this still gives me an error in \begin{longtable}{|p{2.8cm}|p{0.6cm}|p{1.6cm}|p{2.2cm}|P{0.8cm}|p{2.6cm}|p{2.5cm}|}. It says that longtable not in 1-column mode. Is there a way to resolve this issue? – EmJ Jan 13 '19 at 02:13
  • 5
    @Emi Well, I think you do not want to hear that: no, longtable can not run in a two column layout (see manual). In my code I do not get that error, so in your origin you used something you did not show in your MWE :-( Try to add \onecolumn before the long table and add \twocolum after. – Mensch Jan 13 '19 at 02:19
  • @EmJ someone posted that question, see the answer here – nonthevisor Nov 11 '20 at 08:26
  • one of OP main question is about the use of tabular, but your answer does not explicitly mention it should indeed be removed!? – Matifou Mar 29 '21 at 15:11
  • Thank you for this code - it helped me to deal with a loooong table. However, I struggle with the lines, they are nice on the right side of the table but on the left side they dont go all the way up. Is there a way I can change this? – Marte Apr 05 '23 at 10:12