I'd like to automatically add a final period if the argument of \paragraph does not end with either ., ?, or !.
A solution has been provided in Add a period after each paragraph title but this requires the last letter not being an upper case. How to address the general case?
\documentclass{article}
\usepackage{xparse}
\usepackage{amsthm} % for @addpunct
\makeatletter
\let\latexparagraph\paragraph
\RenewDocumentCommand{\paragraph}{som}{%
\IfBooleanTF{#1}
{\latexparagraph*{#3}}
{\IfNoValueTF{#2}
{\latexparagraph{\maybe@addperiod{#3}}}
{\latexparagraph[#2]{\maybe@addperiod{#3}}}%
}%
}
\newcommand{\maybe@addperiod}[1]{%
#1@addpunct{.}%
}
\makeatother
\begin{document}
\paragraph{This is the title} And some text follows.
\paragraph{This is the title.} And some text follows.
\paragraph{Is this is a title?} And some text follows.
\paragraph{This is the title X} And some text follows.
\paragraph{This is the title X.} And some text follows.
\paragraph{Is this is a title X?} And some text follows.
\end{document}



\@if you expect punctuation to follow and it's not an abbreviation. – egreg May 14 '23 at 12:27\paragraphwith an optional argument, e.g.,\paragraph[Title]{This is the title}. – Mico May 14 '23 at 12:50