1

This is a follow-up to Span figure across margin and textbody in twoside: Assigning savebox locally. But all necessary info should be here.

I am trying to make wide images/tables span across margin and text body in a twoside-document. I've got some help, but would like to assign a macro which deals with changing [l],[r] for odd or even pages, so that it fits correctly. Also, for odd pages, it need to add something like the commented line \hspace{-\marginandsep}.

\documentclass[11pt, twoside]{article}
\usepackage{xparse, graphicx, showframe}
\newlength\marginandtext
\newlength\marginandsep
\addtolength{\marginandsep}{\marginparwidth}
\addtolength{\marginandsep}{\marginparsep}
\addtolength{\marginandtext}{\textwidth}
\addtolength{\marginandtext}{\marginandsep}
\NewDocumentCommand{\fullwidth}{smo}{%
\makebox[\textwidth][l]{%
    \begin{minipage}{\marginandtext}
    %\hspace{-\marginandsep}%
    #2%
    \end{minipage}}}%
\begin{document}
foo\\
\begin{figure}[b]
    \fullwidth{\includegraphics[width=\marginandtext, height=4cm]{example-image-a}}
\end{figure}
\clearpage
baz\\
\begin{figure}[t]
    \fullwidth{\includegraphics[width=\marginandtext, height=4cm]{example-image-a}}
\end{figure}
\end{document}

enter image description here

Runar
  • 6,082

1 Answers1

2

By use of package of package changepage and help of package calc it is simple:

enter image description here

\documentclass[11pt, twoside]{article}
    \usepackage{xparse} %not used in this MWE
    \usepackage{graphicx, showframe}
% new packages
    \usepackage{calc}
    \usepackage[strict]{changepage}

\newlength\marginandtext
\setlength{\marginandtext}{\textwidth+\marginparwidth+\marginparsep}
\newlength\marginandsep
\setlength{\marginandsep}{\marginparwidth+\marginparsep}

    \begin{document}
some text
\begin{figure}[b]
    \begin{adjustwidth*}{}{-\marginandsep}
\includegraphics[width=\marginandtext, height=4cm]{example-image-a}
    \end{adjustwidth*}
\end{figure}

\clearpage
\begin{figure}[t]
    \begin{adjustwidth*}{}{-\marginandsep}
\includegraphics[width=\marginandtext, height=4cm]{example-image-b}
    \end{adjustwidth*}
\end{figure}
some text
    \end{document}

That it works properly, you need to compile at least twice.

Zarko
  • 296,517
  • Thank you Zarko, this is perfect. Guess I'll have to make myself familier with the changepage package. – Runar Jan 04 '16 at 14:46