[Tex/LaTex] Abbreviations for AM, PM (small caps) for use within \textbf

acronymsboldfontsizesmall-caps

I have been using \textsc for the abbreviations for AM, PM, but it does not work within \textbf{}. As you can see in the image, within a \textbf{}, it reverts to the normal lower case letter. Ulrike Fischer suggests in bold small caps with mathpazo, to switch to uppercase characters when attempting to use a bold weight font, but that does not look right as the result lablelled MyTextsc shows (I modified it slightly to apply a \tiny size change):

enter image description here

The results are not very good, so wondering if others have other suggestions?

Code:

\documentclass{article}
\usepackage{lmodern}%
\usepackage[T1]{fontenc}%

\usepackage{graphicx}
\usepackage{xspace}

\makeatletter
\newcommand*{\AMorPMTextModeTextsc}[1]{%
        \@ifnextchar{.}%
            {\textsc{\,{\small#1}}}%
            {\textsc{\,{\small#1}}\xspace}%
}%

% https://tex.stackexchange.com/a/24635/4301
\DeclareRobustCommand{\MyTextsc}[1]{%
 \edef\@tempa{\f@series}\edef\@tempb{\bfdefault}%
 \ifx\@tempa\@tempb%
  \uppercase{{\tiny#1}}% \small here seems to do nothing
 \else
  {\scshape\small#1}%
 \fi }

\newcommand*{\AMorPMTextModeMyTextsc}[1]{%
        \@ifnextchar{.}%
            {\MyTextsc{\,{#1}}}%
            {\MyTextsc{\,{#1}}\xspace}%
}%

\makeatother


\newcommand{\PrintText}[1]{%
\makebox[8.0em][l]{Using \textbackslash#1:} 5:00\PM to 8:00\PM.\par
\makebox[8.0em][l]{Using \textbackslash#1:} \textbf{5:00\PM to 8:00\PM.}
}%

\begin{document}
\newcommand{\AM}{\AMorPMTextModeTextsc{am}}%
\newcommand{\PM}{\AMorPMTextModeTextsc{pm}}%
\PrintText{textsc}

\bigskip
\renewcommand{\AM}{\AMorPMTextModeMyTextsc{am}}%
\renewcommand{\PM}{\AMorPMTextModeMyTextsc{pm}}%
\PrintText{MyTextsc}
\end{document}

Best Answer

A good rule of thumb for scaling uppercase to match (poorly) small caps is to use a factor 0.8 of the font size.

\documentclass{article}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage{xspace}
\makeatletter
\DeclareRobustCommand{\maybefakesc}[1]{%
  \ifnum\pdfstrcmp{\f@series}{\bfdefault}=\z@
    {\fontsize{\dimexpr0.8\dimexpr\f@size pt\relax}{0}\selectfont\uppercase{#1}}%
  \else
    \textsc{#1}%
  \fi
}
\newcommand\AM{\,\maybefakesc{am}\xspace}
\newcommand\PM{\,\maybefakesc{pm}\xspace}
\makeatother

\begin{document}

{\bfseries 5:00\AM to 8:00\AM}

5:00\AM to 8:00\AM

\textbf{\AM}\AM

\Huge\textbf{\AM}\AM

\end{document} 

Notice that your test of a following period is useless if you adopt \xspace.

enter image description here

It may seem too high, when compared side by side, but boldface always has some overshoot. Refine at will.

Note. If the text you pass to \maybefakesc can be more complicated than a simple string of ASCII characters, change \uppercase into \MakeUppercase.