# Shift all floats on page horizontally

I would like to modify the way standard floats, like figure or table, appear on page by shifting them horizontally relative to the paragraph text, see the image below.

To this end I have tried to use the adjustwidth environment provided by the package changepage, and redefine the original environments (e.g. figure) in the following way.

\documentclass[]{article}

\usepackage{mwe}
\usepackage{changepage}

\makeatletter
\newenvironment{shiftedfloat}[2][]
\renewenvironment{figure}[1][\fps@figure]
{\shiftedfloat[#1]{figure}}
{\endshiftedfloat}
\makeatother

\begin{document}

\blindtext

\begin{figure}[h]
\includegraphics[width=\textwidth]{example-image}
\caption{Figure caption}
\end{figure}

\end{document}


This only works until I try to load the float package and change the placement specification from [h] to [H], when I get an error:

! Extra }, or forgotten \endgroup.


Interestingly, everything works just fine when I move adjustwidth out of the shiftedfloat definition and put it directly into the given figure:

\documentclass[]{article}

\usepackage{mwe}
\usepackage{float}
\usepackage{changepage}

\makeatletter
\newenvironment{shiftedfloat}[2][]
{\@float{#2}[#1]}
{\end@float}
\renewenvironment{figure}[1][\fps@figure]
{\shiftedfloat[#1]{figure}}
{\endshiftedfloat}
\makeatother

\begin{document}

\blindtext

\begin{figure}[H]
\includegraphics[width=\textwidth]{example-image}
\caption{Figure caption}
\end{figure}

\end{document}


I appears to me that for some reason the \end{adjustwidth} gets lost in the former definition of shiftedfloat, but I couldn't quite figure out why.

Any suggestions how this can be fixed? Or maybe there is a better way of achieving the the desired effect? It's important that the original float environments get altered rather than any new environments are introduced, and that the solution is compatible with the float package, in particular with the [H] argument.

• – Steven B. Segletes Apr 5 '16 at 13:25
• Thank you @StevenB.Segletes My case is different from the one you referenced, as I would like to change the placement of the floats rather than the captions. – aoles Apr 28 '16 at 8:20

Thanks to Axel Sommerfeldt's solution to a similar issue described in Compatibility issue with \renewenvironment{figure} and [H] placement I was able to solve the problem by patching \float@endH from the float package as well.

\documentclass[]{article}

\usepackage{mwe}
\usepackage{changepage}
\usepackage{float}

\makeatletter
\newenvironment{shiftedfloat}[2][]
\renewenvironment{figure}[1][\fps@figure]
{\shiftedfloat[#1]{figure}}
{\endshiftedfloat}
% Adaption to the [H] placement provided by the float package
\AtBeginDocument{%
\let\float@endHorg\float@endH
}
\makeatother

\begin{document}

\blindtext

\begin{figure}[H]
\includegraphics[width=\textwidth]{example-image}
\caption{Figure caption}
\end{figure}

\end{document}