Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm using a type family that supports a semi-bold (sb) face, and I'd like to use that whenever \textbf is called for. How can I redefine \textbf to do this? Can I do it on a per family basis, or only for all families in my document at once?

share|improve this question
add comment

3 Answers

up vote 17 down vote accepted

Fonts are identified by five attributes:

  1. encoding
  2. family
  3. series (weight)
  4. shape
  5. size

For the first four attributes, LaTeX maintains "default" definitions, contained in

  1. \encodingdefault
  2. \familydefault
  3. \seriesdefault
  4. \shapedefault

but also other commands

  • Family defaults: \rmdefault, \sfdefault, \ttdefault
  • Series defaults: \mddefault, \bfdefault
  • Shape defaults: \updefault, \itdefault, \sldefault, \scdefault

When you call \bfseries (or \textbf, which calls \bfseries internally), LaTeX looks at \bfdefault, whose normal definition is

\newcommand{\bfdefault}{bx}

and doesn't change any of the other attributes.

At a lower level LaTeX maintains also

  1. \f@encoding
  2. \f@family
  3. \f@series
  4. \f@shape
  5. \f@size and \f@baselineskip

Your problem seems to be in the fact that the sans serif family has a "semibold" shape that you want to be selected in case \bfseries is called, but the roman and typewriter families don't.

A definition such as

\makeatletter
\renewcommand{\bfdefault}{\ifx\f@family\sfdefault sb\else bx\fi}
\makeatother

will do the right thing unless you call a family changing command after the switch for bold face. So

\textrm{\textbf{x}}

would work, while \textbf{\textrm{x}} wouldn't.

Another way is to use \DeclareFontShape as explained by David Carlisle

\renewcommand{\bfdefault}{sb}
\DeclareFontShape{\encodingdefault}{\rmdefault}{sb}{n}
    {<->ssub*\rmdefault/bx/n}{}
\DeclareFontShape{\encodingdefault}{\rmdefault}{sb}{sl}
    {<->ssub*\rmdefault/bx/sl}{}

and similarly for the typewriter type family.

In case you're using fontspec the situation is completely different, as you can fix the boldface variant on a family basis, as explained by rdhs.

share|improve this answer
    
I set my sans family (which is the one I'm trying to change) with \usepackage[defaultsans]{open sans} and both methods above behave as if they don't recognize \sfdefault. The first method does nothing, while the second fails with "Font family `T1+fos' unknown". –  raxacoricofallapatorius Mar 13 '12 at 18:06
    
I've modified the examples to reflect the new info –  egreg Mar 13 '12 at 18:17
    
Thanks, the \DeclareFontShape method now works; the \ifx\f@family\sfdefault has no effect. –  raxacoricofallapatorius Mar 13 '12 at 18:40
    
@raxacoricofallapatorius It doesn't because opensans doesn't act as expected. –  egreg Mar 13 '12 at 18:47
add comment

If you're already using fontspec, just adjust the BoldFont setting for each family:

\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX,Scale=MatchLowercase}
\setmainfont[BoldFont="Minion Pro Semibold"]{Minion Pro}
\setsansfont[BoldFont="Myriad Pro Semibold"]{Myriad Pro}
share|improve this answer
1  
I had to omit the quotes to get it working, but apart from this it is a nice solution. –  matth Oct 16 '12 at 12:09
add comment

Globally you can override the default definition of

 \newcommand\bfdefault{bx}

with

\renewcommand\bfdefault{sb}

To do it for a single face, probably the easiest is to have a command like this one (from the base ot1cmtt.fd file)

\DeclareFontShape{OT1}{cmtt}{bx}{n}
  {<->ssub*cmtt/m/n}{}

which substitutes non bold tt font for the bold version, just adjust the arguments for the font family you want to change.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.