7

The sidenotes package works pretty well, but I cant find a way to use the figure* environment. When I try:

 \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}
\caption{Este é um sidecaption.}
\end{figure*}
\end{document}

I get:

<fig.png, id=1, 2248.4pt x 1585.925pt> <use fig.png>
! TeX capacity exceeded, sorry [grouping levels=255].
\caption@addtofont #1#2->\begingroup 
                                     \expandafter \let \expandafter \caption...
l.17 \end
         {figure*}
!  ==> Fatal error occurred, no output PDF file produced!
Transcript written on teste.log.

with:

pdflatex teste.tex

In order for that to become a MWE, just remove the caption within the figure* environment.

  • What am I doing wrong?
lf_araujo
  • 801
  • 1
  • 8
  • 22
  • Use \ includegraphics {example-image-a} to include an image. Of all the ways to remove the lines from the figure, I can not compile your file. Give the error:! Missing number, treated as zero. \ Tex_let: D... Apparently the package is broken with the updated versions of ltx3 – Pablo González L Feb 19 '17 at 05:19
  • Without the figure * environment you can not compile either \documentclass{article} \usepackage{sidenotes} \begin{document}

    Noice content \sidenote{note}

    \end{document}

    – Pablo González L Feb 19 '17 at 05:26
  • The figure* environment comes with the sidenote package.. – lf_araujo Feb 19 '17 at 05:34
  • figure* does not make the difference, I have updated my version of TexLIve 2017 and commenting on those lines the file can not be compiled – Pablo González L Feb 19 '17 at 06:04
  • I just tested here 'figure*' does make a difference. Are you sure you removed the \caption as suggested in the text? My pdflatex is running `pdfTeX 3.14159265-2.6-1.40.17 (TeX Live 2016/Arch Linux)'. Maybe that is related to the system I am running it in. The exact figure I am using is here. – lf_araujo Feb 19 '17 at 06:18
  • I think you should send an email to the author with the link to the solution proposed by @egreg – Pablo González L Feb 19 '17 at 16:20

2 Answers2

7

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.

egreg
  • 1,121,712
  • 2
    Is there any easier way (from a regular user point of view) to set that value in a clean L3 way? – Johannes_B Feb 19 '17 at 10:59
  • For example \title{Wombat} for \maketitle. What is the L3 approach here? – Johannes_B Feb 19 '17 at 11:01
  • 1
    @Johannes_B I don't think that there are details on how the document level of L3 will look like. But I could imagine a keyval like setup: \setdocumentproperties{ title = Wombat } – cgnieder Feb 19 '17 at 11:13
  • @Johannes_B as far as \@sidenotes@multisign is concerned: this is an internal marker for the package which in L3 on the code level should be something like \l__sidenotes_multisign_dim and not be set by a user at all… – cgnieder Feb 19 '17 at 11:41
  • @Clemens How about a string i need to reuse? \documentclass{article}

    \usepackage{xparse}

    \newcommand{\foo}{foo}

    \NewDocumentCommand{\Foo}{}{foo}

    \begin{document} \MakeUppercase{\foo}% Wird expandiert

    \MakeUppercase{\Foo}% Nicht expandiert!

    \end{document}

    – Johannes_B Feb 19 '17 at 11:50
  • @Johannes_B you mean if you as a document author want to program something yourself? I haven't put much thought into that. But I'd imagine an implementation in expl3 on the code level and a proper document interface command that makes it unnecessary to use the variable itself after \begin{document} like in many examples here in tex.sx… in an ideal world a document author wouldn't need to do such things at all, though. – cgnieder Feb 19 '17 at 11:57
  • @clemens \renewcommand{\chapterpagestyle}{headings} for example. Or resetting of headers/footers? It is common to change that stuff mid-document. Unfortunately, i still have T 15, so i cannot do any testing right now. – Johannes_B Feb 19 '17 at 12:00
  • @clemens It's also a very bad idea to redefine figure* and table* to do very different things from what they're supposed to do in the standard setup. – egreg Feb 19 '17 at 12:06
  • @Johannes_B but this is common in L2e. In L3 the syntax will probably rather be along the lines of \setdocumentproperties{ chapter-page-style = headings }. But we shouldn't dsicuss this in the comment section here :) – cgnieder Feb 19 '17 at 12:07
  • @egreg fully agreed! – cgnieder Feb 19 '17 at 12:08
6

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}
David Carlisle
  • 757,742