I am managing a XeLaTeX template for editing my own books, which, under mathspec
, allows me to pick some font families in my catalog and use them in the document.
Unfortunately, since frequently the discussion treats math equations as part of the text instead of formulas being shown, I want to take the main punctuation symbols of the text font (,
, .
, ;
and :
) and use them in the math mode.
The fonts used for text and for math are different and, the farthest I've done is to take one of the math fonts subsets (Digits
, Latin
or Greek
) to use the punctuation, but none of these font sets used for math mode has the same punctuation symbols used in text mode.
Sorry for including all the packages I normally use, but trying to remove some of them I think are unnecessary to provide a MWE gave me some random errors.
\documentclass[a4paper,12pt,twoside]{book}
\usepackage{indentfirst}
\usepackage{graphicx}
\usepackage{pdfpages}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{fdsymbol}
\usepackage{tabularx}
\usepackage{multirow}
\usepackage{multicol}
\usepackage{longtable}
\usepackage{xcolor}
\usepackage{colortbl}
\usepackage{paralist}
\usepackage{enumitem}
\usepackage{titleps}
\usepackage{mathspec}
\usepackage{polyglossia}
\usepackage{geometry}
\usepackage{lipsum}
\setdefaultlanguage{brazil}
\geometry{a5paper, left=2.000cm, right=2.000cm, top=2.800cm, bottom=2.800cm}
\defaultfontfeatures{Scale=MatchLowercase,Ligatures=TeX}
% ?
\XeTeXinterchartokenstate=1
% Declaring Font Families
\newfontfamily{\setpunctfont}[
Path = ./fonts/text/ ,
UprightFont = regular.otf ,
BoldFont = regular.otf ,
ItalicFont = regular.otf ,
BoldItalicFont = regular.otf ,
Scale = MatchLowercase ,
NFSSFamily = puncty
]{jPunct}
\setmainfont[
Path = ./fonts/text/ ,
UprightFont = regular.otf ,
BoldFont = bold.otf ,
ItalicFont = italic.otf ,
BoldItalicFont = bold-italic.otf ,
Scale = MatchLowercase
]{jMain}
\setmathfont(Latin)[
Path = ./fonts/math/ ,
UprightFont = latin.otf ,
BoldFont = latin.otf ,
ItalicFont = latin.otf ,
BoldItalicFont = latin.otf ,
Scale = MatchLowercase
]{jMathLatin}
% ?
\makeatletter
\ifx\e@alloc@intercharclass@top\@undefined
\chardef\CharBound=255
\else
\chardef\CharBound=\e@alloc@intercharclass@top
\fi
\makeatother
\chardef\CharBase=0
\newXeTeXintercharclass\CharPcts
\XeTeXcharclass"002C=\CharPcts
\XeTeXcharclass"002E=\CharPcts
\XeTeXcharclass"003A=\CharPcts
\XeTeXcharclass"003B=\CharPcts
\newtoks\TokenPunctFont
\TokenPunctFont={\begingroup\setpunctfont}
\XeTeXinterchartoks\CharBase\CharPcts=\TokenPunctFont
\XeTeXinterchartoks\CharBound\CharPcts=\TokenPunctFont
\XeTeXinterchartoks\CharPcts\CharBase={\normalfont\endgroup}
\XeTeXinterchartoks\CharPcts\CharBound={\normalfont\endgroup}
\DeclareSymbolFont{PunctSymb}{TU}{puncty}{m}{n}
\Umathchardef\MathPunctComma="3 \symPunctSymb "002C
\Umathchardef\MathPunctDot="3 \symPunctSymb "002E
\Umathchardef\MathPunctSemiColon="3 \symPunctSymb "003B
\Umathchardef\MathPunctColon="3 \symPunctSymb "003A
\begin{document}
ASP.<> $ASP.;,:<>$ \textbf{A.B,C} \textit{A,B;C.}. $\MathPunctDot$.
\end{document}
So, I want math .
to correspond to \MathPunctDot
and I can fix properly the another three punctuation symbols.