Todo notes: Vertical position

todonotes

In the below MWE, is there a way to play with the vertical position of the side note? For example, I would like to move it up, making it more side-by-side with the first paragraph.

\documentclass{article}
    
\usepackage[
    showframe,%
    paperwidth=45pc,%
    paperheight=45pc,%
    margin=5pc,%
    bottom=7pc,
    right=15pc,
    %   top=7pc,
    marginparwidth=10pc,%
    %outer=14pc%
    ]{geometry}

\usepackage{libertine}
\usepackage{todonotes}
  
\begin{document}

Lorem ipsum dolor sit amet, consectetur adipiscing 
elit, sed do eiusmod tempor incididunt ut labore et 
dolore magna aliqua. Id cursus metus aliquam eleifend mi 
in. Feugiat pretium nibh ipsum consequat nisl vel pretium 
lectus. Egestas pretium aenean pharetra magna ac placerat 
vestibulum lectus.

\todo{I want this to move up where the paragraph begins.}
    
Integer malesuada nunc vel risus commodo. Lobortis 
elementum nibh tellus molestie nunc non blandit. Et 
molestie ac feugiat sed. Scelerisque mauris pellentesque 
pulvinar pellentesque habitant morbi tristique. Sed 
vulputate odio ut enim blandit volutpat maecenas volutpat 
blandit. Cras fermentum odio eu feugiat pretium nibh 
ipsum. Neque viverra justo nec ultrices dui sapien eget mi. 

\end{document}

enter image description here

Best Answer

You can redefine the tikzstyle that todonotes uses for the notes to add an yshift parameter. Setting this parameter before the note then determines the vertical position.

MWE:

\documentclass{article}
    
\usepackage[
    showframe,%
    paperwidth=45pc,%
    paperheight=45pc,%
    margin=5pc,%
    bottom=7pc,
    right=15pc,
    %   top=7pc,
    marginparwidth=10pc,%
    %outer=14pc%
    ]{geometry}

\usepackage{libertine}
\usepackage{todonotes}

% style definition copied from todonotes manual
\makeatletter
\tikzstyle{notestyleraw} = [
draw=\@todonotes@currentbordercolor,
fill=\@todonotes@currentbackgroundcolor,
text=\@todonotes@currenttextcolor,
line width=0.5pt,
text width = \@todonotes@textwidth - 1.6 ex - 1pt,
inner sep = 0.8 ex,
rounded corners=4pt,
yshift=\myshift]% added this line
\makeatother

\begin{document}

Lorem ipsum dolor sit amet, consectetur adipiscing 
elit, sed do eiusmod tempor incididunt ut labore et 
dolore magna aliqua. Id cursus metus aliquam eleifend mi 
in. Feugiat pretium nibh ipsum consequat nisl vel pretium 
lectus. Egestas pretium aenean pharetra magna ac placerat 
vestibulum lectus.\def\myshift{15mm}\todo{I want this to move up where the paragraph begins.}
    
Integer malesuada nunc vel risus commodo. Lobortis 
elementum nibh tellus molestie nunc non blandit. Et 
molestie ac feugiat sed. Scelerisque mauris pellentesque 
pulvinar pellentesque habitant morbi tristique.\def\myshift{0mm}\todo{no shift for this one} Sed 
vulputate odio ut enim blandit volutpat maecenas volutpat 
blandit. Cras fermentum odio eu feugiat pretium nibh 
ipsum. Neque viverra justo nec ultrices dui sapien eget mi. 

\end{document}

Result:

enter image description here