borisveytsman / acmart

ACM consolidated LaTeX styles
595 stars 252 forks source link

`\subsubsection` incorrectly adds a period punctuation if the last letter is in capital #536

Open Darel13712 opened 1 month ago

Darel13712 commented 1 month ago

Example document

\documentclass[sigconf]{acmart}
\begin{document}
\subsubsection{WTF?}
\end{document}

Observed behaviour: \subsubsection{WTF?}WTF?. Expected behaviour: \subsubsection{WTF?}WTF?

The problem

This behaviour seems to happen only when the last character is a capital letter, but does not happen when it is in lower case. This also happens with other punctuation symbols: \subsubsection{WTF!}WTF!. \subsubsection{WTF.}WTF..

This does not happen if the punctuation symbol is repeated more than once: \subsubsection{WTF??}WTF??

Also this problem does not arise when you use \subsection or \section.

Workaround

I don't really understand the acmart.cls file but was able to produce the following workaround with chatgpt which seems to be working:

\makeatletter
% Redefine \@adddotafter to handle punctuation correctly
\def\@adddotafter#1{%
  \ifx\relax#1\relax
    #1%
  \else
    \def\@tempb{\expandafter\@gobble\string#1.}%
    \ifx\@tempb\@empty
      #1\@addpunct{.}%
    \else
      #1%
    \fi
  \fi
}