# Latex: is is possible to have a marginnote with a leading line and both in and outside a float environment?

I do not have an example since I want to know if it is possible, here is the one from the wiki slightly modified.

\documentclass[a4paper,twoside,english]{article}
\usepackage{lmodern}
\renewcommand{\sfdefault}{lmss}
\usepackage[T1]{fontenc}

\makeatletter

\usepackage{lipsum}
\usepackage{marginnote}
\usepackage[top=1.5cm, bottom=1.5cm, outer=5cm, inner=2cm, heightrounded, marginparwidth=2.5cm, marginparsep=2cm]{geometry}

\makeatother

\usepackage{babel}
\begin{document}

\section{Margin notes}

This is just random text, but random text that is not randomly typed since that would not make sense. This location\marginnote{is where I would like to have a line leading to from this margin note}. Random text.
\end{document}


My objective is to have a line connecting the location word or the space after it to the margin note, so that there is a quick way to relate it to the margin note, a footnote does not solve my issue since it would reduce the vertical space of the template that I need to use.

I believe that if it is not possible to have a line doing the linking, a valid possibility would be to just have a numbered reference similar to the pair \label and \ref.

Thanks in advance! Best, Carlos

Edit Thanks to @samcarter I was able to use:

usepackage[backgroundcolor=white,linecolor=red,bordercolor=none]{todonotes}


To solve my question, however, this implementation breaks while inside a float (specifically a figure), I tried in the caption and got a "not in par mode" error, anyone got an idea for that?

Thanks again!

• Maybe the todonotes package could help – user36296 Oct 29 '18 at 16:22
• @samcarter Thanks a lot! I was able to get what I wanted using \usepackage[backgroundcolor=white,linecolor=red,bordercolor=none]{todonotes} – CMichael Oct 29 '18 at 16:36
• unrelated but it's best not to use \special{papersize=\the\paperwidth,\the\paperheight} (makes the document non portable, doesn't work with pdflatex for example) – David Carlisle Oct 29 '18 at 16:38
• @CMichael Good to hear you were able to solve your problem! It would be nice if you could add a short answer below so that future users with the same question can benefit from your solution. – user36296 Oct 29 '18 at 16:39
• todonotes uses internally \marginpar which doesn't work in a figure. If you don't need \marginpar you could do \let\marginpar\marginnote. Then it should work. – Ulrike Fischer Oct 29 '18 at 17:10

## 1 Answer

Credits to the ones who gave the answers:

@samcarter for the todonotes package information. I implemented in my document as:

\usepackage[backgroundcolor=white,linecolor=red,bordercolor=none]{todonotes}


Across the document I call it as:

\todo{Text}


@Ulrike Fischer for the "\let\marginpar\marginnote". I'm using it inside the figure environment and it worked perfectly.

\begin{figure}
\let\marginpar\marginnote
\todo[size=\scriptsize]{This is my todo note}
\centering
\includegraphics[width=0.5\linewidth]{Image.png}
\caption{Caption}
\label{fig:my_label}
\end{figure}