I would like to have the same behaviour using a command of the pdfcomment package (or other package).

My problem is, that pdfcomment in some cases adds vertical space in the text.

\documentclass{article}
\usepackage{pdfcomment}
\begin{document}
\section{Section 1 Title}
\begin{itemize}
\item additional vertical space above :-(
\end{itemize}

\section{Section 2 Title}

\begin{itemize}
\item normal vertical space above :-)
\end{itemize}
\end{document}


Macro \pdfmargincomment takes up no space when it is placed beside something, but itemize does not like to be beside anything. In fact it adds \par if it doesn't start in vertical mode.

If you put the itemize inside a minipage, then one can put the \pdfmargincomment beside the minipage.

\documentclass{article}
\usepackage{pdfcomment}
\begin{document}
\section{Section 1 Title}
\begin{minipage}[t]{\textwidth}
\begin{itemize}
\item additional vertical space above :-(
\end{itemize}
\end{minipage}

\section{Section 2 Title}

\begin{itemize}
\item normal vertical space above :-)
\end{itemize}
\end{document}


• OK, you say: there is no simple solution that fits to all cases. Thank you. – Tobias Jul 27 '16 at 21:31
• \marginpar{\pdfcomment{Hello}} seems to be more robust than \pdfmargincomment{Hello} if you place it between \section{test1} and \subsection{test2} e.g. – Tobias Jul 27 '16 at 22:12
• i believe \pdfmargincomment uses a \tikzmark while \marginpar doesn't. OTOH, there are places you cannot use \marginpar either. – John Kormylo Jul 27 '16 at 22:28