4

i used a one-sided document with the following geometry content

\usepackage{geometry}
\geometry{
    top=3.5cm,
    bottom=3.5cm,
    outer=6cm,
    inner=2cm,
    heightrounded,
    marginparsep=0.8cm,
    marginparwidth=4.7cm
}

to get images to a proper size i used the following code to push the picture inside the margin

\begin{figure}[h]
\newgeometry{margin=1.8cm}
...
\restoregeometry
\end{figure}

... it looks like:

old

Now i changed the paper to a two-sided document in the document-class. I also updated the geometry code as follows

\usepackage{geometry}
\geometry{
    top=3.5cm,
    bottom=3.5cm,
    outer=6cm,
    inner=2cm,
    heightrounded,
    marginparsep=0.8cm,
    marginparwidth=4.7cm,
    twoside=true  % <--- !!!!
}

But i have some problems with big pictures on even pages:

new

The image should also be pushed into the margin. Any advice how to change the

\newgeometry{margin=1.8cm}

command?

  • Did you try specifying lmargin or rmargin? margin by itself applies automatically to all the margins. – musarithmia Aug 19 '14 at 13:15
  • I tried both, but nothing changed. It would be nice, if it automatically applies on both types of pages, odd and even, so i don't have to check all the pictures, whether it's on a even or odd page. – Frank Aug 19 '14 at 13:35
  • Try package changepage. with it you can locally change the width for your figure. Package also detect odd/even page and adjust margins properly in asymmetric page layout. See package documentation. – Zarko Aug 19 '14 at 14:09
  • This does only affect the images (not the caption) and pushes them left or right with a wrong size. – Frank Aug 19 '14 at 16:02
  • If you put the caption together with figure inside changepage, the caption should follows position of a figure. my experiences with memoir, which incorporate changepage ability show me, that this should work. – Zarko Aug 19 '14 at 16:50
1

I finally came up using the following code with some examples how to set up the pictures and captions:

\documentclass{scrartcl}
\usepackage{scrextend}

\usepackage{geometry}
\geometry{
    top=3.5cm,
    bottom=3.5cm,
    outer=6cm,
    inner=2cm,
    heightrounded,
    marginparsep=0.8cm,
    marginparwidth=4.7cm,
    twoside=true,
    hmarginratio=1:1
}

\usepackage{caption}
\usepackage{subcaption}
%\usepackage{subfig}
\captionsetup[subfigure]{labelformat=simple, labelsep=colon}
\captionsetup[figure]{position=b}
\captionsetup[subfigure]{position=b}

\newcommand*{\figurewidthaddition}{\dimexpr
  \marginparwidth+\marginparsep\relax}
\newsavebox\figurebox

\usepackage{mwe}
\begin{document}
\section{Testchapter}
\blindtext
\begin{figure}
  \ifthispageodd{\makebox[\textwidth][l]}%
                {\makebox[\textwidth][r]}%
  {\includegraphics[width=1.2\textwidth,height=2cm]{example-image}}
  \caption{First test figure: \blindtext}
\end{figure}

\Blindtext
\begin{figure}
  \ifthispageodd{\makebox[\textwidth][l]}%
                {\makebox[\textwidth][r]}%
  {\includegraphics[width=1.2\textwidth,height=2cm]{example-image}}
  \caption{Second test figure: \blindtext}
\end{figure}

\blindtext
\begin{figure}
  \begin{addmargin*}[0pt]{-\figurewidthaddition}
    \begin{minipage}{\linewidth}
      \ifthispagewasodd\else\raggedleft\fi
      \includegraphics[width=.9\textwidth,height=2cm]{example-image}
      \caption{Third test figure: \blindtext}
    \end{minipage}
  \end{addmargin*}
\end{figure}

\blindtext
\begin{figure}
  \begin{addmargin*}[0pt]{-\figurewidthaddition}
    \begin{minipage}{\linewidth}
      \ifthispagewasodd\else\raggedleft\fi
      \includegraphics[width=.9\textwidth,height=2cm]{example-image}
      \caption{Fourth test figure: \blindtext}
    \end{minipage}
  \end{addmargin*}
\end{figure}

\blindtext

test






\begin{figure}
  \savebox\figurebox{%
    \includegraphics[width=1.2\textwidth,height=2cm]{example-image}%
  }%
  \begin{addmargin*}[0pt]{\dimexpr \textwidth-\wd\figurebox\relax}
    \begin{minipage}{\linewidth}
      \ifthispagewasodd\else\raggedleft\fi
      \usebox\figurebox
    \captionsetup{width=0.8\linewidth}
      \caption{Fifth test figure:jwehfewjf\"uoiewj\"ufoijew\"uoi oewfjewoi iuhew ewpfoijewf epwoifje weoipfj ewfopijwef weopifjew fwepoifjwe fpewoij}
    \end{minipage}
  \end{addmargin*}
\end{figure}







\blindtext
\begin{figure}
  \savebox\figurebox{%
    \includegraphics[width=1.2\textwidth,height=2cm]{example-image}%
  }%
  \begin{addmargin*}[0pt]{\dimexpr \textwidth-\wd\figurebox\relax}
    \begin{minipage}{\linewidth}
      \ifthispagewasodd\else\raggedleft\fi
      \usebox\figurebox
      \caption{Sixth test figure: \blindtext}
    \end{minipage}
  \end{addmargin*}
\end{figure}

\end{document}
  • So this is basically your MWE? – John Kormylo Aug 20 '14 at 14:05
  • BTW, there is a problem in that \ifthispageodd uses the page the float was defined on, not the page it appears on. – John Kormylo Aug 20 '14 at 14:23
  • Yes, its a MWE. The problem you mentioned didn't affect my work. I saw some drifts in the images while compiling the first time, but after the second compilation it worked as intended ;) – Frank Aug 20 '14 at 17:07
  • You really don't have to change the geometry to put things into the margins. Use \hspace with a negative distance either before (left margin) or after (to prevent overfull boxes). \hfill\llap{} will right justify into the left margin, and \rlap{}\hfill\newline will left justify into the right margin. – John Kormylo Aug 20 '14 at 23:15
1

This demonstrates left and right shifted images with captions aligned with both the text and with the images.

\documentclass{scrartcl}
\usepackage{scrextend}

\usepackage{geometry}
\geometry{
    top=3.5cm,
    bottom=3.5cm,
    outer=6cm,
    inner=2cm,
    heightrounded,
    marginparsep=0.8cm,
    marginparwidth=4.7cm,
    twoside=true,
    hmarginratio=1:1
}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
%\usepackage{subfig}
\captionsetup[subfigure]{labelformat=simple, labelsep=colon}
\captionsetup[figure]{position=b}
\captionsetup[subfigure]{position=b}

\newcommand{\widebox}[1]% #1 = contents
{\ifthispageodd{\rlap{#1}\rule{\textwidth}{0pt}}%
{\rule{\textwidth}{0pt}\llap{#1}}}

\usepackage{mwe}

\begin{document}
\section{Testchapter}
\blindtext
\begin{figure}
  \widebox{\includegraphics[width=1.2\textwidth,height=2cm]{example-image}}
  \caption{First test figure: \blindtext}
\end{figure}

\lipsum[1-4]
\begin{figure}
  \widebox{\includegraphics[width=1.2\textwidth,height=2cm]{example-image}}
  \caption{Second test figure: \blindtext}
\end{figure}

\blindtext
\begin{figure}
  \ifthispageodd{}{\null\hspace{-.2\textwidth}}%
    \begin{minipage}{1.2\textwidth}
    \includegraphics[width=\textwidth,height=2cm]{example-image}
    \caption{Fourth test figure: \blindtext}
  \end{minipage}%
  \ifthispageodd{\hspace{-.2\textwidth}}{}%
\end{figure}

\blindtext
\begin{figure}
  \ifthispageodd{}{\null\hspace{-.2\textwidth}}%
  \begin{minipage}{1.2\textwidth}
    \includegraphics[width=\textwidth,height=2cm]{example-image}
    \caption{Fourth test figure: \blindtext}
  \end{minipage}%
  \ifthispageodd{\hspace{-.2\textwidth}}{}%
\end{figure}

\Blindtext
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.