How to use arguments with hyphens in math mode

How can you use arguments with hyphens in math mode? E.g.,

$mat(1, 2, 3; 4, 5, 6; delim:"[")$ // works
$mat(1, 2, 3; 4, 5, 6; column-gap: #2pt)$ // does not work

The issue here is of course the hyphen being interpreted as a minus sign. I realize that you can set arguments like column-gap beforehand, but this is somewhat tedious if you want to change the value of this parameter for just a single use of mat amongst many.

For variables with hyphens or underscores, you can use # in math mode:

#let this-variable = 5
$ (#this-variable - a) / b $

…but this approach does not work for arguments:

$mat(1, 2, 3; 4, 5, 6; #column-gap: #2pt)$ // does not work
2 Likes

I used the hashtag to invoke the function explicitly:

$#math.mat(column-gap: 2pt, (1, 2, 3), (4, 5, 6))$

This workaround does lose some flexibility afforded to the maths mode.

1 Like

Your answer seems to be the closest thing to a solution, so I will mark it as such, though I’m bummed there’s no way to use it directly without needing to use #.

Indeed. Given the following is an example from the official documentation, what you’ve seen seems like a bug.

$ vec(1, 2, delim: "[") $
1 Like

This is actually in a PR right now by mkorje!

1 Like