[Tex/LaTex] Sidecaption figure caption placement

sidecap

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}

Best Answer

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

Related Question