1

I'm new in latex,I'm tryin to create a framed float with subfigures and a long text caption that is in line with the text ( does not slide out of the margins)

I've followed so far the following refereces, but so far my attempts were abortive.

The added figure is a scheme of what I'm trying to create.

please keep it simple........

here is what I've done so far:

\documentclass[a4paper,fleqn,12pt]{article}
\usepackage[hypcap]{caption}
\usepackage{graphicx,subfig}
\usepackage[heightadjust=all,valign=c]{floatrow}
\usepackage{fr-subfig}
\usepackage{framed}

\begin{document}

%\title{Facing and obstacle}
%\maketitle

\thisfloatsetup{subfloatrowsep=qquad,style=BOXED}
\begin{figure}[!htbp]
\captionsetup{justification=centering,textfont=small}
\ffigbox{%
\begin{subfloatrow}[3]%
\ffigbox[\FBwidth]{\caption{sub figure a}\label{fig:a}}{%
\includegraphics[height=.25\textheight]{example-image-a}}
\ffigbox[\FBwidth]{\caption{sub figure b}\label{fig:b}}{%
\includegraphics[height=.25\textheight]{example-image-a}}
\end{subfloatrow}
\begin{subfloatrow}
\ffigbox[\FBwidth]{\caption{sub figure c}\label{fig:c}}{%
\includegraphics[height=.25\textheight]{example-image-a}}
\ffigbox[\FBwidth]{\caption{sub figure d}\label{fig:d}}{%
\includegraphics[height=.25\textheight]{example-image-a}}
\end{subfloatrow}%
\begin{subfloatrow}
\end{subfloatrow}
}{%
\caption[Long caption figure]{very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font  \label{fig:x}}%
    }
\end{figure}
 \end{document}

enter image description here

  • 2
    Please add a minial working example. Show, that you have tried to solve the problem on your own. – Peter Ebelsberger May 2 '16 at 12:48
  • @PeterEbelsberger, added – jarhead May 2 '16 at 12:56
  • First, your figure is too wide for the page. Second, floatrow is redefining \caption to \smash the contents somehow. If you measure the total height of the caption it will be reported as 7.73pt. You can do all this without floatrow, fr-subfig or subfig. – John Kormylo May 2 '16 at 14:22
1

Your image only showed the one frame. Additional frames can be created using \fbox and minipage in exactly the same way as the first one.

\documentclass[a4paper,fleqn,12pt]{article}
\usepackage[hypcap]{caption}
\usepackage{graphicx}
\usepackage{subcaption}% bundled with caption

\begin{document}

%\title{Facing and obstacle}
%\maketitle

\begin{figure}[!htbp]
\captionsetup{textfont=small}
\fbox{\begin{minipage}{\dimexpr \textwidth-2\fboxsep-2\fboxrule}
\centering
\begin{subfigure}[b]{0.4\textwidth}
\includegraphics[width=\textwidth]{example-image}
\caption{sub figure a}\label{fig:a}
\end{subfigure}\hfil
\begin{subfigure}[b]{0.4\textwidth}
\includegraphics[width=\textwidth]{example-image}
\caption{sub figure b}\label{fig:b}
\end{subfigure}\par
\begin{subfigure}[b]{0.4\textwidth}
\includegraphics[width=\textwidth]{example-image}
\caption{sub figure c}\label{fig:c}
\end{subfigure}\hfil
\begin{subfigure}[b]{0.4\textwidth}
\includegraphics[width=\textwidth]{example-image}
\caption{sub figure d}\label{fig:d}
\end{subfigure}\par
\caption[Long caption figure]{very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font very long text with small font  \label{fig:x}}%
\end{minipage}}
\end{figure}
 \end{document}
  • very good solution, neat and simple, I would remove the justification=centering though. – jarhead May 2 '16 at 15:13
  • I agree. (Three more words.) – John Kormylo May 2 '16 at 19:05

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.