Is it possible to make $bx$ show as $bold(x)$?

$bx$ usually results in error: unknown variable: bx, so I thought why not turn it into a way to make x bold?

I am not sure how exactly I would go about doing this though, and if it is even possible in Typst. Any ideas?

You can define the variable bx as being a bold x in math mode:

#let bx = $bold(x)$
1 Like

Thanks @Simon2. I was also wondering if it were possible to make a single function for any character to become bold. It sounds like the only way would be to generate a lot of variables, but maybe I’m wrong.

Yes. It is actually already mentioned by @Simon2: it’s bold.

1 Like

I think they want to use the b prefix as a short form for bold(x): ba for bold(a), bb for bold(b), …

I don’t think there is a way to do this without manually defining all variables manually.

1 Like

I’m pretty sure it is impossible since the bx would be recognized as a variable and throws an exception before anything else could modify it. You could use a regex and "bx" in your equation, but at this point it’s ugly and not that much shorter than bold(x) so…

You might as well define a shorter abbreviation for bold like the vb from the physica package. If you want to define the b… variables programmaticaly, you could just generate the code with the following Python function:

def bold_vars(letters: str = None) -> str:
    if letters is None:
        letters = (chr(i) for i in range(ord("a"), ord("z")+1))
    return "\n".join(f"#let b{c} = $bold({c})$" for c in letters)

print(bold_vars("abcxyznmXY"))
1 Like