2

I'm trying to change math font to sans serif font (the same I use in the rest of the document) with mathastext package. Letters change but numbers doesn't do it and I don't know why. This is my preamble:

\documentclass[a4paper,10pt,twoside]{article}
\usepackage[margin=2cm]{geometry} % Margin

\usepackage{amsmath,tikz,mathrsfs,subdepth}
% amsmath   align equations
% tikz      create graphic elements
% subdepth  equalise the height of sub­scripts in math mode
% mathrsfs  handwritting math font

\usepackage{color, fancyhdr, fontspec, ragged2e, subfiles, titlesec}
% Color     text and background color
% Fancyhdr  customize headers and footers
% Fontspec  change main font
% Ragged2e  align text
% Subfiles  han­dle multi-file projects
% Titlesec  titles style

% ---------- COLOR PACKAGE ----------
\definecolor{amarillo}{RGB}{255,227,54}
\definecolor{azul}{RGB}{0,11,63}
\definecolor{blanco}{RGB}{255,255,255}
\definecolor{fucsia}{RGB}{255,49,127}
\definecolor{verde}{RGB}{5,187,136}

% ---------- FANCYHDR PACKAGE ----------
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0} % Deletes header line
\fancyhf{}
\fancyfoot[LE,RO]{\colorbox{amarillo}{Página \thepage}} % Numbering pages

% ---------- FONTSPEC PACKAGE ----------
\setmainfont[
BoldFont=RobotoCondensed-Bold.ttf,
ItalicFont=RobotoCondensed-RegularItalic.ttf,
]{Quicksand-Regular.ttf} % Main font, loaded

% ---------- MATHASTEXT PACKAGE ----------
\usepackage[defaultmathsizes]{mathastext}

% ---------- TITLESEC PACKAGE ----------
\titlespacing{\section}{0}{-1cm}{1cm}
\titlespacing{\subsection}{2cm}{0.75cm}{0.5cm}
\titlespacing{\subsubsection}{0}{0}{0.1cm}
\titleformat{\section}[display]{\bfseries\LARGE}{}{1cm}{\centering}[]
\titleformat{\subsection}[display]{\bfseries\Large}{}{0}{}[]
\titleformat{\subsubsection}[display]{\bfseries\large}{}{0}{}[]

% ---------- OTHERS ----------
\setlength{\parskip}{0} \setlength{\parindent}{0} % Paragraph formatting

\begin{document}

\subfile{sections/unidad4}

\end{document}

I'd tried to translate (from spanish) the better I could, sorry for mistakes.

Then, when I write in math mode:

\textbf{Math mode:} \\
\( 0123456789 \quad ABCDEFGHIJ\) \\
\\
\textbf{Text mode:} \\
0123456789 \quad ABCDEFGHIJ

math mode vs text mode

Can someone help me please?

2

If you load the fontspec package with the no-math option (see the manual for this package) your problem should be solved. Also, I suggest to write \setlength{\parskip}{0pt} instead of \setlength{\parskip}{0} (see the warnings in the log file after compilation).

Output

(The horizontal rule connects the top and bottom part of the page and represents the image break only.)

enter image description here

\documentclass[a4paper,10pt,twoside]{article}
\usepackage[margin=2cm]{geometry} % Margin

\usepackage{amsmath,tikz,mathrsfs,subdepth}
% amsmath   align equations
% tikz      create graphic elements
% subdepth  equalise the height of sub­scripts in math mode
% mathrsfs  handwritting math font

\usepackage{color,fancyhdr,ragged2e,subfiles,titlesec}
\usepackage[no-math]{fontspec}
% Color     text and background color
% Fancyhdr  customize headers and footers
% Fontspec  change main font
% Ragged2e  align text
% Subfiles  han­dle multi-file projects
% Titlesec  titles style

% ---------- COLOR PACKAGE ----------
\definecolor{amarillo}{RGB}{255,227,54}
\definecolor{azul}{RGB}{0,11,63}
\definecolor{blanco}{RGB}{255,255,255}
\definecolor{fucsia}{RGB}{255,49,127}
\definecolor{verde}{RGB}{5,187,136}

% ---------- FANCYHDR PACKAGE ----------
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt} % Deletes header line
\fancyhf{}
\fancyfoot[LE,RO]{\colorbox{amarillo}{Página \thepage}} % Numbering pages

% ---------- FONTSPEC PACKAGE ----------
\setmainfont[
BoldFont=RobotoCondensed-Bold.ttf,
ItalicFont=RobotoCondensed-RegularItalic.ttf,
]{Quicksand-Regular.ttf} % Main font, loaded

% ---------- MATHASTEXT PACKAGE ----------
\usepackage[defaultmathsizes]{mathastext}

% ---------- TITLESEC PACKAGE ----------
\titlespacing{\section}{0}{-1cm}{1cm}
\titlespacing{\subsection}{2cm}{0.75cm}{0.5cm}
\titlespacing{\subsubsection}{0}{0}{0.1cm}
\titleformat{\section}[display]{\bfseries\LARGE}{}{1cm}{\centering}[]
\titleformat{\subsection}[display]{\bfseries\Large}{}{0}{}[]
\titleformat{\subsubsection}[display]{\bfseries\large}{}{0}{}[]

% ---------- OTHERS ----------
\setlength{\parskip}{0pt} \setlength{\parindent}{0pt} % Paragraph formatting

\begin{document}

\textbf{Math mode:} \\
\( 0123456789 \quad ABCDEFGHIJ\) \\
\\
\textbf{Text mode:} \\
0123456789 \quad ABCDEFGHIJ

\end{document}
  • Very good. You have my appreciation. (+1). – Sebastiano Jul 28 at 10:49
  • I didn't know the no-math option for Fontspec. Now my LaTeX document looks as I want ♥ Thank you, thank you, thank you! – Priscila Velázquez Jul 28 at 19:27

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.