In my document I've a side capture environment as well as a full width environment for figures and tables. In the past I all my documents were printed on the back and front of a page, thus I had a clause in the environment that checked if a page is odd or even.
Now I want to only print on one side of the page and thus the environment should check for that. How can I accomplish this? (I'm using scrbook).
\documentclass[a4paper, oneside]{scrbook}
...
\usepackage{realboxes}
\newenvironment{fwfigure}[1][htbp]%
{%
\begin{figure}[#1]
\checkoddpage
\edef\side{\ifoddpage l\else r\fi}% <<<--- Here should another if statement check the *side-mode
\Makebox[\textwidth][\side]\bgroup%
\begin{minipage}[t]{\textwidth+\marginparsep+\marginparwidth}
\centering
}{%
\end{minipage}%
\egroup%
\end{figure}
}
EDIT:
I ended up doing this:
\makeatletter
\if@twoside%
\newcommand{\side}{\ifoddpage l\else r\fi} %% twoside=true
\else%
\newcommand{\side}{l} %% twoside=false
\fi%
\makeatother
%%%
\usepackage{realboxes}
\newenvironment{fwfigure}[1][htbp]%
{%
\begin{figure}[#1]
\checkoddpage
\Makebox[\textwidth][\side]\bgroup%
\begin{minipage}[t]{\textwidth+\marginparsep+\marginparwidth}
\centering
}{%
\end{minipage}%
\egroup%
\end{figure}
}
Best Answer
The test is provided by the LaTeX kernel with
So you can use this test. Please note that the test string uses
@
so you need\makeatletter
/\makeatother
(See: What do \makeatletter and \makeatother do?)Edit
There is a great answer of David explaining the how
\newif
command worksAs mention by egreg the package
\typearea
which is loaded by every KOMA-Class by default provides the optiontwoside=semi
. In this case the condition above should be extended by\if@semitwoside
.However based on your example you can redefine your environment as follows: