# Custom geometry for page with floats

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}

• 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
• A longtable should never be encased inside a table. No exeptions. None. – Mico Feb 4 '18 at 21:28
• @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

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
• @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
• It seems like if you want to use \vspace*{-1cm} and \hspace*{-1cm} at the same time then the vspace has to go first before the minipage and second after the minipage. – Ubiquitous Mar 27 at 7:52
• @Ubiquitous ????? put the space after or before the minipage depending if you want to change the space before or after the image. ideally of course you would not have either hspace or vspace in a document – David Carlisle Mar 27 at 8:14
• Sorry, what I meant is that you have to do vspace-hspace-minipage-hspace-vspace. At least, if I do hspace-vspace-minipage-hspace-vspace the vspace part doesn't work. – Ubiquitous Mar 27 at 8:18