2

I have some L shaped SCfigure. Is there a way to optimize the figure caption position? The space where the caption could extend is marked with a star in the example below.

enter image description here

Here's the relevant MWE

\documentclass{article}

\usepackage{tikz}
\usepackage{sidecap}

\usepackage{lipsum}

\begin{document}
\lipsum[1-3]

\begin{SCfigure}
\begin{tikzpicture}
    \fill (0,0) -- ++(6,0) -- ++(0,-1) -- ++(-2,0) -- ++(0,-2) -| cycle;
    \node at (5,-2) {$\star$};
\end{tikzpicture}
\caption{Some caption that is not placed optimally}
\end{SCfigure}
\end{document}
| improve this question | | | | |
3

You can use the floatrow package instead of sidecap. We have to declare a new separator between the figure and its beside caption. As such separators, in floatrow syntax, are just keywords to be defined in preamble, I introduce a \mysep length to be able to dynamically change the separator mid document. Here is how it goes:

\documentclass{article}

\usepackage{tikz}
\usepackage{sidecap}
\usepackage[capbesideposition =outside]{floatrow}
\newlength\mysep
\setlength\mysep{0em}% default equivalent to capbesidesep=none
\DeclareFloatSeparators{mysep}%
{\hskip\mysep}

\usepackage{lipsum}

\begin{document}

\lipsum[1]

\begin{figure}[!h]%
\thisfloatsetup{capbesidesep =mysep}%
\setlength\mysep{-6em}
  \fcapside{%
\begin{tikzpicture}
    \fill (0,0) -- ++(6,0) -- ++(0,-1) -- ++(-2,0) -- ++(0,-2) -| cycle;
    \node at (5,-2) {$\star$};
\end{tikzpicture}}{\caption{Some caption that is not placed optimally}}
\end{figure}

\lipsum[2]

\begin{figure}[!h]%
\thisfloatsetup{capbesidesep =mysep}%
  \fcapside{%
\begin{tikzpicture}
    \fill (0,0) -- ++(6,0) -- ++(0,-1) -- ++(-2,0) -- ++(0,-2) -| cycle;
    \node at (5,-2) {$\star$};
\end{tikzpicture}}{\caption{Some caption that is not placed optimally}}
\end{figure}

\end{document} 

enter image description here

| improve this answer | | | | |
  • you should comment \usepackage{sidecap}. Is there a way to determine automatically the negsep? Because it could vary dynamically between the figures... – s__C Aug 14 '14 at 6:51
  • @s__c: see my updated answer. – Bernard Aug 14 '14 at 8:59

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.