2

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}
Keelan
  • 5,425
  • 3
    longtable is for multi-page tables, so it cannot float. You can use something like changepage.sty. – cfr Feb 04 '18 at 21:17
  • @Dr.ManuelKuehner thanks, but that doesn't seem to work, I think because I'm in a float. – Keelan Feb 04 '18 at 21:21
  • Ok - I read "a special page" so I assumed it is ONE page. – Dr. Manuel Kuehner Feb 04 '18 at 21:23
  • @Dr.ManuelKuehner it is one page, but I don't know which one, so I don't know where to place the \newgeometry and \aftergeometry. When I place it in the float, nothing happens. By 'special page' I meant using a float with [p]. – Keelan Feb 04 '18 at 21:23
  • I see. Just an idea: float package and [H] option. – Dr. Manuel Kuehner Feb 04 '18 at 21:26
  • 3
    A longtable should never be encased inside a table. No exeptions. None. – Mico Feb 04 '18 at 21:28
  • @Mico the reason was that I wanted multiple columns (so the longtable is not directly in the table): https://tex.stackexchange.com/a/46001/23992 --- But I can also split it up in two separate tabulars, if that helps. – Keelan Feb 04 '18 at 21:32
  • 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 04 '18 at 21:35
  • @Mico I tried to simplify things for this question. That's obviously failing, apologies. The real structure is as in the link I gave in my previous comment: table > multicols > longtable (through a savebox). But I now also have table > multicols > 2 * tabular, if that's better. I think that if I have a way to get the MWE from my post, with the figure, to work, I can manage the real case as well. – Keelan Feb 04 '18 at 21:38

1 Answers1

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}
David Carlisle
  • 757,742
  • 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 04 '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 04 '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 '20 at 07: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 '20 at 08: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 '20 at 08:18
  • @Ubiquitous doing hspace and vspace at the same point is pretty odd thing to do (more natural to trim the figure dimensions if the intention is to adjust the figure) but anyway a vspace in horizontal mode is inserted after the paragraph is broken in to lines, after the line that contains the vspace node. so if you do hspace 1 vspace 2 minipage 3 hspace 4 the vertical space could be at any of 1,2,3,4 depending on the widths involved and where linebreaking happens, – David Carlisle Mar 27 '20 at 08:29