I am trying to combine todonotes with mdframed to create a unifying command that allows to write todos and and highlight paragraphs at the same time. The syntax is \todo[<todo-options>]{<todonote>}<paragraph>, where essentially all arguments are optional (so one could use \todo{<todonote>}, \todo<paragraph> or both together).
I think I have done most of it with the code below, but two issues:
When both
\todoand themdframedenvironment are used, there is an empty line, that I need to manually 'remove' with\vspace{-1\baselineskip}. This has the unwanted side-effect that these two linenumbers are overlapping. How can I avoid this empty line?Because of this issue, the definition of
\todofeels inefficient because I need two instances of themdframedenvironment, one with the the\vspace{}and one without.
How can my solution be improved?
\documentclass{scrartcl}
\usepackage{xparse}
\usepackage{todonotes}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{lineno}
\newmdenv[leftmargin=\dimexpr-0.5em-3pt, innerleftmargin=0.5em,
rightmargin=\dimexpr-0.5em-3pt, innerrightmargin=0.5em,
linewidth=3pt,linecolor=red, topline=false, bottomline=false,
innertopmargin=0pt,innerbottommargin=0pt,skipbelow=0pt,skipabove=0pt,%
]{notex}
\newenvironment{note}%
{\vskip\dimexpr\dp\strutbox-\prevdepth\relax\notex\strut\ignorespaces}%
{\xdef\notetpd{\the\prevdepth}\endnotex\vskip-\notetpd\relax}
\let\oldtodo\todo
\makeatletter%
\DeclareDocumentCommand{\todo}{ O{} +g +d<> }{%
\IfNoValueTF{#2}{\relax}{%
\oldtodo[caption={#2},size=\footnotesize,#1]{\renewcommand{\baselinestretch}{1}\selectfont\sffamily#2\par}%
}%
\IfNoValueTF{#3}{\relax}{%
\IfNoValueTF{#2}{% when parmark but no todo
\begin{note}%
\begin{internallinenumbers}%
\indent%
#3%
\end{internallinenumbers}%
\end{note}%
}{% when parmark and todo
\vspace{-1\baselineskip}%
\begin{note}%
\begin{internallinenumbers}%
\indent%
#3%
\end{internallinenumbers}%
\end{note}%
}%
}%
}%
\makeatother
\begin{document}
\linenumbers
\todo{Lorem Ipsum is simply dummy text of the printing and
typesetting industry}Lorem Ipsum is simply dummy text of the
printing and typesetting industry. Lorem Ipsum has been the
industry's standard dummy text ever since the 1500s, when an
unknown printer took a galley of type and scrambled it to make a
type specimen book.
Lorem Ipsum is simply dummy text of the printing and typesetting
industry. Lorem Ipsum has been the industry's standard dummy text
ever since the 1500s, when an unknown printer took a galley of type
and scrambled it to make a type specimen book.
\todo{Todonote}<Lorem Ipsum is simply dummy text of the printing
and typesetting industry. Lorem Ipsum has been the industry's
standard dummy text ever since the 1500s, when an unknown printer
took a galley of type and scrambled it to make a type specimen
book.>
Lorem Ipsum is simply dummy text of the printing and typesetting
industry. Lorem Ipsum has been the industry's standard dummy text
ever since the 1500s, when an unknown printer took a galley of type
and scrambled it to make a type specimen book.
\todo<Lorem Ipsum is simply dummy text of the printing and
typesetting industry. Lorem Ipsum has been the industry's standard
dummy text ever since the 1500s, when an unknown printer took a
galley of type and scrambled it to make a type specimen book.>
\end{document}

