6

For some reason, when I use \mathsf{}, the decimal point doesn't seem to be affected:

\documentclass{article}
\begin{document}
\textsf{This is an example.} $ \mathsf{\frac{1}{2} = 0.5} $

The rest of the document is in normal serif font.
\end{document}

enter image description here

If you look carefully, you can notice how the dot after 'example' is a square, but the dot between 0 and 5 is a circle.

This might not be a big deal in English, but in other languages where we use the comma instead of the dot this is much more noticeable:

\documentclass{article}
\usepackage[spanish]{babel}
\begin{document}
\textsf{This is an example,} $ \mathsf{\frac{1}{2} = 0.5} $

The rest of the document is in normal serif font.
\end{document}

enter image description here

  • 2
    \usepackage[spanish]{babel} \spanishdecimal{\textsf{,}} – Manuel May 13 '15 at 15:25
7

This is expected, because the period has type \mathord, so it doesn't change with \mathXY commands. However, it's easily fixed.

\DeclareMathSymbol{.}{\mathalpha}{operators}{`.}

For the comma it's not as easy, because we can't assign the comma the \mathalpha type, since it should be punctuation.

It's easier to use sansmath, that also makes sans serif many other symbols.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage{sansmath}

\newcommand{\sftextandmath}{\sffamily\sansmath}
\DeclareTextFontCommand{\allsf}{\sftextandmath}

\begin{document}
\allsf{This is an example: $\frac{1}{2} = 0.5$}

This is another example: $\frac{1}{2}=0.5$
\end{document}

enter image description here

2

spanish from babel, defines a particular macro to alter the output of a decimal point (i.e., you input, as always, a dot ., and you change the output with this macro).

\usepackage[spanish]{babel}
\spanishdecimal{\textsf{,}}

Personally, I like the dot itself, so \spanishdecimal{.} would do for me (there are other concrete macros for the dot or the comma, but \spanishdecimal is more general).

  • What about math in serif type? – egreg May 13 '15 at 15:47
  • I didn't think he needed, but \spanishdecimal{\textsf{,}} can be used inside a group, or appended to a macro. or whatever. – Manuel May 13 '15 at 15:51
  • I did need it, I guess I should've been clearer. How would I use it inside a group (e.g. in egreg's example)? – saarl May 13 '15 at 16:05
  • @saarl Possible, but since egreg already answered, I think the sansmath is more general. – Manuel May 13 '15 at 16:29

Your Answer

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

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