4

I have used the 'cleveref' package for a large document. It contains a lot of (tikz) figures and the 'scrreprt' class is used.

\documentclass[a4paper, onecolumn, twoside, openright, titlepage, DIV=calc, BCOR=1cm, headinclude=false,footinclude=false, draft, captions=topbeside]{scrreprt}

I'd like to place figure captions in outer margins of the pages. I tried to use the 'floatrow' package and the 'captionbeside' environment for this purpose.

KOMA-Script and sidenotes : how to format side (margin) caption and its caption label?

'cleveref' can not recognise the labels of figures and tables anymore afterwards. I can guess that this is related to some kind of changed 'labelling' but am not able to find a solution.

Would you please advice me on how to address this issue?

Chr.

EDIT: I have added this example:

\documentclass[captions=topbeside]{scrreprt}

\usepackage{graphicx}
\usepackage{cleveref}

\begin{document}
\begin{figure}[!htb]
\begin{captionbeside}{caption1}
[o]{\includegraphics[width=3cm]{example-image-a}}
\end{captionbeside}\label{fig:fig_1}
\end{figure}

\begin{figure}[!htb]
\begin{captionbeside}{caption2}
[o]{\includegraphics[width=3cm]{example-image-a}}
\end{captionbeside}\caption{caption2}\label{fig:fig_2}
\end{figure}

\begin{figure}[!htb]
\includegraphics[width=3cm]{example-image-a}
\caption{caption3}\label{fig:fig_3}
\end{figure}

\cref{fig:fig_1}, \cref{fig:fig_2}, \cref{fig:fig_3}.
\end{document}
  • 4
    Welcome to TeX.SE. Many thanks for listing all options being passed to the document class. To really diagnose what's going on, let alone provide a fix, it would be most helpful if you provided an MWE that generates the problem behavior you've encountered. – Mico Aug 6 '16 at 13:42
  • I encountered the same problem when using the tufte classes several years back. – JPi Aug 6 '16 at 14:57
  • I added an example. \ref{} can access the 'hidden' (for \cref{}) 'counter'. – user111486 Aug 6 '16 at 15:32
5

Setting the label in the caption argument works for me:

\begin{captionbeside}
  {caption1\label{fig:fig_1}}

Here is a twosided example, but I am not sure how the pictures and the captions should be positioned:

\documentclass
  [
    captions=topbeside,
    twoside
  ]
  {scrreprt}

\usepackage{graphicx}
\usepackage{cleveref}

\usepackage{etoolbox}
\BeforeBeginEnvironment{captionbeside}{%
  \setcapindent*{0pt}%
  \ifthispageodd
    {\addtokomafont{caption}{\raggedright}}
    {\addtokomafont{caption}{\raggedleft}}%
}


\usepackage{lipsum}% dummy text
%\usepackage{showframe}% shows the page layout

\begin{document}
\chapter{A chapter}
\lipsum[1]
\begin{figure}[htb]
  \setcapindent*{0pt}
  \begin{captionbeside}
    {caption1\label{fig:fig_1}}
    [o]
    [\dimexpr\textwidth+\marginparwidth+\marginparsep\relax]
    [0pt]*
    \raisebox
      {\dimexpr\ht\strutbox-\totalheight\relax}
      {\makebox
        [\textwidth]
        [c]
        {\includegraphics[width=3cm]{example-image-a}%
      }%
    }
  \end{captionbeside}
\end{figure}

\begin{figure}[!htb]
\begin{captionbeside}
  {caption2\label{fig:fig_2}}
  [o]
  \includegraphics[width=3cm]{example-image-a}
\end{captionbeside}
\end{figure}


\cref{fig:fig_1}, \cref{fig:fig_2}, \cref{fig:fig_3}.

\clearpage
\lipsum[1]
\begin{figure}[htb]
  \setcapindent*{0pt}
  \begin{captionbeside}
    {caption1\label{fig:fig_3}}
    [o]
    [\dimexpr\textwidth+\marginparwidth+\marginparsep\relax]
    [0pt]*
    \raisebox
      {\dimexpr\ht\strutbox-\totalheight\relax}
      {\makebox
        [\textwidth]
        [c]
        {\includegraphics[width=3cm]{example-image-a}%
      }%
    }
  \end{captionbeside}
\end{figure}
\end{document}

Note that \ifthispageodd may need two runs.

Result:

enter image description here

enter image description here

  • @user111486: Instead of saying thank you consider to accept this answer and upvote it (you've more than 15 rep, you can upvote by now!) – user31729 Aug 6 '16 at 21:26

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.