# XeLaTeX Font Warning: Font shape TS1/Arial(0)/m/n' undefined, how to fix it?

I hope a quick and easy solution is possible

• Error Code

LaTeX Font Warning: Font shape TS1/Arial(0)/m/n' undefined (Font) usingTS1/cmr/m/n' instead on input line 75.

• Main Problem

The error showcases that I can't manage to change the math font to a choice of mine while using mathspec package

• Explanation

I searched through old topics on the forum, with examples such as usage of "fontspec", usage of "renewcommands" and more. But they all can't seem to fix my error or allow me to use basically Arial as a main font(bold, italic etc.) and FOR EXAMPLE Cambria Math for Math fonts. The substitution named "cmr" looks kinda odd if combined with Arial.

If Cambria Math is a stupid idea to use with Arial, feel free to provide a better solution!

Here is the minimum example so you can also observe that error message(and see how unfitting Arial + cmr is):

Minimum Working Example with complete Preamble

    \documentclass[hidelinks,11pt,egregdoesnotlikesansseriftitles]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage{apacite}
\usepackage[showframe=true]{geometry}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{mathspec}
\setmainfont{Arial}
\setmathfont{Cambria Math}%an example, feel free to suggest something that works
\usepackage{natbib}
\usepackage[table,xcdraw]{xcolor}
\usepackage{array}
\usepackage[english]{babel}
\usepackage{geometry}
\usepackage{setspace}
\usepackage{eurosym}
\usepackage{multirow}
\usepackage{siunitx}

\makeatletter
\newcommand{\MSonehalfspacing}{%
\setstretch{1.44}%  default
\ifcase \@ptsize \relax % 10pt
\setstretch {1.448}%
\or % 11pt
\setstretch {1.399}%
\or % 12pt
\setstretch {1.433}%
\fi
}
\makeatother
\MSonehalfspacing

\clearpairofpagestyles
\KOMAoptions{onpsinit=\setstretch{1}}

\usepackage{textcomp}
\usepackage{gensymb}

\makeatletter
\makeatother

\let\oldtabular\tabular
\renewcommand{\tabular}{\small\oldtabular}
\setkomafont{caption}{\small}

\setlength{\parindent}{0pt}

\usepackage{apacdoc}

\addto\captionsenglish{% Replace "english" with the language you use
\renewcommand{\contentsname}%
}
\usepackage{hyperref}
\def\UrlBreaks{\do\/\do-}

\makeatletter
\newcommand{\tocfill}{\cleaders\hbox{$\m@th \mkern\@dotsep mu . \mkern\@dotsep mu$}\hfill}
\makeatother
\newcommand{\abbrlabel}[1]{\makebox[4cm][l]{\textbf{#1}\ \tocfill}}
\newenvironment{abbreviations}{\begin{list}{}{\renewcommand{\makelabel}{\abbrlabel}%
\setlength{\itemsep}{0pt}}}{\end{list}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}

Test

\textbf{Many Test much hurt}

\textit{Tester Rester}

$\frac{22}{33}$ How can I change the font of the numbers to be similar to Arial? It doesn't have to be Arial, just a similar font type. Heck there might be a more elegant solution?

\end{document}

• never use \usepackage[T1]{fontenc} with xetexm it forces the use of font encoding with 256 characters so breaks Unicode support, and xetex does not load any hyphenation tables for that encoding so hyphenation will be wrong. – David Carlisle Nov 28 '18 at 15:45
• I assume removing fontenc does the trick (see Herbert's answer), just another question in that context: Is there a substitute neccessary or not? The preamble which Herbert provided removes it completly alongside mathspec and replaces it with {unicode-math} – Shog64 Nov 28 '18 at 16:01
• you should use fontspec rather than fontenc but you are already using that (indirectly via mathspec) Herbert used unicode-math rather the mathspec but that also loads fontspec (the T1 and TS1 fonts are text related rather than math) – David Carlisle Nov 28 '18 at 16:12
• +1 for using the best option ever appeared in a class or package. ;-) – egreg Nov 29 '18 at 22:47

## EDIT:

You don't really need mathcomp either. I was doing the bare minimum to remove the font substitution from your document. If you use unicode-math package, as suggested by @Herbert in the other answer, you can revise my original answer to:

\documentclass[11pt]{scrartcl}

\usepackage{fontspec}
\usepackage{unicode-math}
\setmainfont{Arial}
\setmathfont{Cambria Math}

\begin{document}

°C
$°C$
Ω
$Ω$
‰
$‰$
μ
$μ$
‱
$‱$

\end{document}


As you can see, using unicode-math allows you to use the symbols directly in math mode also. You can get rid of mathspec and use the more standard fontspec options. And this approach still allows you to use Cambria Math. Again, the only issue is with the last symbol: ‱ (this time, also in math mode - because both Arial and Cambria Math do not appear to have ‱)

Bringing this all back together with your preamble, I've updated @Herbert's preamble to remove gensymb, textcomp, and mathcomp packages and use fontspec instead:

\documentclass[11pt]{scrartcl}

\usepackage{fontspec}
\usepackage{unicode-math}
\setmainfont{Arial}
\setmathfont{Cambria Math}

\usepackage{apacite}
\usepackage[showframe=true]{geometry}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{eurosym}
\usepackage{multirow}
\usepackage{siunitx}
\usepackage{natbib}
\usepackage[table,xcdraw]{xcolor}
\usepackage{array}
\usepackage[english]{babel}
\usepackage{geometry}
\usepackage{setspace}

\makeatletter
\newcommand{\MSonehalfspacing}{%
\setstretch{1.44}%  default
\ifcase \@ptsize \relax % 10pt
\setstretch {1.448}%
\or % 11pt
\setstretch {1.399}%
\or % 12pt
\setstretch {1.433}%
\fi
}
\makeatother
\MSonehalfspacing

\clearpairofpagestyles
\KOMAoptions{onpsinit=\setstretch{1}}

\makeatletter
\makeatother

\let\oldtabular\tabular
\renewcommand{\tabular}{\small\oldtabular}
\setkomafont{caption}{\small}

\setlength{\parindent}{0pt}

\usepackage{apacdoc}

\addto\captionsenglish{% Replace "english" with the language you use
\renewcommand{\contentsname}%
}
\usepackage{hyperref}
\def\UrlBreaks{\do\/\do-}

\makeatletter
\newcommand{\tocfill}{\cleaders\hbox{$\m@th \mkern\@dotsep mu . \mkern\@dotsep mu$}\hfill}
\makeatother
\newcommand{\abbrlabel}[1]{\makebox[4cm][l]{\textbf{#1}\ \tocfill}}
\newenvironment{abbreviations}{\begin{list}{}{\renewcommand{\makelabel}{\abbrlabel}%
\setlength{\itemsep}{0pt}}}{\end{list}}
\begin{document}

°C
$°C$
Ω
$Ω$
‰
$‰$
μ
$μ$
‱
$‱$

\end{document}


This produces the same image above.

## Original:

A quick note: this is not an error message. It is a warning message.

The real problem comes from \usepackage{gensymb}. If you comment that out (without any changes from your original example), the error is removed.

As others mentioned, you should also remove \usepackage[T1]{fontenc} and use \usepackage{fontspec} (which is loaded by mathspec anyway).

According to gensymb documentation, it seems to expect the textcomp package and loading \usepackage[T1]{fontenc}. The real question is... do you need exactly the symbols that gensymb? Or can you find the appropriate symbol elsewhere (such as the comprehensive symbols guide - which lists packages, if necessary)?

gensymb was written in 2003 and does not appear to have been updated since. The package only provides \de­gree, \cel­sius, \pert­hou­sand, \mi­cro and \ohm.

Using this MWE, however, I find you do not need gensymb or textcomp packages:

\documentclass[11pt]{scrartcl}

\usepackage{mathspec}
\setmainfont{Arial}
\setmathfont{Cambria Math}

\usepackage{mathcomp}

\begin{document}

°C
$\tccentigrade$
Ω
$\tcohm$
‰
$\tcperthousand$
μ
$\tcmu$
‱
$\tcpertenthousand$

\end{document}


So you see, you can just copy and paste the symbols directly (in text mode) and use the mathcomp commands in math mode.

The only real problem is that ‱ appears not to be available with Arial. You'll need to find either another package with the symbol, or another font for it.

EDIT: This will not work in pdfLaTeX, by the way.

• 1.Thanks for correcting me on the difference on warning and error 2. Just to make sure I understand your answer correctly: I remove the packages "gensymb" and "textcomp", than I add the package "mathcomp" on the preamble from Herbert downbelow which uses the "unicode-math" package. 3. I just want to make sure I am not missing anything which could lead to formatting errors etc., Step 2 is basically what I did and it compiles in XELATEX with no errors and -relevant- warnings (e.g. underfull badboxes due to being forced to use Arial in the first place...sigh.) – Shog64 Nov 29 '18 at 8:39
• No worries. It was just a nitpick. 2. It depends on your needs - what symbols are you actually using in your document? If you don't need any of the gensymb, textcomp, or mathcomp symbols... then you really don't need any of the packages. Impossible for me to determine from your minimal example. Try not including any of them and see if you get errors/warnings. 3. these packages do not appear to provide any formatting commands or changes... so I don't think you need to worry (unless you use/don't use and see changes other than the symbols)! – whatisit Nov 29 '18 at 17:49
• Feel free to correct me on this, but for some reason, using fontspec alongside unicode-math produces an actual error, after I reset my PC for some reason(as yesterday it worked fine). Note that the error consists of atleast 33 lines correlated with the input of my complete file(for example: missing } on \citep, which doesn't make sense, alongside other errors) Basically, %\usepackage{fontspec} aka removing fontspec let's me work with it again. I assume using both, fontspec and unicode-math loads the fontspec package twice? Or is \usepackage{fontspec} + \usepackage{unicode-math} neccessary? – Shog64 Nov 30 '18 at 10:14
• After looking in unicode-math, I find that fontspec is a required package - which I didn't specifically know or consider when posting this. However, I don't see unicode-math specifying any options for fontspec either... so, it's literally just loading fontspec at the beginning of unicode-math (which is effectively no different from manually loading fontspec first. By contrast, mathspec loads very specific options for fontspec and loading fontspec before it causes an error or warning. – whatisit Nov 30 '18 at 23:53
• As for your problem getting an error... that seems to be a problem with your installation (I'm just guessing). I compiled the code before posting it here and then copied and pasted without any changes. Recopying the example with full preamble above into a new document, I get no errors or warnings (except something about geometry...which is informational? and definitely unrelated. Could be due to an old version of something? Did you update recently? You might need to refresh the database. Let's talk via chat/PM at this point, because it gets away from the question/answer here. – whatisit Dec 1 '18 at 0:00

use this preamble and run thr document with xelatex:

\documentclass[hidelinks,11pt,egregdoesnotlikesansseriftitles]{scrartcl}
\usepackage{apacite}
\usepackage[showframe=true]{geometry}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{eurosym}
\usepackage{multirow}
\usepackage{siunitx}
\usepackage{gensymb}
\usepackage{unicode-math}
\setmainfont{Arial}
\setmathfont{Cambria Math}%an example, feel free to suggest something that works
\usepackage{natbib}
\usepackage[table,xcdraw]{xcolor}
\usepackage{array}
\usepackage[english]{babel}
\usepackage{geometry}
\usepackage{setspace}

\makeatletter
\newcommand{\MSonehalfspacing}{%
\setstretch{1.44}%  default
\ifcase \@ptsize \relax % 10pt
\setstretch {1.448}%
\or % 11pt
\setstretch {1.399}%
\or % 12pt
\setstretch {1.433}%
\fi
}
\makeatother
\MSonehalfspacing

\clearpairofpagestyles
\KOMAoptions{onpsinit=\setstretch{1}}

%\usepackage{textcomp}

\makeatletter
\makeatother

\let\oldtabular\tabular
\renewcommand{\tabular}{\small\oldtabular}
\setkomafont{caption}{\small}

\setlength{\parindent}{0pt}

\usepackage{apacdoc}

\addto\captionsenglish{% Replace "english" with the language you use
\renewcommand{\contentsname}%
}
\usepackage{hyperref}
\def\UrlBreaks{\do\/\do-}

\makeatletter
\newcommand{\tocfill}{\cleaders\hbox{$\m@th \mkern\@dotsep mu . \mkern\@dotsep mu$}\hfill}
\makeatother
\newcommand{\abbrlabel}[1]{\makebox[4cm][l]{\textbf{#1}\ \tocfill}}
\newenvironment{abbreviations}{\begin{list}{}{\renewcommand{\makelabel}{\abbrlabel}%
\setlength{\itemsep}{0pt}}}{\end{list}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

• Thank you very much, it works! I not only get the error message removed, it also seems to be able to work with other fonts: If this list is outdated, feel free to correct me :) Cam­bria Math , Min­ion Math Latin Modern Math TEX Gyre Pag­ella Math Asana-Math fonts , Neo Euler , STIX , and XITS Math – Shog64 Nov 28 '18 at 15:57
• I use alwys Libertinus Math with \usepackage{libertinus} it is automatically configured. – user2478 Nov 28 '18 at 16:16
• That particular warning (not error) message is removed with this preamble. However, it seems other warnings come. Package gensymb Warning: Not defining \perthousand. and Package gensymb Warning: Not defining \micro. and xdvipdfmx:warning: Unable to read OpenType/TrueType Unicode cmap table. and xdvipdfmx:warning: Failed to load ToUnicode CMap for font "CambriaMath" – whatisit Nov 28 '18 at 22:56
• I do not get the xdvipdfmx warnings. Up-to-date TeXLive 2018 – user2478 Nov 29 '18 at 6:07
• Interesting. I should have clarified that I am using and up-to-date MiKTeX. Also, I wasn't suggesting there were not improvements to the preamble. I simply ran into gensymb` warnings and for some reason the xdvipdfmx ones also. – whatisit Nov 29 '18 at 17:45