Math & ScienceMath symbols in sans-serif font

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
bstex
Posts: 69
Joined: Mon Oct 23, 2017 10:22 am

Math symbols in sans-serif font

Post by bstex »

Hi.
Is there any way to make the symbols \leq, \simeq etc to be shown with a sans-serif font and also a little bit smaller?
When I put them in math mode as $\leq$ and $\simeq$, they don't "match" with my text font, because they are not sans-serif.
When I put them in my code with copy/paste from Word, they look fine.
You would say that with copy/paste from Word I could have solved my problem, but as you see in example 6, the symbol ≃ does not appear correctly.
Screen Shot 2018-03-29 at 00.06.12.png
Screen Shot 2018-03-29 at 00.06.12.png (18.22 KiB) Viewed 21508 times
My MWE:

Code: Select all

\documentclass[a4paper,11pt,openright]{book}
\usepackage{fontspec}
\setmainfont[Kerning=On,Mapping=tex-text]{Myriad Pro}

\begin{document}
Examples: \\
1. Α $\leq$ B \\
2. A ≤ B \\
3. C $<$ D \\
4. C < D \\
5. E $\simeq$ F \\
6. E ≃ F
\end{document}
Any help? Thank you.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
Stefan Kottwitz
Site Admin
Posts: 10321
Joined: Mon Mar 10, 2008 9:44 pm

Math symbols in sans-serif font

Post by Stefan Kottwitz »

With pdfLaTeX, shmath gives sans-serif math:

Code: Select all

\documentclass{book}
\usepackage{sfmath}
\begin{document}
$E \simeq F$
\end{document}
By the way, commonly math variables are written in italic shape. That's the case in all math textbooks I know. The intention is not matching the text font, but to distinguish math expressions clearly from text. And, in contrast to italic variables, operators are commonly written upright.

Stefan
LaTeX.org admin
User avatar
Stefan Kottwitz
Site Admin
Posts: 10321
Joined: Mon Mar 10, 2008 9:44 pm

Math symbols in sans-serif font

Post by Stefan Kottwitz »

Another way, I just tested that it works wit XeLaTeX and fontspec too:

$\mathsf{E \simeq F}$

Stefan
LaTeX.org admin
bstex
Posts: 69
Joined: Mon Oct 23, 2017 10:22 am

Math symbols in sans-serif font

Post by bstex »

Stefan, I had already tested these solutions, but none of them worked in my project.

This code produces the EXACT same math symbol!

Code: Select all

\documentclass[a4paper,11pt,openright]{book}
\usepackage{fontspec}
\setmainfont[Kerning=On,Mapping=tex-text]{Myriad Pro}

\begin{document}
E $\simeq$ F \\
$\mathsf{E \simeq F}$
\end{document}
Screen Shot 2018-03-29 at 10.35.41.png
Screen Shot 2018-03-29 at 10.35.41.png (8.02 KiB) Viewed 21499 times
Thank you for your reply.
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Math symbols in sans-serif font

Post by Johannes_B »

What exactly are you expecting?
This is a symbol, there is no bserif or sans-serif version.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
bstex
Posts: 69
Joined: Mon Oct 23, 2017 10:22 am

Math symbols in sans-serif font

Post by bstex »

My code has this result:
Screen Shot 2018-03-29 at 11.19.17.png
Screen Shot 2018-03-29 at 11.19.17.png (9.72 KiB) Viewed 21497 times
but I'd like to make it look like this:
Screen Shot 2018-03-29 at 11.19.32.png
Screen Shot 2018-03-29 at 11.19.32.png (9.87 KiB) Viewed 21497 times
so the math symbols are a little more "compatible" with the text font.
Thank you.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10321
Joined: Mon Mar 10, 2008 9:44 pm

Math symbols in sans-serif font

Post by Stefan Kottwitz »

Perhaps like this?

Code: Select all

\documentclass{book}
\usepackage{fontspec}
\usepackage{relsize}
\newcommand*{\eq}{\mathrel{\raisebox{0.4ex}{\boldmath$\mathsmaller{\simeq}$}}}
%\setmainfont[Kerning=On,Mapping=tex-text]{Myriad Pro}
\begin{document}
$\mathsf{E \eq F}$ \\
\end{document}
Stefan
LaTeX.org admin
bstex
Posts: 69
Joined: Mon Oct 23, 2017 10:22 am

Math symbols in sans-serif font

Post by bstex »

Yes!
Also, since I'm using \everymath{\displaystyle} in my preamble, I added the \scriptsize in your code and now the math symbols seem perfect.
Thank you!
bstex
Posts: 69
Joined: Mon Oct 23, 2017 10:22 am

Math symbols in sans-serif font

Post by bstex »

I just found another solution, but it works only with some symbols.
Since I'm using the fontspec, if I know the Unicode number of the symbol, I write this code:

Code: Select all

\documentclass{book}
\usepackage{fontspec}
\setmainfont[Kerning=On,Mapping=tex-text]{Myriad Pro}

\begin{document}
Examples:\\
A {^^^^2264} B \\
C {^^^^2265} D \\
E {^^^^2243} F
\end{document}
Screen Shot 2018-03-29 at 13.04.58.png
Screen Shot 2018-03-29 at 13.04.58.png (13.23 KiB) Viewed 21493 times
and the symbols are shown perfectly.
But why the symbol "simeq" can't be shown?
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Math symbols in sans-serif font

Post by Johannes_B »

I guess the font just does not provide this symbol.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Post Reply