1

I have the following landscaped longtable under a section:

\documentclass{article}
\usepackage{longtable}
\usepackage{arydshln}
\usepackage{pdflscape}


\begin{document}

\section{Landscaped longtable issues}

\begin{landscape}

\begin{longtable}{cccc}
\caption{Observations}\label{tab:X}\\
\hline
A & B & C & D\\
type & type & unit & an incredibly wiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiide source\\
\hline
\endfirsthead
\multicolumn{4}{l}%
{\tablename\ \thetable\ (\emph{continued from previous page})} \\
\hline
A & B & C & D\\
type & type & unit & an incredibly wiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiide source\\
\hline
\endhead
\hline 
\multicolumn{4}{r}%
{(\emph{continued on next page})} \\
\endfoot
\hline
\endlastfoot

Asian 1 & Yellow & X & R\\
Asian 2 & Yellow & X & R\\
Asian 3 & Yellow & X & R\\
Asian 4 & Yellow & X & R\\
Asian 5 & Yellow & X & R\\
Asian 6 & Yellow & X & R\\
Asian 7 & Yellow & X & R\\
Asian 8 & Yellow & X & R\\
Asian 9 & Yellow & X & R\\
Asian 10 & Yellow & X & R\\
Asian 11 & Yellow & X & R\\
Asian 12 & Yellow & X & R\\
Asian 13 & Yellow & X & R\\
Asian 14 & Yellow & X & R\\
Asian 15 & Yellow & X & R\\
Asian 16 & Yellow & X & R\\
Asian 17 & Yellow & X & R\\
Asian 18 & Yellow & X & R\\
Asian 19 & Yellow & X & R\\
Asian 20 & Yellow & X & R\\
American 1 & Red & Y & R\\
American 2 & Red & Y & R\\
American 3 & Red & Y & R\\
American 4 & Red & Y & R\\
American 5 & Red & Y & R\\
American 6 & Red & Y & R\\
American 7 & Red & Y & R\\
American 8 & Red & Y & R\\
American 9 & Red & Y & R\\
American 10 & Red & Y & R\\
American 11 & Red & Y & R\\
American 12 & Red & Y & R\\
American 13 & Red & Y & R\\
American 14 & Red & Y & R\\
American 15 & Red & Y & R\\
American 16 & Red & Y & R\\
American 17 & Red & Y & R\\
American 18 & Red & Y & R\\
American 19 & Red & Y & R\\
American 20 & Red & Y & R\\
& & &\\
\cdashline{1-3}
\multicolumn{2}{c}%
{\textbf{Mean type}} & Z &\\
\multicolumn{2}{c}%
{(standard deviation)} & (SD) &\\

\end{longtable}

\end{landscape}

\end{document}

as you see the landscape environment breaks the page right after the section title. Is it possible to have the landscaped longtable on the first page, right after the section title, while keeping the whole page in portrait orientation (i.e. I just want the longtable rotated, nothing else)? I know this is an old question, but I couldn't really find an elegant solution to the problem so far, and just wanted to hear from the community.............. cheers!

10
  • 1
    No, it is not possible. Landscape pages always start new page. One way is use sideways defined in `rotating˙ package, hoewer it can be only on one page. Does this section contain only table?
    – Zarko
    Dec 24, 2020 at 2:09
  • @Zarko: it contains a "true longtable", i.e., the longtable spans over multiple pages.............
    – Euclides
    Dec 24, 2020 at 8:23
  • @Zarko: I'll update the MWE (as soon as I find some time) with a multipage longtable. For better illustration..............
    – Euclides
    Dec 24, 2020 at 9:13
  • @Zarko: longtable in MWE has been updated..............
    – Euclides
    Dec 24, 2020 at 9:45
  • 1
    From typographical point of view have a mix of portrait and landscape page is not appealing. Beside this, the width of table had to bi smaller from text height, this amount may cast doubt on the eligibility of necessity of landscape oriented table. Width of table generated by your MWE doesn't show any need to have longtable in landscape pages ...
    – Zarko
    Dec 24, 2020 at 10:42

2 Answers 2

0

One can overlap the rotated section heading and the longtable, just be careful not to actually overlap them.

\documentclass{article}
\usepackage{longtable}
\usepackage{arydshln}
\usepackage{pdflscape}
\usepackage{adjustbox}

\newsavebox{\tempbox}

\begin{document}

\setbox\tempbox=\vbox{\section{Landscaped longtable issues}}

\begin{landscape}
\makebox[\linewidth][r]{\smash{\rotatebox[origin=lb]{-90}{\usebox\tempbox}}}\vspace{-\baselineskip}
\begin{longtable}[l]{cccc}
\caption{Observations}\label{tab:X}\\
\hline
A & B & C & D\\
type & type & unit & source\\
\hline
\endfirsthead
\multicolumn{4}{l}%
{\tablename\ \thetable\ (\emph{continued from previous page})} \\
\hline
A & B & C & D\\
unit & unit & unit & unit\\
\hline
\endhead
\hline 
\multicolumn{4}{r}%
{(\emph{continued on next page})} \\
\endfoot
\hline
\endlastfoot

Asian & Yellow & X & R\\
American & Red & Y & R\\
& & &\\
\cdashline{1-3}
\multicolumn{2}{c}%
{\textbf{Mean type}} & Z &\\
\multicolumn{2}{c}%
{(standard deviation)} & (SD) &\\

\end{longtable}

\end{landscape}

\end{document}
5
  • @John: what about hyperlinks to the section caption? To they point appropriately?..............
    – Euclides
    Dec 24, 2020 at 8:25
  • @John: nevermind, I'll answer that question myself and come back to you, if I have further questions or comments..............
    – Euclides
    Dec 24, 2020 at 9:11
  • @John: not sure yet how document-class-independent your proposed solution is. Hyperlink to Section looks fine for now. Hyperlink to Table looks bad.............. took the liberty to update your code with the hyperlinked cross-references.............. also switched to lscape (looks more consistent I think) and expanded the number of lines in the longtable for a true representation of a multipage longtable in landscape mode.............. –
    – Euclides
    Dec 24, 2020 at 10:11
  • @Jonh: do you think it is possible to have the hyperlink to the "landscaped longtable" pointing to the latter's caption? Would that be possible?..............
    – Euclides
    Dec 24, 2020 at 10:22
  • You can use \hyperlink{foo}{\ref*{tab:X}} to link to \hypertarget{foo}{}. The trouble is putting a \hypertarget to the right of a longtable. Dec 24, 2020 at 17:02
0

From provided MWE is hard to figured out, how the real table should looks. This may seems irrelevant to you, but we are unable to suggest you some, a wee bit different approach in table design, which will give better table format and also may make use of landscape pages unnecessary:

One possible solution can consider:

  • portrait page orientation with extend text width with adjustwidth macro defined in the changepage table
  • use xltabular table with modified `` column type in the last column
  • use of rules from the booktabs package
  • added additional vertical spaces around cells contents by use of the makecellgaped macro defined in the makecell package
\documentclass{article}
\usepackage{microtype}
\usepackage{ragged2e}                       % new added
\usepackage{arydshln,
            booktabs, makecell, xltabular}  % new, added
\renewcommand\theadfont{\bfseries}
\renewcommand\theadgape{}
\newcolumntype{L}{>{\RaggedRight\hspace{0pt}}X} %  added
\usepackage[skip=1ex, font=small, label font=bf]{caption}
\usepackage[strict]{changepage}
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{lipsum}


\begin{document}

\section{A wide table present in the portrait page}

    \begin{adjustwidth}{}{-\dimexpr\marginparsep+\marginparwidth\relax}
    \setlength\tabcolsep{4pt}
    \setcellgapes{2pt}
    \makegapedcells
\begin{xltabular}{\linewidth}{@{} ccc L @{}}
    \caption{Observations}
    \label{tab:X}                                               \\
    \toprule
\thead[b]{A\\ type}
    &   \thead[b]{B\\ type}
        & \thead[b]{C\\ unit}
            & \thead[b]{D\\ some description of column content} \\
    \midrule
\endfirsthead
    \caption[]{Observations 
               (\emph{continued from previous page})}   \\
    \toprule
\thead[b]{A\\ type}
    &   \thead[b]{B\\ type}
        & \thead[b]{C\\ unit}
            & \thead[b]{D\\ some description of column content} \\ 
    \midrule
\endhead
    \midrule
    \multicolumn{4}{r}{\small(\emph{continued on next page})}   \\
\endfoot
    \bottomrule
\endlastfoot
%%%%    table body
Asian 1     & Yellow    & X & \lipsum[66] \\
Asian 2     & Yellow    & X & \lipsum[66] \\
Asian 3     & Yellow    & X & \lipsum[66] \\
Asian 4     & Yellow    & X & \lipsum[66] \\
Asian 5     & Yellow    & X & \lipsum[66] \\
Asian 6     & Yellow    & X & \lipsum[66] \\
Asian 7     & Yellow    & X & \lipsum[66] \\
Asian 8     & Yellow    & X & \lipsum[66] \\
Asian 9     & Yellow    & X & \lipsum[66] \\
Asian 10    & Yellow    & X & \lipsum[66] \\
Asian 11    & Yellow    & X & \lipsum[66] \\
Asian 12    & Yellow    & X & \lipsum[66] \\
Asian 13    & Yellow    & X & \lipsum[66] \\
Asian 14    & Yellow    & X & \lipsum[66] \\
Asian 15    & Yellow    & X & \lipsum[66] \\
Asian 16    & Yellow    & X & \lipsum[66] \\
Asian 17    & Yellow    & X & \lipsum[66] \\
Asian 18    & Yellow    & X & \lipsum[66] \\
Asian 19    & Yellow    & X & \lipsum[66] \\
Asian 20    & Yellow    & X & \lipsum[66] \\
American 1  & Yellow    & X & \lipsum[66] \\
American 2  &  Yellow   & X & \lipsum[66] \\
\end{xltabular}
    \end{adjustwidth}
\lipsum[1]
\end{document}

prva stran

druga in tretja stran

(red lines indicate page layout)

It is possible to make some more tweaks of table design if the (imitation) of the real table contents would be known. For example, third column if contain units, can bi of s type defined in siunitx package, used can be smaller font size, for example \small etc. Anyway, to my opinion suggested solution looks better better than as your intended table format.

You must log in to answer this question.

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