# Abbreviations for AM, PM (small caps) for use within \textbf

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):

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}%
}%

% http://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}

-
I assume you don't want to switch to a different font that provides bold small caps (like Linux Libertine)? –  Caramdir Jun 16 '12 at 0:29
Or switch to 24h format :P –  percusse Jun 16 '12 at 0:30
@Caramdir: I don't mind switching fonts but not something I had dived into, but any suggestions for fonts to use that work in with math mode are fine. –  Peter Grill Jun 16 '12 at 0:54
@PeterGrill: MinionPro is nice, it's not a free font though. The basic cuts are included in the Adobe Reader package (though I did not read the licence...). LaTeX support is available in the FontPro package. –  sebschub Jun 16 '12 at 7:29

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.

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.

-

My method relies on the relsize package. Please, if needed, read the package documentation.

\documentclass{article}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{relsize}
\usepackage{xspace}
\makeatletter
\protected\def\declarescsize{\@testopt\declare@scsize{1}}
\def\declare@scsize[#1]{%
\protected\def\makesc##1{%
\ifnum\pdfstrcmp{\f@series}{\bfdefault}=\z@
\uppercase{{\relsize{#1}{##1}}}%
\else
\textsc{##1}%
\fi
}%
}
\newcommand\AM{\,\makesc{am}\xspace}
\newcommand\PM{\,\makesc{pm}\xspace}
\makeatother

% You can change the scale by calling \declarescsize:
\declarescsize[-1.2]

\begin{document}
\parindent0pt
{\bfseries 5:00\AM to 8:00\AM}

5:00\AM to 8:00\AM

\textbf{\AM}\AM

\par\bigskip
{\Huge\textbf{\AM}\AM}
\end{document}


-
Could you a) add a picture of the output and b) add a few words to explain your approach, how it solves the problem? –  doncherry Jun 16 '12 at 20:26
There's no real need to use \protected and \@testopt, since \newcommand\declarescsize[1][1]{...} would "robustify" \declarescsize anyway. You end up with defining two macros anyway. –  egreg Jun 17 '12 at 10:08
The commands with an optional argument defined with \newcommand[n][...]{...} are robust: they survive being used in moving arguments. They use \@testopt, of course, but the kernel takes precautions in order that the command is written unexpanded in the auxiliary files. –  egreg Jun 18 '12 at 23:55