\def\testfileincipit{Test file to accompany \texttt{mathastext} version \texttt{v1.2f} of \texttt{2013/01/21.}} %% %% Package `mathastext' by Jean-Francois Burnol %% Copyright (C) 2011, 2012 by Jean-Francois Burnol %% %% This file `testmathastextalphabets.tex' is for testing the extended %% scope of the math alphabet commands with package `mathastext', via %% the package command \MTnonlettersobeymathxx. %% %% Compile either with latex, pdflatex, lualatex (pdf output) or xelatex. %% %% See `mathastext.dtx' for the copyright and conditions of distribution or %% modification. %% \documentclass{article} \usepackage[hscale=0.66]{geometry} \usepackage{amsmath} \usepackage{mathtools}\mathtoolsset{centercolon} %% WARNING THIS IS INCOMPATIBLE WITH BABEL+FRENCHB %% BUT WITH MATHASTEXT LOADED THIS IS CORRECTED %% *IF* \MTnonlettersobeymathxx IS MADE USE OF. \usepackage{iftex} \ifXeTeX \usepackage[no-math]{fontspec} \setmainfont[ExternalLocation, Mapping=tex-text, BoldFont=texgyretermes-bold, ItalicFont=texgyretermes-italic, BoldItalicFont=texgyretermes-bolditalic]{texgyretermes-regular} \setmonofont[ExternalLocation, Mapping=tex-text]{texgyrecursor-regular} \setsansfont[ExternalLocation, Mapping=tex-text]{texgyreheros-regular} \else \ifLuaTeX % for pdf output \usepackage[no-math]{fontspec} \setmainfont[Ligatures=TeX]{TeX Gyre Termes} \setmonofont[Ligatures=TeX]{TeX Gyre Cursor} \setsansfont[Ligatures=TeX]{TeX Gyre Heros} \else \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{tgtermes} \usepackage{tgcursor} \usepackage{tgheros} \fi\fi \usepackage{metalogo} % must be loaded /after/ [no-math]fontspec \usepackage[french]{babel} \usepackage[italic,asterisk]{mathastext} \MTlettershape{n}\Mathastext[upright] \MTnonlettersobeymathxx \MTexplicitbracesobeymathxx \delimitershortfall-1pt \begin{document} \testfileincipit The package makes ${!}\,{?}\,{,}\,{:}\,{;}\,{+}\,{-}\,{=}\,{(}\,{)}\,{[}\,{]}\,{<}\,{>}\,{\{}\,{\}}$, the asterisk $*$, and $.\,/\,\vert\,\backslash\,{\#}\,{\$}\,{\%}\,{\&}$ obey the math alphabet commands (this is the maximal list, some characters may have been excluded by the corresponding package options). For the characters listed first the mechanism involves a `mathematical activation'. As this process may create incompatibilities, it will be put into action for ${!}\,{?}\,{,}\,{:}\,{;}\,{+}\,{-}\,{=}\,{(}\,{)}\,{[}\,{]}\,{<}\,{>}$ only if the user makes use of the package command \verb|\MTnonlettersobeymathxx| (and the braces necessitate \verb|\MTexplicitbracesobeymathxx|). It could be that one such character has been made `active' in the entire document by some other package, typically a language definition file for the \verb|babel| system. Here for example we have used \verb|babel| with the \verb|french| option, which makes the high punctuation characters !?:; active throughout the document (extra spacing is put in front of the character when used in text; no change in math but perhaps for other languages and characters this could happen, it is up to the language definition file to decide). When \verb|mathastext| detects that a character it wants to `mathematically activate' is already `active', it does not go further except if it seems that the activation was done by Babel. If the activation was done by Babel, then \verb|mathastext| replaces the expansion of the active character in math mode by what is necessary to achieve its goal. It does not additionally mathematically activate the character; rather it makes sure that the character is \emph{not} mathematically active. In the present document the colon was made mathematically active by \verb|mathtools| but this was already canceled in the preamble by \verb|mathastext| as it was loaded later. And it is better so, because the combination \verb|babel| (with option \verb|frenchb|) +\verb|mathtools| (with \verb|centercolon|) makes \verb|$:$| create an infinite loop! But even if someone had mathematically activated the colon after the preamble, or after the loading of \verb|mathastext|, this would be canceled again automatically for each inline or displayed mathematical formula (if the user does \verb|\MTnonlettersobeymathxx|). The conclusion with \verb|\MTnonlettersobeymathxx| is: if some package has tried to make the character mathematically active, this will be overruled by \verb|mathastext|; if some package has made the character globally active, then the package wins except if it is Babel, as \verb|mathastext| may in the latter case safely modify the action in math mode (paying attention to the fact that the character should be usable in \verb|\label| and \verb|\ref| in and outside of math mode). The displayed equations below have been labeled using various characters from our list, to test if it works ok with then. \def\testformula{\Biggl\lbrace\biggl(\left(\left[[\sin(a) + \cos(b) - \log(c) = \sec(d)]\right]\right)\biggr)\Biggr\rbrace} \begin{equation}\testformula\label{eq:1}\end{equation} \begin{equation}\mathnormalbold{\testformula}\label{eq;2}\end{equation} \begin{equation}\mathrm{\testformula}\label{eq?3}\end{equation} \begin{equation}\mathbf{\testformula}\label{eq!4}\end{equation} \begin{equation}\mathit{\testformula}\label{eq(5}\end{equation} \begin{equation}\mathtt{\testformula}\label{eq)6}\end{equation} \begin{equation}\mathsf{\testformula}\label{eq=7}\end{equation} Equations above are numbered \ref{eq:1}, \ref{eq;2}, \ref{eq?3}, \ref{eq!4}, and $\ref{eq(5}$, $\ref{eq)6}$, and $\ref{eq=7}$. \def\testline#1{$#1$&$\mathnormalbold{#1}$&$\mathrm{#1}$&$\mathbf{#1}$&$\mathit{#1}$&$\mathtt{#1}$&$\mathsf{#1}$} \begin{tabular}{ccccccc} \testline{a!b}\\ \testline{a?b}\\ \testline{a,b}\\ \testline{a;b}\\ \testline{a:b}\\ \testline{a:=b}\\ \testline{a\vcentcolon= b}\\ \testline{a\colon b}\\ \testline{a.b}\\ \testline{a-b}\\ \testline{a+b}\\ \testline{a=b}\\ \testline{ab}\\ \testline{}\\ \testline{\mathopen{<} x,y\mathclose{>}}\\ \testline{\left< x,y\right>}\\ \testline{a/b}\\ \testline{a\backslash b}\\ \testline{a\setminus b}\\ \testline{a|b}\\ \testline{a\mid b}\\ \testline{(a,b)}\\ \testline{[a,b]}\\ \testline{\{a,b\}} \end{tabular} The question mark has been made active by \verb|babel+frenchb|. \verb|mathastext| has imposed in math mode its ways (now \verb|$\mathbf{???}$| gives $\mathbf{???}$). As the extra spacing is added by \verb|frenchb| only in text, we had to use the math alphabet to check that indeed \verb|mathastext| overruled Babel. To double-check we will now make \string? mathematically active: \verb|\mathcode`?="8000|\mathcode`?="8000. This is a sure cause for disaster normally with Babel (don't do this at home without \verb|mathastext|!). But here with \verb|$?$| no bad surprise (infinite loop!) awaits us: just $?$. Let's take some other character which was not made active by \verb|babel+frenchb|, for example the opening parenthesis: \verb|\catcode`(=\active \def ({X}|. Let's try now \verb|( vs $($|.\begingroup\catcode`(=\active \gdef ({X} This gives ( vs $($\endgroup. We see that \verb|mathastext| does not attempt anything (this could not safely be done for technical reasons). We have now cancelled the activation of the parenthesis, and let's make it only mathematically active with \verb|\mathcode`(="8000|.\mathcode`(="8000\ If we try \verb|$((($| we see that nothing special happens $((($. The mathematically active character was overruled by \verb|mathastext|. But if we now issue \verb|\MTnonlettersdonotobeymathxx|\MTnonlettersdonotobeymathxx\ we get $((($ from the input \verb|$((($|. This shows that indeed the parenthesis had been made mathematically active. By the way don't do this at home without \verb|mathastext|: \verb|amsmath| is not compatible with a mathematically active opening parenthesis, and \verb|mathastext| does a patch. Always load \verb|amsmath| before \verb|mathastext|. \MTversion{upright}\MTnonlettersobeymathxx We defined in the preamble of the document a \verb|mathastext|-enhanced math version (named \verb|upright|) having the Latin letters upright in math mode. Let's switch to it.\footnote{\texttt{\char92MTversion\{upright\}}. This maintains the status of the `difficult non-letters'.}\footnote{as we left \string? mathematically active, we initially had the bad surprise to fall into an infinite loop. And indeed we had forgotten our previous \texttt{\char92MTnonlettersdonotobeymathxx}. So a new \texttt{\char92MTnonlettersobeymathxx} was done to prevent this problem of \texttt{babel} when it activates a character which is mathematically active.} Then, italic corrections are added,\footnote{this has an effect only with \LaTeX{} and PDF\LaTeX{} not with \XeTeX{} or \LuaLaTeX{}.} as we can see here, to correct the positioning of the subscript: $f_i^i$. After using \verb|\MTnoicinmath| to turns off the feature\MTnoicinmath{}, this is $f_i^i$. Let's turn it back on (\verb|\MTicinmath|)\MTicinmath{} and try \verb|$f_{abc}^{def}$|, this gives $f_{abc}^{def}$, or this other one: $f^{f_{abc}^{def}}_u$. Without italic corrections\MTnoicinmath: $f_{abc}^{def}$, and respectively $f^{f_{abc}^{def}}_u$.\MTicinmath We can also check that the added italic corrections do not prevent the formation of ligatures when using the math alphabets, apart from \verb|\mathnormal| (which comes first): $\mathnormal{ff}$, $\mathrm{ff}$, $\mathit{ff}$, $\mathbf{ff}$, $\mathtt{ff}$ (no ligature in teletype) and $\mathsf{ff}$. \begin{tabular}{ccccccc} \testline{a!b}\\ \testline{a?b}\\ \testline{a,b}\\ \testline{a;b}\\ \testline{a:b}\\ \testline{a:=b}\\ \testline{a\vcentcolon= b}\\ \testline{a\colon b}\\ \testline{a.b}\\ \testline{a-b}\\ \testline{a+b}\\ \testline{a=b}\\ \testline{ab}\\ \testline{}\\ \testline{\mathopen{<} x,y\mathclose{>}}\\ \testline{\left< x,y\right>}\\ \testline{a/b}\\ \testline{a\backslash b}\\ \testline{a\setminus b}\\ \testline{a|b}\\ \testline{a\mid b}\\ \testline{(a,b)}\\ \testline{[a,b]}\\ \testline{\{a,b\}} \end{tabular} \end{document} \endinput %% %% End of file `testmathastextalphabets.tex'.