1

Please look at the following example:

\documentclass[a4paper, landscape, twoside, twocolumn]{book}

\usepackage[a4paper, landscape, twoside, twocolumn, top=0.8cm, bottom=1cm, bindingoffset=1.5cm, inner=6mm, outer=6mm, includemp, includeheadfoot, marginparwidth=3.5cm, marginparsep=4mm, headheight=16pt, showframe=true]{geometry}

\usepackage{floatrow}
\usepackage{blindtext}

\DeclareFloatSeparators{marginparsep}{\hskip\marginparsep}

\floatsetup[figure]{facing=yes, capposition=beside, capbesidewidth=\marginparwidth, capbesideposition={bottom, outside}, capbesidesep=marginparsep, floatwidth=\textwidth, margins=hangoutside}

\begin{document}

\begin{figure}
  \centering
  \rule{3cm}{2cm}
  \caption{This is a needlessly long caption to which runs at least two lines.}
\end{figure}

\blindtext

\newpage% makes a new column

\blindtext

\begin{figure}
  \centering
  \rule{3cm}{2cm}
  \caption{This is a needlessly long caption to which runs at least two lines.}
\end{figure}

\end{document}

This ist a perfect solution for a onecolumn document, there the caption appears in the margin. But if you compile this example you can see that this does not work for a twocolumn document. The caption of the figure in the first column appears in the second column. But it shoud be placed in the left margin.

I know that the following Option

capbesideposition={bottom, outside}

is the problem. But I do not know how to tell floatrow that it has to check in which column the figure is placed.

Do you have any ideas to solve this problem?

Thanks.

1

I'm not sure I understood the document layout that you want ... Like this?

\documentclass[a4paper, landscape, twoside, twocolumn]{book}
\usepackage{graphicx}
\usepackage[a4paper, landscape, twoside, twocolumn, top=0.8cm, bottom=1cm, bindingoffset=1.5cm, inner=6mm, outer=6mm, includemp, includeheadfoot, marginparwidth=3.5cm, marginparsep=4mm, headheight=16pt, showframe]{geometry}
\usepackage{floatrow}
\usepackage{blindtext}

\floatsetup[figure]{margins=hangleft,capposition=beside,
capbesideposition={top,left},floatwidth=\linewidth}

\begin{document}

\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
  \caption{This is the A needlessly long caption to which runs at least two lines.}
\end{figure}

\blindtext
\newpage
\blindtext

\floatsetup[figure]{margins=hangright, capbesideposition={right}}

\begin{figure}
  \centering
\includegraphics[width=\linewidth]{example-image-b}
  \caption{This is the B needlessly long caption to which runs at least two lines.}
\end{figure}
\end{document}

To change the setup automatically you can use \if@firstcolumn in a macro (change the \xxx in the next example by some more meaningful).

\documentclass[a4paper, landscape, twoside, twocolumn]{book}
\usepackage{graphicx}
\usepackage[a4paper, landscape, twoside, twocolumn, top=0.8cm, bottom=1cm, bindingoffset=1.5cm, inner=6mm, outer=6mm, includemp, includeheadfoot, marginparwidth=3.5cm, marginparsep=4mm, headheight=16pt]{geometry}
\usepackage{floatrow}
\usepackage{lipsum}

\floatsetup[figure]{capposition=beside,
capbesideposition={top},floatwidth=\linewidth}

\makeatletter
\def\xxx#1#2{\if@firstcolumn 
\floatsetup[figure]{margins=hangleft, capbesideposition={left}}
\begin{figure}[hbtp]
\centering
\includegraphics[width=\linewidth]{#1}
\caption{#2}
\end{figure}
 \else 
\floatsetup[figure]{margins=hangright, capbesideposition={right}}
\begin{figure}[btp]
\centering
\includegraphics[width=\linewidth]{#1}
\caption{#2}
\end{figure}
 \fi}%
\makeatother

\begin{document}

\xxx{example-image-a}{This is the A needlessly long caption to which runs at least two lines.}
\lipsum[1-2]
\xxx{example-image-b}{This is the B needlessly long caption to which runs at least two lines.}
\lipsum[3-8]
\xxx{example-image-c}{This is the B needlessly long caption to which runs at least two lines.}
\lipsum[9]
\end{document}

mwe

However, this can fail when the float is not moved to the top or bottom of the column but jump to the next column or the next page. One option to solve this case could be move the macro between the text of the column where really will appear, or allow the option h (here) or ... may be use an approach without floats.

  • Note: The site does not accept images at this moment. I will upload it later. – Fran Feb 28 '17 at 19:17
  • Your answer solves this Problem in this special case, but I asked if ther is a way to let floatrow detect on wich column we are at the moment. When there is a huge documet I cannot do this manually for every figure. – user125730 Feb 28 '17 at 20:10
  • I see. This can be solved with \if@firstcolumn. I will edit the answer. – Fran Feb 28 '17 at 23:14
  • OH, thank you. Is there another way to solve this problem? Maybe with another package oder individual definitions? – user125730 Mar 5 '17 at 23:21
  • @user125730 The problem is inherent to the float movement, that is not a bug a essential feature, so I am not aware of some solution for this. Floats seem puzzling at first, but once you understand how they work, you learn to worry about their placement only in the final draft. Then move some figure a few paragraphs or change their options, is only a minor price (and usually unnecessary) . – Fran Mar 6 '17 at 0:11

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.