How do you create delimited sequences with a missing right or left delimiter?

In LaTeX, this can be done by writing one delimiter as \left. or \right.. This notation is commonly used to express derivatives at a specific point:

\[\left. \frac{\mathrm{d}}{\mathrm{d}x} x^2 \right|_3 = 6\]

I have tried:

$ lr(dif / (dif x) x^2 |_3) &= 6 $

but this does not work.
The following does seem to work:

$ lr(dif / (dif x) x^2 |)_3 &= 6 $

but I am not sure if the spacing is correct and am uneasy about the document semantics now reflecting the subscript attaching to the expression as a whole, not the right delimiter.

Additionally, the above would not work if the expression had an unclosed left parenthesis, e.g.:

$ lr(\( sum^* |) $

will always size the parenthesis and the bar together, which is not necessarily desirable.

If there is no reliable way to do this currently, might I suggest the following change:

Make lr take optional named arguments left and right, which can be content, none, or auto. The default is auto, in which case the delimiter is inferred from the text. Otherwise the provided content is affixed and sized appropriately, unless none is used. Since math mode would not interpret none as a literal, perhaps a string can be passed instead, which is either interpreted as a delimiter, e.g. "(", "|", or "none", or "auto". Perhaps, in analogy to mat, a delim parameter could be provided, too, which would take either the left delimiter with an implicit mirrored right delimiter, or a tuple.

$ lr(x^2 - sum_(i = 0)^infinity (-1)^i x!|_1, left: "none") $

Upon further thought this seems to be two only somewhat interrelated issues.

  1. lr does not interpret a delimiter with an attachment as a delimiter.
    This is what causes lr(x|_y) to not work.
  2. lr has no way of ignoring a delimiter.
    This is what makes lr(\(x|) correct only some of the time.

the simplest solution I see is to do:

$
lr(dif / (dif x) x^2 |)_3 = 6
$

as lr doesn’t necessarily need to have both sides.
you just contain the block that you want the | to size in reference to.
Hope this helps!

This is indeed the correct way to do it. As for the document semantics, it is obviously more complex to read than without lr, but it is only used here to specify that | must scale with the rest of the previous content.

About the subscript, it is not only semantics, but it is actually attached to lr.

I think this is known, see Different parsing in LR longhand vs shorthand: `lr([..])` vs `[..]` · Issue #2979 · typst/typst · GitHub.