1

This question is related to this one: What are all the font styles I can use in math mode?

I would like to know if it is possible to use the command \varmathbb{}, that according to the accepted answer needs either the package txfonts or the package pxfonts (I am using the former), without extending the usage of the font to the entire document (thus leaving computer modern as the standard font).

Thanks a lot in advance for any feedback.

  • Indeed you are right. Terrible typo (but now corrected)! – Kolmin Jan 5 '18 at 14:22
3

Use the font defined by newtxmath, with some help (the characters are not in the standard font position).

\documentclass{article}
\usepackage{amsmath}
\usepackage{xparse}

% from newtxmath
\DeclareFontFamily{U}{ntxmia}{}
\DeclareFontShape{U}{ntxmia}{m}{it}{<-> ntxmia }{}
\DeclareFontShape{U}{ntxmia}{b}{it}{<-> ntxbmia }{}
\DeclareSymbolFont{lettersA}{U}{ntxmia}{m}{it}
\SetSymbolFont{lettersA}{bold}{U}{ntxmia}{b}{it}

\AtBeginDocument{\let\mathbb\varmathbb}

\ExplSyntaxOn
\NewDocumentCommand{\varmathbb}{m}
 {
  \tl_map_inline:nn { #1 }
   {
    \use:c { varbb##1 }
   }
 }
\tl_map_inline:nn { ABCDEFGHIJKLMNOPQRSTUVWXYZ }
 {
  \exp_args:Nc \DeclareMathSymbol{varbb#1}{\mathord}{lettersA}{\int_eval:n { `#1+64 }}
 }
\exp_args:Nc \DeclareMathSymbol{varbbk}{\mathord}{lettersA}{169}
\ExplSyntaxOff

\begin{document}

$\mathbb{A}\mathbb{B}\mathbb{C}\mathbb{R}\mathbb{Z}\mathbb{k}$

$\mathbb{ABCDEFGHIJKLMNOPQRSTUVWXYZk}$

\end{document}

enter image description here

  • Thanks a lot (as always). If there are no other options I will go for that, but – to me – it really looks very close to the standard \mathbb. – Kolmin Jan 5 '18 at 15:22
  • @Kolmin Sorry, I misinterpreted your requirement. Fixed. – egreg Jan 5 '18 at 15:51
  • Thanks a lot. This is (almost) what I was looking for. :-) That is, now everytime there is a \mathbbit switches automatically to that nice \varmathbb. However, can the two types of fonts coexist, with \mathbb as usual and also \varmathbb to get that nice effect? – Kolmin Jan 5 '18 at 18:07
  • 1
    @Kolmin Just remove the \AtBeginDocument{\let\mathbb\varmathbb} instruction and use \varmathbb{A} for the modified letters. – egreg Jan 5 '18 at 18:13
  • Great, thanks! (Sorry, I could open the page only now). – Kolmin Jan 6 '18 at 16:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.