# pdfcomment within command swallowing last character of argument

Hey fellow TeXnicians,
I've been having some trouble integrating pdfcomment with a custom command that I've written. No matter how simple the command, it seems that pdfcomment swallows the last character of the arguments I pass to it. A minimal reproduction case would include something like this in its preamble:

\newcommand{\todoComment}[1]{\pdfmarkupcomment[markup=Highlight]{#1}{#1}}


...and something like this in its body...

\todoComment{gradual}


...and produce output something like this:

Invoking \pdfmarkupcomment normally in the body text does not create a similar problem.

The only thing I've found that causes the final character of the passed-in string to render is leaving a full space after #1---wrapping the argument in braces causes LaTeX to throw an error, and adding \xspace is ineffectual. As solutions go it's not the worst, and I can certainly live with it. But I'd be curious to know whether anyone has insight into what-all's going on. I've been using LaTeX for years, but this one's got me pretty much stumped.

• Welcome to TeX.SX! Please make life easier for us by providing a small complete document (starting with \documentclass and ending with \end{document}) that we can compile and experiment with. – gernot Nov 15 '16 at 11:33

Using this MWE,

\documentclass{article}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage{bera}
\usepackage{pdfcomment}
\newcommand{\todoComment}[1]{\pdfmarkupcomment[markup=Highlight]{#1}{#1}}
\pdfminorversion=3
\begin{document}

\end{document}


I get the following result:

In mwe.pdf you will find:

3 0 obj
<<
/Type /Annot
/Subtype /Highlight /C [0 0 1] /CreationDate (D:20161115180801+0000) /M (D:20161115180801+0000) /CA 1.0 /T () /Subj () /Contents (gradual) /Open false /QuadPoints [148.71194 664.93233 183.80598 664.93233 148.71194 654.18423 183.80598 654.18423] /F 4
/Rect [148.712 657.235 148.712 657.235]
>>
endobj
4 0 obj
<<
/Type /Annot
/Subtype /Highlight /C [0 0 1] /CreationDate (D:20161115180801+0000) /M (D:20161115180801+0000) /CA 1.0 /T () /Subj () /Contents (gradual) /Open false /QuadPoints [148.71194 652.3794 183.80598 652.3794 148.71194 641.6313 183.80598 641.6313] /F 4
/Rect [148.712 644.682 148.712 644.682]
>>
endobj


There's definitively gradual as PDF annotation content! Besides the positions, both methods produce the same code. So, probably a problem with your PDF viewer! I'm using Win10/AR!

• What a colossal facepalm. I opened up my example in Acrobat and everything looked fine. That'll teach me to trust anything Preview dot app says about the state of the world. Thanks so much for investigating! – Daniel P. Shannon Dec 7 '16 at 8:25