I am using KOMA script for my document. Occasionally, I have a float that is wider than text width, and I want the float to be pushed into the outer margin. This is why I defined \widefloat
command, that checks if page is odd using command \ifthispageodd
and depending on the results pushes the float left or right. This works fine when float is in the middle of the page. However, when float is thrown into the next page, \ifthispageodd
gives wrong result. Could you please tell me how to fix this up?
MWE: the first float is correctly pushed into outer margin, the second is pushed into inner margin.
\documentclass[11pt]{scrbook}
\usepackage{tikz,lipsum}
\newcommand{\widefloat}[1]{%
\ifthispageodd{\makebox[\textwidth][l]{#1}}{\makebox[\textwidth][r]{#1}}}
\begin{document}
\lipsum[1]
\widefloat{
\begin{tikzpicture}
\draw (0,0) rectangle (16cm,10cm);
\end{tikzpicture}}
\lipsum[3]
\widefloat{
\begin{tikzpicture}
\draw (0,0) rectangle (16cm,10cm);
\end{tikzpicture}}
\lipsum[2]
\end{document}