1

I have some strange problem tying place a "fake float" with large tables. Here is a MWE:

\documentclass[twoside, a4paper]{scrbook}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{geometry}
\usepackage{lipsum,blindtext}
\usepackage{tabu,longtable,booktabs}
\usepackage{showframe}
\usepackage{calc}
\usepackage{afterpage}
\usepackage{rotating}
\usepackage{lscape}

% Set main geometry
\geometry{inner=\paperwidth/9, textwidth=6\paperwidth/9, outer=2\paperwidth/9,
  top=\paperheight/9, bottom=2\paperheight/9}

\begin{document}

  % Set special layout and save it.
  \newgeometry{outer=\paperwidth/9, inner=\paperwidth/9,
    textwidth=7\paperwidth/9,top=\paperheight/9,
    bottom=\paperwidth/9}
  \savegeometry{L}
  \restoregeometry

\Blindtext

\afterpage{% First case: vertical long table
  \loadgeometry{L}
  \begin{longtabu}to \textwidth {XX}
    \caption{Lorem Ipsum}\\
    \toprule[2pt]
    \rowfont{\bfseries}
    Lorem & Ipsum\\
    \midrule
    \endfirsthead

    \toprule[2pt]
    \rowfont{\bfseries}
    Lorem & Ipsum\\
    \midrule
    \endhead

    \lipsum[1] & \lipsum[2] \\
    \midrule
    \lipsum[1] & \lipsum[2] \\
    \bottomrule[2pt]
    \end{longtabu}
   \restoregeometry
}

\Blindtext

\afterpage{%% Secons case: wide table in landscape env.
  \loadgeometry{L}
  \begin{landscape}
    \begin{longtabu}  {XX}
      \caption{Lorem Ipsum}\\
      \toprule[2pt]
      \rowfont{\bfseries}
      Lorem & Ipsum\\
      \midrule
      \endfirsthead

      \toprule
      \rowfont{\bfseries}
      Lorem & Ipsum\\
      \midrule
      \endhead

      \blindtext & \blindtext \\
      \midrule
      \blindtext & \blindtext \\
      \midrule
      \blindtext & \blindtext \\
      \bottomrule[2pt]
    \end{longtabu}
  \end{landscape}
  \restoregeometry
}

\Blindtext

\Blindtext
\end{document}

In the first case, the idea is enlarge a bit a page in order to fit a slightly larger table than \textheight. After the long table ends \textwidth is correctly reset to its original value, although bottom margin is not. The page number is also bad placed.

The second problem comes with wide table in landscape mode. As you can see in pag. 7, after exit landscape environment, next page have correct left an right margins, bot bottom one isn't. This is even stranger for me. the text area drawn shows a correct layout, and see the text spilling beyond lower box gets me puzzled.

Any help will be welcome.

Thanks in advance.

  • related tex.stackexchange.com/questions/267109/… – touhami Feb 12 '16 at 15:34
  • changing the output routine mid-document is one of the more delicate operations possible in tex, to use afterpage, longtable, and restoregeometry and have all three attempt to change the output routine at the same point seems ... wildly optimistic. I wouldn't attempt that and I wrote half that code:-) – David Carlisle Feb 12 '16 at 22:50
  • @DavidCarlisle And it is not even longtable.... – cfr Feb 13 '16 at 0:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.