Based on the two examples here, the inline form of \todo
is modified to allow truly inline todos. However, if the \todo
is on a line by itself, a Bad space factor (0).
error is generated (sometimes, see code below). Is there a way to have the command work in either context?
\documentclass[12pt]{article}
\usepackage[colorinlistoftodos]{todonotes}
%%%
%%% https://tex.stackexchange.com/questions/329701/todonotes-how-to-make-literally-inline-notes-without-line-breaks
%%%
\makeatletter
\tikzstyle{inlinenotestyle} = [
draw=\@todonotes@currentbordercolor,
fill=\@todonotes@currentbackgroundcolor,
line width=0.5pt,
inner sep = 0.8 ex,
rounded corners=4pt]
\renewcommand{\@todonotes@drawInlineNote}{%
{\begin{tikzpicture}[remember picture,baseline=(current bounding box.base)]%
\draw node[inlinenotestyle,font=\@todonotes@sizecommand, anchor=base,baseline]{%
\if@todonotes@authorgiven%
{\noindent \@todonotes@sizecommand \@todonotes@author:\,\@todonotes@text}%
\else%
{\noindent \@todonotes@sizecommand \@todonotes@text}%
\fi};%
\end{tikzpicture}}}%
\newcommand{\mytodo}[1]{\@todo[inline]{#1}}%
\makeatother
\begin{document}
This is \todo[inline]{fine}.
The following breaks if the line above is commented out.
\todo[inline]{a test}
\end{document}
\leavevmode\todo[inline]{a test}
(but it looks like a bug in todonotes placing of@esphack
I think. (incidentally you are defining\mytodo
but not using it