4

The URW Palldio font (mathpazo package) does not provide bold small caps. To get round this issue, I'd want to make a macro to use small caps usually and normal caps in bold text.

I tried this code:

\documentclass{minimal}
\usepackage[sc,osf]{mathpazo}

% Use small caps normally except in a bold font: switch to uppercase instead.
% This macro does not work: the `\ifx\f@series\bfdefault` test always fails.
\makeatletter
\DeclareRobustCommand{\mytextsc}[1]{%
    \ifx\f@series\bfdefault%
        \uppercase{#1}%
    \else
         {\scshape #1}%
    \fi
}
\makeatother

% An other macro, where the same test is ok here !?
\newcommand\normal{\fontseries{\ifx\f@series\bfdefault\then m \fi}\selectfont}


\begin{document}
% this works OK
This is a \mytextsc{small caps} text.

% this fails
\textbf{This is a bold \mytextsc{upper case} text.}

% here the normal macro works
\textbf{This is a bold \mytextsc{upper \normal case} text.}
\end{document}

For some strange reason, the test \ifx\f@series\bfdefault always fails in the \mytestsc macro, although it works well in the \normal macro. Any ideas how to correct the \mytextsc macro?

3
  • 1
    Try putting \makeatletter\show\f@series\show\bfdefault\makeatother within the body of the \textbf. What does Latex say? Apr 10 '10 at 12:34
  • this don't work, the latex file don't compile with show macro.
    – user312728
    Apr 12 '10 at 19:49
  • The \show command interrupts the compilation to show you the definition of commands, you must continue it by typing enter. Aug 1 '11 at 13:01
7

Update 2020

Due to changes in the latex kernel - series are now handled in a more sophisticated way - this will no longer work. It is now better to test against \bfseries@rm and \bfseries@sf. Perhaps there will be in future also be a generic test to check if one is in a "bold context".

I also suggest not to use \uppercase as it won't handle e.g. accents correctly.

\documentclass{article}
\usepackage[sc,osf]{mathpazo}
\usepackage[T1]{fontenc}
\usepackage{xparse}

\ExplSyntaxOn\makeatletter
\NewDocumentCommand{\mytextsc}{m}
 {
  \bool_if:nTF 
    {
      \tl_if_eq_p:NN \f@series \bfseries@rm
      ||
      \tl_if_eq_p:NN \f@series \bfseries@sf 
    }  
    {
      \text_uppercase:n{#1}%
    }
    {
      \textsc{#1}
    } 
 }
\ExplSyntaxOff \makeatother
\begin{document}
This is a \textsc{small caps} \mytextsc{small caps} text.

\textbf{This is a bold \textsc{upper case} \mytextsc{upper text grüße} text.}

\sffamily
\textbf{This is a bold \textsc{upper case} \mytextsc{upper text grüße} text.}

\end{document}

enter image description here

Old (outdated) answer.

\bfdefault is a long macro, \f@series not, so both are different and the test always gives false. This also happen in your "working" normal command which always gives \fontseries{m}. Expand the macros before the test:

\DeclareRobustCommand{\mytextsc}[1]{%
 \edef\@tempa{\f@series}\edef\@tempb{\bfdefault}%
 \ifx\@tempa\@tempb%
  \uppercase{#1}%
 \else
  {\scshape #1}%
 \fi }
0

I don't know why \bfdefault isn't expanding correctly, but you can define a new macro that does what you want:

\makeatletter
\def\boldseriesname{bx}
\DeclareRobustCommand{\mytextsc}[1]{%
    \ifx\f@series\boldseriesname\uppercase{#1}%
    \else{\scshape #1}%
    \fi}
\makeatother
0

There doesn't appear to be any bold small caps for mathpazo, according to Will Robertson:

You should check the Latex warning to be sure.

1
  • Sorry, I edited the post to clarify my issue. It's not the missing font, but the macro.
    – user312728
    Apr 9 '10 at 19:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy