I want to define a math symbol \dbar which will display its italic version normally, but display upright when it appears inside \mathrm.

My naïve attempt is something like this



$\dbar \mathrm{\dbar} \updbar$

which outputs:

enter image description here

This is expected since the stix2 package uses LS1 encoding for \mathrm, which has at position 158, while T1 encoding has đ at that position.

Is there a way to define the command \dbar so that it will display as


normally but display as


when it appears inside the scope of \mathrm? I do not want to modify the behavior of the stix2 package or of how any other glyph interacts with \mathrm. I would also be interested in hearing solutions involving the unicode-math package.

1 Answer 1


There are two different things \mathrm can mean: upright math symbols (such as constants in ISO style) and short lines of text in math mode.

Both Unicode and the T1 encoding have the đ (U+0111) character, as itself or \dj, so you could set \mathrm to either encoding and use \mathrm{\dj}.

However, you are more likely to want to define this command with \text from amsmath or amstext, or similar. A pair of commands for upright and italic math symbols might be:


If you really do want a command that changes its shape depending on whether you’re in math or text mode, that could be:




\( \dstroke \text{ is {\dstroke} in text mode.}\)

You must log in to answer this question.

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