dan-weiss / apa7-latex-cls-source

Source code for apa7 class
LaTeX Project Public License v1.3c
49 stars 13 forks source link

Long table in landscape #14

Closed junoslukan closed 3 years ago

junoslukan commented 3 years ago

Consider the example of a long table that should be rotated into landscape mode.

\documentclass[man]{apa7}
\usepackage{longtable}
\usepackage{pdflscape}
\begin{document}
\shorttitle{zz}
\begin{landscape}

\begin{longtable}{ccc} 
\caption{test} \\
\hline
Column1 & Column2 & Column3  \\
\hline
    Column1 & Column2 & Column3  \\
    Column1 & Column2 & Column3  \\
    Column1 & Column2 & Column3  \\ 
    Column1 & Column2 & Column3  \\
    Column1 & Column2 & Column3  \\
    Column1 & Column2 & Column3  \\
    Column1 & Column2 & Column3  \\
    Column1 & Column2 & Column3  \\
    Column1 & Column2 & Column3  \\
    Column1 & Column2 & Column3  \\
    Column1 & Column2 & Column3  \\
    Column1 & Column2 & Column3  \\
    Column1 & Column2 & Column3  \\
    Column1 & Column2 & Column3  \\
    Column1 & Column2 & Column3  \\
    Column1 & Column2 & Column3  \\
    Column1 & Column2 & Column3  \\
    Column1 & Column2 & Column3  \\
    \hline

\end{longtable} % line 36
\end{landscape}    % line 37

\end{document}

This works fine as long as the longtable package is loaded explicitly.

When loading is as the class option (which is the recommended way), changing only the first two lines:

\documentclass[man,longtable]{apa7}
%\usepackage{longtable}

I get an error:

\openout4 = document2.ttt (document2.ttt)) Runaway argument? ! File ended while scanning use of \next.

I also tried using the sidewaystable environment, but could not get it to work together with the longtable.

dan-weiss commented 3 years ago

I didn't modify the longtable implementation from the apa6 class when making apa7 so I don't know much about the issues. Please try the instructions in the documentation first (endfloat.cfg) and let me know if that works.

If that doesn't work, I can look into making these classes work together.

image
junoslukan commented 3 years ago

Hi dan-weiss, thank you for looking into this!

I did indeed copy the APA7endfloat.cfg to my working folder and renamed it to endfloat.cfg.

I tested this again and found out that using longtable as a class option produces a .ttt file that is also mentioned in the error pasted above. This file includes the table in question, including \begin{longtable} and \end{longtable}, but also \end{landscape} and \end{document}, with no matching \begin statements. I am not sure if that helps you at all, but it seemed suspect to me.

Note that this file is not produced when loading the longtable package explicitly.

Finally, it occurred to me to try the whole thing out without the endfloat.cfg file (that I had there all along) and the document compiled fine even with \documentclass[man,longtable]{apa7} as class option.

I hope this helps you narrow down the problem.

dan-weiss commented 3 years ago

@junoslukan I believe I solved your problem: instead of using the landscape environment, I used the sidewaystable environment and it worked. Here my the modified code (with end float.cfg in the folder with the project):

\documentclass[man,longtable]{apa7}
\begin{document}
\shorttitle{zz}

\begin{sidewaystable}
\begin{longtable}{ccc} 
\caption{test} \\
\hline
Column1 & Column2 & Column3  \\
\hline
    Column1 & Column2 & Column3  \\
    Column1 & Column2 & Column3  \\
    Column1 & Column2 & Column3  \\ 
    Column1 & Column2 & Column3  \\
    Column1 & Column2 & Column3  \\
    Column1 & Column2 & Column3  \\
    Column1 & Column2 & Column3  \\
    Column1 & Column2 & Column3  \\
    Column1 & Column2 & Column3  \\
    Column1 & Column2 & Column3  \\
    Column1 & Column2 & Column3  \\
    Column1 & Column2 & Column3  \\
    Column1 & Column2 & Column3  \\
    Column1 & Column2 & Column3  \\
    Column1 & Column2 & Column3  \\
    Column1 & Column2 & Column3  \\
    Column1 & Column2 & Column3  \\
    Column1 & Column2 & Column3  \\
    \hline

\end{longtable} % line 36
\end{sidewaystable}

\end{document}