I created a custom font Computer Modern Roman Blackboard Bold, similar to the Computer Modern Roman - italic as the following image:

enter image description here

As you can imagine, I want to implement this font in math-mode such as \cmrbb{hello} or maybe substitute \mathsf alphabet for mine, then rename a new command \cmrbb.


  • I'm using fontspec
  • I'm using LuaLaTeX
  • I have some packages like amsmath, amssymb, mathtools (I don't know if it can cause trouble)
  • I want to use the new font as a simple command like \cmrbb{text} inside math-mode
  • I'm working currently on Overleaf and have loaded cmrbb.ttf

I have no idea how I can do it, I tried using mathspec but the document doesn't even compile (I think it only works in XeLaTeX).

And just in case there is no incompatibility, I don't use any command for font encoding, and I have already loaded some fonts. I don't know much about fontspec, any additional information to make it easier to implement the solution would be really helpful.

  • If anyone is looking for CM outline style upright blackboard letters, then the cmathbb package provides it. Unfortunately, it works only on Windows as of now due to a bug. ctan.org/pkg/cmathbb Commented Jan 21 at 12:03

1 Answer 1


It's not clear if your font is OT1 encoded like the original cmr or TU Unicode encoded, but basically

\DeclareMathAlphabet      {\cmrbb}{OT1}{cmrbb}{m}{n}


\DeclareMathAlphabet      {\cmrbb}{TU}{cmrbb}{m}{n}

together with a suitable fd file if using OT1 and declare the font using \newfontfamily\cmrbbfam[NFSSFamily=cmrbb] if using TU encoded fonts.

An example (produced with xelatex) using some opentype font found on this system, the declarations would be the same for any font.

enter image description here


\newfontfamily\cmrbbfam{Goudy Stout}[NFSSFamily=cmrbb]
\DeclareMathAlphabet      {\cmrbb}{TU}{cmrbb}{m}{n}


  a=\cmrbb{N}+\cmrbb{xyz} + y
  • \DeclareMathAlphabet{\cmrbb}{OT1}{cmrbb}{m}{n} with OT1 or TU uses the computer modern roman font (the default in text-mode) and with the \newfontfamily it returns the error Package fontspec Error: The font "N" cannot be found. I added in the specifications that I'm using Overleaf and I've loaded cmrbb.ttf in between the documents, just in case it has to do with it.
    – Agente 156
    Commented Jan 21 at 11:29
  • @Agente156 I added an example for xelatex Commented Jan 21 at 12:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .