Sidenotes package, can't solve TeX capacity exceeded, sorry [grouping levels=255]

It's a bug in sidenotes.sty that does

\NewDocumentCommand \@sidenotes@multisign { } {3sp}

which is conceptually wrong, as \@sidenotes@multisign is used in expandable context.

It's also wrong to do \renewcommand{\caption}{\sidecaption}, because it either makes caption into not working at all or creates an infinite loop.

\documentclass{article}
\usepackage{sidenotes}
\usepackage{graphicx}

\renewcommand{\footnote}{\sidenote}

\makeatletter
\ExplSyntaxOn
\tl_set:Nn \@sidenotes@multisign {3sp}
\ExplSyntaxOff
\makeatother

\begin{document}
\section{Title}\label{title}

Noice content. \sidenote{Sidenote}

\begin{figure*}
\centering
\includegraphics[]{example-image}
\sidecaption{Este é um sidecaption.}
\end{figure*}
\end{document}

Actually, the package should be thoroughly rewritten.


It does warn you that something will go wrong:

Package caption Warning: \caption will not be redefined since it's already
(caption)                redefined by a document class or package which is
(caption)                unknown to the caption package.
See the caption package documentation for explanation.

and then it does go wrong.

In general if you load two attempts to redefine the same command then things will break: you are loading caption package and then redefine \caption by hand.

Just use \sidecaption

 \documentclass{article}
 \usepackage{sidenotes}
 \usepackage{graphicx}
 \renewcommand{\footnote}{\sidenote}
 %\renewcommand{\caption}{\sidecaption}


\begin{document}
\section{Title}\label{title}

Noice content. \sidenote{Sidenote}

\begin{figure*}
\centering
\includegraphics[]{fig.png}
\sidecaption{Este é um sidecaption.}
\end{figure*}
\end{document}

Tags:

Sidenotes