# How to mix lxfonts' rounded letters with a system-installed font in math expressions

The only way I found to mix a system installed font inside maths expression with rounded letters from lxfonts is by wrapping each number in a \text{}, like so:

\documentclass[a4paper,12pt]{article}
\usepackage{fontspec}
\setmainfont{Ubuntu}
\usepackage{amssymb}
\usepackage{amsmath}

\usepackage{lxfonts}
\begin{document}
\fontspec{Ubuntu}
$\text{7}x - \text{1} = \text{13}$
\end{document}


This compiles into this (desired) output:

Question

I would like to find a more simple way to get the same result, without using these \text{} to wrap numbers.

Difficulties

lxfonts must be loaded in the last position, and yet the other packages I've tried to use do cancel its effects.

I want to be able to use lxfonts for letters in math mode, but it looks like it's not exactly working as another font (or maybe I do not use it correctly?).

Unsuccessful attempts

• Using unicode-math, the minus sign is lost (so maybe other operators too?), and lxfonts effects are cancelled

\documentclass[a4paper,12pt]{article}
\usepackage{fontspec}
\usepackage{unicode-math}
\setmainfont{Ubuntu}
\setmathfont{Ubuntu}
\setmathfont[range=\mathup]  {Ubuntu}
\setmathfont[range=\mathbfup]{Ubuntu Bold}
\setmathfont[range=\mathbfit]{Ubuntu Bold Italic}
\setmathfont[range=\mathit]  {Ubuntu Italic}
\usepackage{lxfonts}
\begin{document}
\fontspec{Ubuntu}
$7x - 1 = 13$
\end{document}


• Using mathastext, the result is somewhat reversed (numbers are not Ubuntu, letters are Ubuntu).

\documentclass[a4paper,12pt]{article}
\usepackage{fontspec}
\setmainfont{Ubuntu}
\usepackage{mathastext}
\usepackage{lxfonts}
\begin{document}
\fontspec{Ubuntu}
$7x - 1 = 13$
\end{document}


You should avoid to load font packages meant for pdflatex after fontspec. They often destroy fontspec settings. In this case even loading it before doesn't avoid all problems as lxfonts sets fonts in \AtEndPreamble.

I don't have the Ubuntu font, so I used instead a red Arial.

\documentclass[a4paper,12pt]{article}

\usepackage{lxfonts}
\usepackage[no-math]{fontspec}

\AtEndPreamble{\setmainfont{Arial}[NFSSFamily=arial,Color=FF0000]}

\usepackage{amssymb}
\usepackage{amsmath}

\DeclareSymbolFont{mynumbers}      {TU}{arial}{m}{n}
\SetSymbolFont    {mynumbers}{bold}{TU}{arial}{bx}{n}

\AtBeginDocument{
\DeclareMathSymbol{0}{\mathalpha}{mynumbers}{0}
\DeclareMathSymbol{1}{\mathalpha}{mynumbers}{1}
\DeclareMathSymbol{2}{\mathalpha}{mynumbers}{2}
\DeclareMathSymbol{3}{\mathalpha}{mynumbers}{3}
\DeclareMathSymbol{4}{\mathalpha}{mynumbers}{4}
\DeclareMathSymbol{5}{\mathalpha}{mynumbers}{5}
\DeclareMathSymbol{6}{\mathalpha}{mynumbers}{6}
\DeclareMathSymbol{7}{\mathalpha}{mynumbers}{7}
\DeclareMathSymbol{8}{\mathalpha}{mynumbers}{8}
\DeclareMathSymbol{9}{\mathalpha}{mynumbers}{9}
}

\begin{document}
1234 x \textit{x}

$1234567890x - 1 = 13$

\boldmath
$1234567890$
\end{document}


• In order to include the decimal points and commas, I have added \DeclareMathSymbol{.}{\mathalpha}{mynumbers}{.} and \DeclareMathSymbol{,}{\mathalpha}{mynumbers}{,}. It works, but I'm not sure it's the correct way of doing this. – zezollo Jan 3 '18 at 8:39