0

I have a figure with multiple subfigures and tikz-type of figures therein.

This figure contains a \pgfplotslegendfromname{named} type of legend.

This legend, which is wider than the text width, is always aligned with the left text margin, and always goes beyond the right text margin, regardless of whether I use single- or two-sided documents; while the figure (and its subfigures) above remain centered with respect to the text width.

Now, I'm interested in a two-sided document. Is it possible, in such a document, to have the aforementioned type of legend aligned with the right text margin in odd pages and with the left text margin in even pages, as well as spilling out accordingly; while still keeping the figure (and its subfigures) above the legend centered with respect to the text width?

If I use a narrower legend with less columns, then the plots and the legend stay all centered with respect to text width, but I'm interested in a wider legend, even if it spills out of the text margins. To put it short, I would like to have, in a two-sided document, a figure composed of subfigures that is centered with respect to text width, but a legend that being wider than the text width cannot be centered and is therefore aligned with either the right or left text margin depending on whether it lands on a even or odd page, respectively, spilling out accordingly into the left or right margin, respectively.

I tried to use the \ifoddpage package and insert:

\checkoddpage
\edef\side{\ifoddpage l\else r\fi}%
\makebox[\textwidth][\side]{%

immediately after \begin{figure}, but this option seems to have a conflict with the abovementioned type of legend.

Any help would be very welcome!

  • You have figures which are too wide for the document and you wish to align them? Why not trying to make the figures small enough to fit? IMHO opinion a document with overshooting figures won't look good. Apart from these comments, I'd like to encourage you to a compilable document, not just code fragments. – marmot Mar 23 at 17:31
  • thanks for your reply marmot. You might be right regarding the aesthetics of an overshooting legend, but I still would like to have that option. Regarding the MWE, you're totally right, and I'll try to prepare one in the coming hours. – Euclides Mar 23 at 19:18
  • You could just use \iffoddpage\makebox[\textwidth][l]{#1}\else\makebox[\textwidth][r]{#1}\fi assuming this is in a macro with argument #1. – John Kormylo Mar 23 at 20:46

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.