3

I really need to use \marginpar like in the following code:

\documentclass[11pt,a4paper,twoside,openright]{book}

\usepackage{graphicx}
\usepackage{caption}
\usepackage{lipsum}

\begin{document}

Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. 
Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer 
id, vulputate a, magna. Donec vehicula augue eu neque.

\begin{minipage}{\linewidth}
\centering
\includegraphics[width=0.5\textwidth]{RedArrow.png}
\captionof{figure}{Ut purus elit, vestibulum ut, placerat ac, adipiscing 
vitae\marginpar{Lorem ipsum \ref{fig:RedArrow} dolor sit amet, consectetuer 
adipiscing elit.}, felis. Cur- Lorem ipsum dolor sit amet, consectetuer 
adipiscing elit.}
\label{fig:RedArrow}
\end{minipage}

\end{document}

But I just get errors. What can I do?

  • 1
    Welcome to TeX.SX! To remove the ! Argument of \caption@ydblarg has an extra } error, you just put \protect in front of \marginpar (see this). But then another error comes up: ! LaTeX Error: Not in outer par mode, which is intentionally programmed in \marginpar, so I don't think it's possible to do what you want without changing \marginpar... See if this answer solves your problem. – Phelype Oleinik May 23 '18 at 23:15
  • Smells like an XY problem. I suggest you tell us what you really need to do and not the way you think you need to do it, because the former is very likely possible, whereas the latter is very likely impossible. What you think you need ain't going to work, but what you actually need probably would. Not knowing what you're trying to do, it's hard to suggest much more than trying not to really need it. – cfr May 23 '18 at 23:49
  • @PhelypeOleinik, @cfr: Thanks for your answers. I saw the link, but it uses a figure block. I am using a minipage block in order to put the figure and its caption aligned within an item inside an itemize block. The figure block seems to align the figure and its caption within the page width... Look this – MaribuS May 24 '18 at 1:41
  • If you use the short caption (add [] after {figure}) you get the more normal error message, "Not in outer par mode." Which you aren't, inside a minipage. Try marginnotes instead. – John Kormylo May 24 '18 at 14:47
  • Thanks, I will try marginnotes. I hope that it works... – MaribuS May 26 '18 at 22:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.