You could use this little snippet which defines \textify
. The control sequence \textify
takes another control sequence (for instance \exists
) and wraps it into \ensuremath{…}
.
I don't think that one needs to go through all the \GlobalLetLtxMacro
and \protected\gdef
hassle for simple things like \exists
, which is only a \mathchar
, but this should cover all weird edge cases.
N.B.: The \macro
in \textify\macro
may not take any mandatory arguments. Optional arguments will output as their default value. If the macro you want to textify needs any arguments a more complicated approach is needed.
\documentclass{article}
\usepackage{letltxmacro}
\newcommand\textify[1]{%
\expandafter\GlobalLetLtxMacro\csname textify@\string#1\endcsname#1%
\protected\gdef#1{\ensuremath{\csname textify@\string#1\endcsname}}%
}
\textify\exists
\textify\forall
\begin{document}
\exists $\exists$
\forall $\forall$
\end{document}
For reference, a non-letltxmacro
and non-protected version of \textify
would read
\newcommand\textify[1]{%
\global\expandafter\let\csname textify@\string#1\endcsname#1%
\gdef#1{\ensuremath{\csname textify@\string#1\endcsname}}%
}
which of course doesn't require the letltxmacro
package.
You’re loading polyglossia
, which loads fontspec
, and using an OpenType font. This is not compatible with the legacy package bm
.
One solution is:
\usepackage{unicode-math}
\defaultfontfeatures{ Ligatures=TeX, Scale=MatchLowercase }
\setmathfont{TeX Gyre Termes Math} % Or another math font
\setmathfont{Georgia}[range=up]
\setmathfont{Georgia Italic}[range=it]
\setmathfont{Georgia Bold}[range=bfup]
\setmathfont{Georgia Bold Italic}[range=bfit]
This will allow you to use \mathbf{1}
or \symbf{1}
. If you don’t ever use \mathbf
for words in math mode, you might use the option \usepackage[mathbf=sym]{unicode-math}
, and make \mathbf
a synonym for \symbf
. Theoretically, this invokes the bold alphanumeric symbols from your math font, rather than a text font, although here you’re setting them both to the same font anyway. You can still use \textbf
(or, more robustly, \textnormal{\bfseries ...}
) in math mode.
If you have a version of Georgia that supports lining numbers, you can additionally give the supplemental \setmathfont
commands the option Numbers=Lining
. Or, if you specifically want to use Georgia for letters and not numbers, you may specify range=up/{Latin,latin,Greek,greek}
, etc.
You can change the \mathbf
font, which is intended for words and short phrases in math mode, to something different from your main text font with \setmathrm[BoldFont={...}, BoldFeatures={...}]
. Alternatively, you can call \usepackage[no-math]{fontspec}
before polyglossia
to prevent it from changing \mathbf
, \mathrm
, and so on.
The unicode-math
package does support \boldsymbol
, but this calls \mathversion{bold}
. As of 2020, unicode-math
does not support both the version=bold
and range=
options of \setmathfont
at the same time, so you cannot reliably use \boldsymbol
and also change the letters in math mode.
Other options to change the math font to Georgia are mathastext
, or, in XeTeX, mathspec
.
Best Answer
The
mathtools
package has a\DeclarePairedDelimiter
command which lets you define such macros. I defined a\nint
command which encloses its argument between\lfloor
and\rceil
. The starred version adds a pair of implicit\left
...\right
, but you may fine-tune the delimiters size using one of\big
,\Big
,\bigg
,\Bigg
as an optional argument.