1

I have a special page for floats (i.e., with [p]). In my real code it is a longtable in a table. Because of space issues I want to change the margins of the page with that float. How do I set a new geometry only for the float pages?

This is not a duplicate of the linked question as that solution does not work in the case of a float page.

An MWE with a \hrule to indicate the margins of the float page:

\documentclass[a4paper]{article}
\usepackage{geometry}
\usepackage{lipsum}
\begin{document}
\lipsum[1] 
\begin{figure}[p]
    \hrule
    \caption{A horizontal rule.}
\end{figure}
\end{document}
  • 3
    longtable is for multi-page tables, so it cannot float. You can use something like changepage.sty. – cfr Feb 4 '18 at 21:17
  • @Dr.ManuelKuehner thanks, but that doesn't seem to work, I think because I'm in a float. – Keelan Feb 4 '18 at 21:21
  • Ok - I read "a special page" so I assumed it is ONE page. – Dr. Manuel Kuehner Feb 4 '18 at 21:23
  • 3
    A longtable should never be encased inside a table. No exeptions. None. – Mico Feb 4 '18 at 21:28
  • 2
    @Keelan - You wrote both "In my real code it is a longtable in a table" and "the longtable is not directly in the table". I suspect I'm not the only one who senses a contradiction... – Mico Feb 4 '18 at 21:35
4

You do not need to change the page geometry (most likely) it is much simpler and usually sufficient just to allow the content of the float to bleed in to the margins, here by 1cm either side.

\documentclass[a4paper]{article}


\usepackage{lipsum}
\begin{document}
\lipsum[1] 
\begin{figure}[p]
\hspace*{-1cm}%
\begin{minipage}{\dimexpr\textwidth+2cm}
    \hrule
    \caption{A horizontal rule.}
\end{minipage}%
\hspace*{-1cm}
\end{figure}
\end{document}
  • Thanks! This works for the horizontal margin. For the vertical margin I would still be interested in something as well. But in my current case that is not necessary; what I now do is set the page style to empty (with floatpag) so that the table doesn't appear on top of the page number, and that's enough for now. Thanks again! – Keelan Feb 4 '18 at 21:49
  • 1
    @Keelan same as horizontal, you can put \vspace*{-1cm} or whatever above and below the minipage, so long as you have space to steal without hitting the page number or page head – David Carlisle Feb 4 '18 at 23:04

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.