If I want to typeset conditional probabilities (e.g. P[A | B]) or set-builder-notation (e.g. {x | x ∈ ℝ}), what symbol should I use for the vertical bars? Candidates are bar.v (producing and equivalent to “|”) and divides (producing and equivalent to “∣”).
Arguments for bar.v:
Found on most keyboards, hence significantly easier to type
The official docs use it in set-builder-notation examples, e.g. here.
The vertical bar in conditional probabilities and set-builder-notation has nothing to do with divisibility, so using a symbol called divides seems unidiomatic.
Arguments for divides:
Before issue #306 (sorry, I can only add two links per post) got fixed, I think divides was the only way to typeset conditional probabilities and set-builder-notation? Nowadays, both divides and bar.v produce very similar (though not identical!) output.
The LaTeX-counterpart to bar.v is \vert, and the LaTeX-counterpart to divides is \mid. In LaTeX, conditional probabilities and set-builder-notation should be typeset with \mid, according to this stackexchange answer.
One rather common suggestion would be to use mid(|) i.e the regular bar but with a call out to mid which ensures it has the same height as the surrounding brackets. I won’t vote for which symbol to use, but use one with mid. physica has a Set function and uses mid(|).
The behavior of bar.v and its shorthand | is quite special: it’s a “fence” symbol which means it doesn’t have clear semantics: it can represent a delimiter as in |x| (absolute value) or a kind of relation as in P[A | B]) or {x | x ∈ ℝ}.
Currently Typst adds spacing around | when there is a space in the source code. You can even have space on only one side and this will be reflected in the output. The same applies to bar.v but to have no source space you need to write a#{}bar.v#{}b.
This has been discussed in this issue and on discord. As hinted on discord the treatment of | might change in the future. And the treatment of mid(|) will probably change soon when this PR is merged.
In summary if you care about the semantics and the details in spacing you should use abs(...) and mid(|) instead of a bare |.
As you say, the question that remains is: For conditional probabilities and set-builder notation, should we use mid(|), or divides (and mid(divides) for auto-scaling)? Now comes another complication: when you write mid(|), Typst will use U+007C (i.e. bar.v) if the symbol is not scaled, but it will actually use U+2223 (i.e. divides) if scaling is necessary. I’d be interested to read the Unicode meeting discussions on this subject since it seems like the “divides” symbol is being abused for something else (I don’t know how to find the relevant meeting minutes).
Anyway here’s my answer: I would use mid(|) as this gives Typst all the information it needs to use the correct symbol and spacing, and as a bonus it’s shorter to type, and it reads better than “divides” which reads semantically wrong even if it’s actually the symbol that gets used by mid(|) behind the scenes.