16

I have a (float) figure that has a ┓-shape, that is there is a huge blank square at the bottom left.

enter image description here

I'd like to put in this blank the caption of the figure. Is there a way?

My class loads caption and floatrow packages, so I need something that works with floatrow.

2

3 Answers 3

4

What about using TikZ and write your caption over the image?

\documentclass{article}
\usepackage{graphicx}
\usepackage{tikz}

\begin{document}
\begin{figure}
    \begin{tikzpicture}
     \node [draw=black, anchor=south west] at (0,0) {\includegraphics[width=\textwidth]{fig1}};

     \node [draw=black, anchor=south west, text width=.3\textwidth] at (0,0) {\caption{A picture of a X.}};
    \end{tikzpicture} 
\end{figure}
\end{document}

A \RawFloats after \begin{figure} solves the problem with floatrow.

2
  • Sorry, but for some reason (?), it does not work with floatrow (which is a requierement).
    – cjorssen
    Oct 16, 2013 at 15:44
  • 3
    Instead of a manual minipage, you can also use text width=.3\textwidth and let TikZ use its internal version of the minipage environment (which is the same for LaTeX). Oct 16, 2013 at 17:10
5

Here's a very basic, feasible implementation that inserts the caption at the desired location:

enter image description here

\documentclass{article}
\usepackage{graphicx}% http://ctan.org/pkg/graphicx
\newsavebox{\graphicsbox}
\begin{document}
\begin{figure}[ht]
  \centering
  \savebox{\graphicsbox}{\includegraphics[width=.7\linewidth]{myfigure}}% Store image
  \leavevmode\rlap{\usebox{\graphicsbox}}% Set image with complete overlap
  \begin{minipage}[b]{.5\wd\graphicsbox}% Insert caption
    \caption{This is my caption. It has a large amount of information, and should
      flow over several lines.}
  \end{minipage}\hspace*{.5\wd\graphicsbox}% Add space to represent figure width
\end{figure}
\end{document}

The image is set in a box \graphicsbox in order to calculate its width. This width is used to measure the minipage and subsequent spacing. A [b]ottom-placement ensures that the caption is stacked vertically as it expands. The alignment of the minipage and surrounding spacing can be changed, of course. For example, to add a \columnsep gap between the caption and the image, use

\begin{minipage}[b]{\dimexpr.5\wd\graphicsbox-\columnsep}% Insert caption
  % <caption>
\end{minipage}\hspace*{\dimexpr.5\wd\graphicsbox+\columnsep}% Add space to represent figure width
4

I made a two-line change to boxhandler's macro \ReciteFigure, and set of few of the package parameters.

\documentclass{article}
\usepackage{floatrow}
\usepackage{caption}
\usepackage{boxhandler}

\makeatletter
\renewcommand\ReciteFigure[6][ht]{%
  \begin{figure}[#1]%
    \begin{\LRFigurePlacement}%
      \let\@makecaption\new@makecaption%
      \setlength\abovecaptionskip{\arabic{abovecaptionskipterm}\p@}%
      \setlength\belowcaptionskip{\arabic{belowcaptionskipterm}\p@}%
        \set@DataBoxWidth{#3}%
        \setlength\CaptionBoxWidth{#4}%
        \set@BoxOffsets%
        \if T#6%
          \rule{\@DataBoxOffset}{0in}%
          \makebox[\@DataBoxWidth][l]{#5}%
          \rule{\@DataBoxOffset}{0in}\\%
        \fi
        \rule{\@DataBoxOffset}{0in}%
        \usebox{#3}%
        \rule{\@DataBoxOffset}{0in}%
        \par%
        \rule{\@CaptionBoxOffset}{0em}%
        \parbox{.5\CaptionBoxWidth}{\bx@caption{#2}}% .5 WAS ADDED
        \hspace{.5\CaptionBoxWidth}%                  THIS LINE WAS ADDED
        \rule{\@CaptionBoxOffset}{0em}%
        \if T#6%
          \rule{\@DataBoxOffset}{0in}\\%
          \makebox[\@DataBoxWidth][r]{#5}%
          \rule{\@DataBoxOffset}{0in}%
        \fi
      \let\@makecaption\old@makecaption%
      \setlength\abovecaptionskip\oldabovecaptionskip%
      \setlength\belowcaptionskip\oldbelowcaptionskip%
    \end{\LRFigurePlacement}%
  \end{figure}%
}
\makeatother

\begin{document}
\setcounter{abovecaptionskipterm}{-80}
\captionStyle{n}{c}
\def\CaptionJustification{\raggedright}
\bxfigure{My caption goes here and may exceed one line}
{\fbox{\rule{2in}{0in}\rule{0in}{2in}}}

\end{document}

enter image description here

1
  • Interesting, thanks. I did not know the boxhandler package. For my use case, I'd like to stick to floatrow.
    – cjorssen
    Oct 16, 2013 at 19:09

You must log in to answer this question.

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