How to enforce minimal height in pdfmarkupcomment?
You can patch \pdfmarkupcomment
so that every appearance of #2
becomes \strut#2
\documentclass{article}
\usepackage{pdfcomment}
\usepackage{regexpatch}
\makeatletter
\xpatchcmd*{\pdfmarkupcomment}
{#2}
{\strut#2}
{}{}
\makeatother
\begin{document}
\pdfmarkupcomment[markup=Highlight]{aa}{Highlight}
\pdfmarkupcomment[markup=Highlight]{AA}{Highlight}
\pdfmarkupcomment[markup=Highlight]{gg}{Highlight}
\pdfmarkupcomment[markup=Highlight]{Ag}{Highlight}
\end{document}
but beware that this will apply \strut
everywhere, not only when some markup comments are near to each other.
Alternative patching:
\documentclass{article}
\usepackage{pdfcomment}
\usepackage{letltxmacro}
\LetLtxMacro\originalpdfmarkupcomment\pdfmarkupcomment
\renewcommand{\pdfmarkupcomment}[3][]{%
\originalpdfmarkupcomment[#1]{\strut#2}{#3}%
}
\begin{document}
\pdfmarkupcomment[markup=Highlight]{aa}{Highlight}
\pdfmarkupcomment[markup=Highlight]{AA}{Highlight}
\pdfmarkupcomment[markup=Highlight]{gg}{Highlight}
\pdfmarkupcomment[markup=Highlight]{Ag}{Highlight}
\end{document}
You might use the height of capital letters and the depth of y, but beware that capital letters usually overshoot:
\documentclass{article}
\usepackage{pdfcomment}
\usepackage{letltxmacro}
\LetLtxMacro\originalpdfmarkupcomment\pdfmarkupcomment
\renewcommand{\pdfmarkupcomment}[3][]{%
\originalpdfmarkupcomment[#1]{%
\hbox{\vrule height \fontcharht\font`A depth \fontchardp\font`y width 0pt}%
#2%
}{#3}%
}
\begin{document}
\pdfmarkupcomment[markup=Highlight]{aa}{Highlight}
\pdfmarkupcomment[markup=Highlight]{AA}{Highlight}
\pdfmarkupcomment[markup=Highlight]{gg}{Highlight}
\pdfmarkupcomment[markup=Highlight]{Ag}{Highlight}
\end{document}
You can fix the overshoot by using 1.1\fontcharht\font`A
and the result would be
and you may want to do similarly for the depth.
You can simply use \strut
to get the height of a base line. Or define your own \boxheight
as in the example. You must define it in a macro without argument, otherwise it will not survive the SOUL parser used by pdfcomment
.
\documentclass{article}
\usepackage{pdfcomment}
\newcommand\pdfstrutmc[3][\strut ]%
{%
\pdfmarkupcomment{#1#2}{#3}%
}%
\newcommand\boxheight{\raisebox{-3pt}{\rule{0pt}{15pt}}}
%
\begin{document}
\pdfstrutmc{aa}{Highlight}
\pdfstrutmc{AA}{Highlight}
\pdfstrutmc{gg}{Highlight}
\pdfstrutmc{Ag}{Highlight}
\bigskip
\pdfstrutmc[\boxheight]{Aa}{Highlight}
\pdfstrutmc[\boxheight]{AA}{Highlight}
\pdfstrutmc[\boxheight]{gg}{Highlight}
\pdfstrutmc[\boxheight]{Ag}{Highlight}
\end{document}