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 typesetting both text and math in Latin Modern, except for the figures, where I would like to use a sans serif font for both text and math.

I need to follow the ISO recommendations for math typesetting. That incorporates the need to typeset vectors in boldface italics. Within the document, I'm using \bm from the bm package for that purpose. It works fine.

Now I started using the sansmath environment from the sansmath package to get my figures in sans serif. For simplification, I did not put a figure in the following example.

\documentclass{scrartcl}

\usepackage{lmodern}
\usepackage{bm}
\usepackage{sansmath}

\begin{document}

$\bm{d} = (d_1, d_2)$

$\mathbf{d} = (d_1, d_2)$

\begin{sansmath}
$\bm{d} = (d_1, d_2)$

$\mathbf{d} = (d_1, d_2)$
\end{sansmath}

\end{document}

As the example shows, I could also use mathbf, which also does its job within the sansmath environment. However, I mustn't have upright letters for the vectors.

Is the another combination of packages available that both does sans serif math and supports boldface italics?

share|improve this question
add comment

2 Answers 2

up vote 5 down vote accepted

As I understand your question, you would like the \bm command to always typeset its contents in slanted style, whether in ordinary, i.e., serif, math mode or in the sansmath environment. The following modified version of your MWE achieves this objective.

Relative to your code, I've made the following three changes: (a) The sansmath package is now loaded with the T1 option; (b) the \SetMathAlphabet{\mathsfbf}...{bx}{sl} command tells LaTeX to use a slanted font in bold-math mode; (c) the sansmath environment is augmented so that \bm will typeset its argument the way that \mathsfbf does. (I say "augmented" rather than "patched" because I believe that the sansmath package predates the bm package. Hence, the sansmath package couldn't make allowance for the emergence of the subsequent \bm command, right?)

A word of caution: This quick fix lets \bm operate, as expected, on lower- and uppercase Latin letters in the sansmath environment. However, some of the other "magic" of the bm package, which lets it operate on Greek letters and math symbols as well, is not preserved by this method. To set Greek letters and math symbols in bold in the sansmath environment, you'll have to use the \boldsymbol command. (By the way, AFAIK the Latin Modern font family doesn't provide separate sans-serif math-mode Greek letters, whether regular weight or bold. Therefore, if you use Greek letters in the sansmath environment, you'll get the ordinary math-mode Greek letters, which may look wrong in a sans-serif environment. If you must have sans-serif Greek math-mode letters in your document, you should probably use xelatex and employ a specialized math font that does provide this feature.)

\documentclass{scrartcl}                             
\usepackage{lmodern,bm}                
\usepackage[T1]{sansmath} 
\SetMathAlphabet{\mathsfbf}{sans}{\sansmathencoding}{\sfdefault}{bx}{sl}
\usepackage{etoolbox}
\AtBeginEnvironment{sansmath}{\let\bm\mathsfbf}{}{}
\begin{document}                
Serif math:

$\bm{d} = (d_1, d_2)$                

$\mathbf{d} = (d_1, d_2)$                

\textsf{Sans-serif math:}

\begin{sansmath}                
$\bm{d} = (d_1, d_2)$                

$\mathbf{d} = (d_1, d_2)$                
\end{sansmath}                

\end{document}

enter image description here

share|improve this answer
    
That one does it very well! The good thing is that I can continue using the sansmath environment just for my figures without changing them. Greek letters are a mess anyway, it's getting even more funny if it comes to upright lowercase and slanted uppercase Greek letters. I intentionally did not ask for the Greek letters... so much better you mention it in your answer. And you are right, the look of the Greek letters does not match the Latin one very well. At least, the lowercase Greek letters do not have serifs :). –  Christoph Dec 11 '11 at 21:48
add comment

Here are some options - either a text version or using the sfmath package:

enter image description here

\documentclass{scrartcl}
\usepackage{lmodern}% http://ctan.org/pkg/lm
\usepackage{bm}% http://ctan.org/pkg/bm
\usepackage{sfmath}% http://ctan.org/pkg/sfmath
\newcommand{\mathbfit}[1]{\textbf{\textit{\textsf{#1}}}}
\begin{document}
\renewcommand{\arraystretch}{1.2}
\begin{tabular}{r@{\quad}r}
  \verb|\bm|: & $\bm{d} = (d_1, d_2)$ \\
  \verb|\mathbf|: & $\mathbf{d} = (d_1, d_2)$ \\
  \verb|\mathbfit|: & $\mathbfit{d} = (d_1, d_2)$
\end{tabular}
\end{document}
share|improve this answer
    
That doesn't use the sansmath package, which I prefer since it allows typesetting math without taking care for the font (by providing the environment sansmath I'm using in the MWE). Anyway, it's interesting to see sfmath as an alternative to sansmath. I think that makes it impossible to typeset math in sans serif only in parts of the document, or did I miss something? –  Christoph Dec 11 '11 at 21:15
    
@christoph.spiegel: Is the "text" alternative not viable? –  Werner Dec 11 '11 at 21:25
    
It does the trick with sans-serif bold-italic; anyway I can't see how to typeset math in the regular serif font once sfmath is loaded. –  Christoph Dec 11 '11 at 21:54
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.