1

I have a two column document with images. If an image is put in the left column, I want it to extend all the way to the edge of the page. Images in the right column should extend all the way to the right. If an image is put on the top left/right, or bottom left/right it should extend all the way into the corner.

I also have images that should span across the whole page.

Ideally the captions should automatically be placed above or below the figures, depending on there a figure is placed. A figure that is placed on the top right of the page, should have the caption is below it. But it shouldn't go all the way to the edge of the page.

I started to play around with this example, but I can't quite get it to work. Here the adjustments were done manually. My target is to have it done automatically, as I have 700+ images. Also I'm not using the memoir class, but maybe I can start to use it.

image extends to page edge

\documentclass{memoir}
\usepackage{lipsum}
\usepackage[demo]{graphicx} %remove demo in your file.
\usepackage[export]{adjustbox}
\usepackage{letltxmacro}
\LetLtxMacro{\originalfigure}{\figure}
\LetLtxMacro{\originalendfigure}{\endfigure}
\renewenvironment{figure}[1][htb]%
{\originalfigure[#1]% \begin{figure}[htb]
        \begin{adjustwidth*}{-1.5in}{-1.5in}
        }%
        {\end{adjustwidth*}\originalendfigure}% \end{figure}
\twocolumn 

\begin{document}
    \lipsum[1]
    \begin{figure}[htb]
        \caption{This is a one big caption that may run in to more than two lines without any trouble to us in setting more margins}\label{fig:figure-chow}
        \adjincludegraphics[width=1.7\columnwidth,left]{figure}
    \end{figure}
    \lipsum[1]
    %
\end{document}

My goal is to have something like this, where black are the images and gray is the text.

enter image description here

1
  • You can also simply overlap the margins using \makebox. Top and bottom margins are a little trickier. You will also need a way to determine which column you wound up on (see tikzpagenodes). If you set topnumber to 1, all top floats will be at the very top. Commented Jul 5 at 19:29

2 Answers 2

1

Edit:
At the first attempt I apparently misunderstand what you after. Now I see, that you almost done. You only need to make the following small changes:

  • accommodate width of adjustwidth width to width which is available on page
  • to have wide figure on the same page where you insert it in text, you need to employ stfloats package. It will has desired effect if the following conditions will be fulfilled:
    • inserted should be already in the first column on the page
    • after point of insertion there should be sufficient vertical space for wide figure.
\documentclass[twocolumn]{memoir}
\usepackage{lipsum}
\usepackage[demo,
            export]{adjustbox}
\usepackage{stfloats}   % new

\begin{document}
    \lipsum[66]
    \begin{figure}[htb]
\begin{adjustwidth*}{-15mm}{}
\caption{This is a one big caption that may run in to more than two lines without any trouble to us in setting more margins}
\label{fig:figure-chow}
    \adjincludegraphics[width=\linewidth]{figure}
\end{adjustwidth*}
    \end{figure}
    
    \begin{figure*}[b]
\begin{adjustwidth}{-15mm}{-25mm}
\caption{This is a one big caption that may run in to more than two lines without any trouble to us in setting more margins}
\label{fig:figure-chow}
    \adjincludegraphics[width=\linewidth, height=44mm]{figure}
\end{adjustwidth}
    \end{figure*}
    \lipsum[66]
    
    \begin{figure}[htb]
\begin{adjustwidth*}{}{-25mm}
\caption{This is a one big caption that may run in to more than two lines without any trouble to us in setting more margins}
\label{fig:figure-chow}
    \adjincludegraphics[width=\linewidth]{figure}
\end{adjustwidth*}
    \end{figure}

    \lipsum[66]   
\end{document}

enter image description here

As you can observe, for your quite unusual demand for page design, you need to perform a lot manual tweaking for image appearing in the desired form: from defining amount of length, for which images spill of column borders separately for left and right column and care about where should be inserted wide figure ...

BTW, I wonder, why you doing this. Resulted page has (to my opinion at least) bad typographically appearance.

3
  • That's not really what I wanted. I added an image to show what I mean.
    – Roald
    Commented Jul 5 at 18:36
  • I'm trying to convert a travel blog into a book and I want the images to be as big as possible. I find it a waste to have so much white space around when that could be filled by the pictures. If I understand correctly this solution does require manual adjustment of \begin{adjustwidth} where either the first or second argument needs be entered, depending if an image is in the left or right column?
    – Roald
    Commented Jul 9 at 5:09
  • @Roald, of course. You should tell in advance how big are your images.- At this you should be aware that at spinning side of pages images will become worse visible as at opposite (outer) side. But this up to you.
    – Zarko
    Commented Jul 9 at 5:19
0

This uses tikzpagenodes to detect left and right columns, It is not the most efficient, but is far simpler to use. The assumption is that figures only overlap the left and right margins, while figure* overlaps the top and bottom margins.

\documentclass{memoir}
\usepackage{lipsum}
\usepackage[demo]{graphicx} %remove demo in your file.
\usepackage[export]{adjustbox}
\usepackage{letltxmacro}
\usepackage{showframe}

\usepackage{tikzpagenodes}
\newif\ifLeftFloat
\newcommand{\CheckFloatColumn}{\begin{tikzpicture}[overlay,remember picture]
  \pgfextractx{\dimen1}{\pgfpointdiff{\pgfpointorigin}%
    {\pgfpointanchor{current page text area}{center}}}%
  \ifdim\dimen1>0pt
    \global\LeftFloattrue
  \else
    \global\LeftFloatfalse
  \fi
\end{tikzpicture}}

\makeatletter
\renewenvironment{figure}[1][tbp]{\@float{figure}[#1]%
  \CheckFloatColumn
  \ifLeftFloat
    \hspace{\dimexpr-\oddsidemargin-1in}%
    \begin{minipage}{\dimexpr \columnwidth+\oddsidemargin+1in}%
  \else 
    \begin{minipage}{\dimexpr \paperwidth-\columnsep-\columnwidth-\oddsidemargin-1in}%
  \expandafter\fi}%
{\end{minipage}%
  \ifLeftFloat\else
    \hspace{\dimexpr \textwidth+\oddsidemargin+1in-\paperwidth}%
  \fi
  \end@float}
\makeatother

\twocolumn 

\begin{document}
    \lipsum[1]
    
    \begin{figure}[htb]
        \caption{This is a one big caption that may run in to more than two lines without any trouble to us in setting more margins}\label{fig:figure-chow}
        \includegraphics[width=\linewidth]{example-image}
    \end{figure}
    
    \lipsum[1]
    
    \begin{figure}[htb]
        \caption{This is a one big caption that may run in to more than two lines without any trouble to us in setting more margins}\label{fig:figure-chow2}
        \includegraphics[width=\linewidth]{example-image}
    \end{figure}
    
    \lipsum[1]
    %
\end{document}
4
  • There is not automatic way to get this behavior depending if an image is in the right or left column?
    – Roald
    Commented Jul 9 at 5:10
  • Yes there is, but I wasn't ambitious enougth to do the whole thing at once. Then I got distarcted by a hurricane. Commented Jul 10 at 17:23
  • It is not possible to grow a figure in both the top and side margins?
    – Roald
    Commented Jul 13 at 13:55
  • It is , but it would look odd. Mostly it is difficult to tell whther you are at the very top, the very bottom, or are filling the whole page. Commented 2 days ago

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .