2

float side by side

Hello everyone. When I want to place float side by side in Lyx,which is shown in the picture, I need to add a float-figure first, then add two box, and a(maybe three)\hfill, which is very inconvenient. Is there a simple way to do this in Lyx, so I can only press one or two bottom?

Thanks!

PS: I don't want to use ERT, I want the method that is simpler than I describe above, and can preview the image in Lyx like in the picture.

Thank you!

2 Answers2

2

May be you want this (captions aligned and images top-aligned)?

\documentclass[11pt,a4paper]{book}
\usepackage[utf8]{inputenc} %
\usepackage{geometry}
\usepackage{floatrow, graphicx}

\begin{document}

\begin{figure}[!ht]
\floatsetup{style=plain, floatrowsep=qquad, heightadjust=object, valign=t, captionskip=2.5ex}
\begin{floatrow}
\ffigbox[\FBwidth]{\caption{Float 1 on the left side}\label{flt1}}
{\includegraphics[scale=0.6]{pepe-le-pew1}}
\ffigbox[\FBwidth]{\caption{Float 2 on the right side}\label{flt2}}
{\includegraphics{pepe-le-pew2}}
\end{floatrow}
\end{figure}

\end{document} 

enter image description here

Bernard
  • 271,350
0

For example:

\documentclass[a5paper]{report}
\usepackage{graphicx}
\usepackage{caption}
\captionsetup{format=hang}
\begin{document}
\setcounter{chapter}{3}
\begin{figure}
  \begin{minipage}[t]{.5\dimexpr\linewidth-\columnsep\relax}
    \kern0pt
    \centering
    \scalebox{6}{$\infty$}
    \caption{This float is on the left side}
  \end{minipage}\hfill
  \begin{minipage}[t]{.5\dimexpr\linewidth-\columnsep\relax}
    \kern0pt
    \centering
    \includegraphics[width=\linewidth]{example-image-a}
    \caption{This float is on the right side}
  \end{minipage}
\end{figure}
\end{document}

Result

The top alignment is achieved by option t of the minipages together with \kern0pt as first element. Option t aligns at the baseline for the first line/element in the minipage. It would be the symbol and the image, if \kern0pt is not given.

The hanging format of the caption text is realized by package caption with option format=hang.

The width for the minipages are calculated via eTeX's \dimexpr. \linewidth is set to the current line width both inside the float environment and inside the minipages.

Heiko Oberdiek
  • 271,626