2

I'm occasionally using double accents on symbols, e.g. double hats, using wipet's code from this question.

I now found that these do not work in acronym environments (which I'd like to use to produce a list of symbols).

Here is a minimal example:

\documentclass{article}
\usepackage{acronym}
\def\measurehat#1{%
   \setbox0=\vbox{$\hat{#1}\hfil\break$\null\par
      \setbox0=\lastbox\unskip\unpenalty\global\setbox1=\lastbox}%
   \setbox0=\hbox{\unhbox1 \unskip\unpenalty\unskip \global\setbox2=\lastbox}%
   \setbox0=\vbox{\unvbox2 \setbox0=\lastbox}%
}
\def\doublehat#1{%
   \measurehat{#1}\dimen0=\wd0 \measurehat{\kern0pt#1}%
   \raise.35ex\rlap{\kern\dimexpr\dimen0-\wd0$\hat{\phantom{#1}}$}{\hat#1}%
}
\begin{document}
    \section*{Works}
        \begin{acronym}[MMM]
            \setlength{\itemsep}{-\parsep}%
            \acro{lambdahat}[{$\hat{\lambda}$}]{Lambda hat}
            \acro{lambdatilde}[{$\tilde{\lambda}$}]{Lambda tilde}
        \end{acronym}
    \section*{Does not work}
        \begin{acronym}[MMM]
            \setlength{\itemsep}{-\parsep}%
            \acro{lambdahathat}[{$\doublehat{\lambda}$}]{Lambda double hat}
            \acro{lambdatilde}[{$\tilde{\lambda}$}]{Lambda tilde}
        \end{acronym}
\end{document}

This produces

enter image description here

As you can see, the twice-behatted lambda is overlaid on the next symbol; the same problem does not happen with a regular behatted lambda.

I've looked at acronym's documentation, to no avail; I've no idea where to even start with this, and would appreciate any help from the resident wizards.

chsk
  • 3,667

1 Answers1

2

No need to reinvent the wheel. ;-)

Double accents are available with amsmath.

\documentclass{article}
\usepackage{amsmath}
\usepackage{acronym}

\newcommand{\doublehat}[1]{\hat{\hat{#1}}}

\begin{document}

\begin{acronym}[MMM] \acro{lambdahat}[{$\hat{\lambda}$}]{Lambda hat}

\acro{lambdatilde}[{$\tilde{\lambda}$}]{Lambda tilde}

\acro{lambdahathat}[{$\doublehat{\lambda}$}]{Lambda double hat}

\acro{lambdatildehat}[{$\tilde{\lambda}$}]{Lambda tilde hat} \end{acronym}

\end{document}

enter image description here

egreg
  • 1,121,712
  • Huh, so they are. Interesting. The spacing is not quite as visually appealing, the double hat there looks like two individual hats rather than a single double hat (no surprise given that it is two individual hats), but good to know anyway! Thanks. If there's no other solutions I might just use this for the list of symbols and hope that noone'll notice the slight visual difference. ;) – chsk Sep 08 '22 at 13:46
  • @chsk You may want to try acro rather than the dated acronym. – egreg Sep 08 '22 at 14:05
  • I'll look into that, thanks again. – chsk Sep 08 '22 at 15:28