1

I often want to include a small figure in the margin to illustrate a point in the main text.

To do this I am using scrlayer-notcolumn in with komascript. In particular the \makenote* macro because that is robust, which is required e.g. if they images are being created using tikz.

I'm also using captionof from the caption package, to have captions outside of floats.

I am using cleveref to do my references to figures.

My images an there captions are showing up fine. However, when I put in a \Cref{fig:myfig} for a label that is in a makenote, it never works, only displaying ??. Plain-old \ref works fine however

Example code:

\documentclass{scrartcl}
\usepackage{scrlayer-scrpage}
\usepackage{scrlayer-notecolumn}
\usepackage[demo]{graphicx}
\usepackage{caption}
\usepackage{cleveref}



\begin{document}

\section{start}

Do not forget  to consider the image in \Cref{fig:foo} or \Cref{fig:bar}.
Or more plainly Figure \ref{fig:foo} or Figure \ref{fig:bar}

\begin{minipage}{\textwidth}
    \includegraphics{dummy}
    \captionof{figure}{Here is the inline figure caption}
    \label{fig:foo}
\end{minipage}

\makenote*{
    \includegraphics{dummy}
    \captionof{figure}{Here is the side figure caption}
    \label{fig:bar}
}
\end{document}

Output (after 2+ builds with pdflatex): the output note the ?? marks

2

scrlayer-notecolumn restores in the \label after a \makenote command to the version it has found after loading the package, this is the \label - version before cleveref changed it -- this way, cleveref can't write cross-referencing information to the .aux file and does not store its own label version; Neither \cref nor \Cref can find anything useful to work with and display ??.

A possible (perhaps the quickest) solution is to load scrlayer-notecolumn after cleveref, making it one of the rare packages that should be loaded last.

\documentclass{scrartcl}
\usepackage{scrlayer-scrpage}
\usepackage[demo]{graphicx}
\usepackage{caption}
\usepackage{cleveref}
\usepackage{scrlayer-notecolumn}




\begin{document}

\section{start}

Do not forget  to consider the image in \Cref{fig:foo} or \Cref{fig:bar}.
Or more plainly Figure \ref{fig:foo} or Figure \ref{fig:bar}

\begin{minipage}{\textwidth}
    \includegraphics{dummy}
    \captionof{figure}{Here is the inline figure caption}
    \label{fig:foo}
\end{minipage}

\makenote*{
    \includegraphics{dummy}
    \captionof{figure}{Here is the side figure caption}
    \label{fig:bar}
}
\end{document}

enter image description here

  • hyperref -- last, cleveref -- laster, scrlayer-notecolumn -- lastest – Lyndon White Oct 16 '17 at 5:49
  • hmm, this is a problem. I am loading scrlayer-notecolumn inside my (custom) document class, but I am loading cleverref inside the document using usepackage. – Lyndon White Oct 16 '17 at 5:54
  • @LyndonWhite: Try \RequirePackage{etoolbox} and then say \AtEndPreamble{\RequirePackage{scrlayer-notecolumn}} and put the code related to that also there. This way you should be able to load cleveref before scrlayer-notecolumn. – user31729 Oct 16 '17 at 11:40
  • Awesome, I just used this in my document and it is all working now. Not only that, but I can also use hyperref again, which I see now was broken for the same reason – Lyndon White Oct 17 '17 at 6: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.