typst: Can't use `over-/underline()` with any space symbol or `h()`
Description
I need to extend underline to the end of the line like this:
\documentclass{article}
\usepackage{ulem}
\begin{document}
Text or no text \uline{\hfill}
\end{document}
But neither #underline(h(100%)) (or 1fr) nor #underline(sym.space) is working. I didn’t find any of the settings that can replicate the same behavior, and #line() ignores any text + it is drawn automatically on the next line (not inline).
I consider this a bug, since it should work in theory, and it does work in LaTeX.
Update (v0.12.0)
Now #underline(sym.space) does work and as was pointed out in https://github.com/typst/typst/issues/1716#issuecomment-2435645252 #underline(box(width: 1fr, repeat(sym.space))) now also works. I tried pretty much all fonts that I use, and they all work. I think this should simplify some of my underline util functions.
Reproduction URL
No response
Operating system
Linux
Typst version
- I am using the latest version of Typst
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 7
- Comments: 17 (13 by maintainers)
I think this is a more universal version and all underlines (real/artificial) are on the same level (and have the same thickness).
You can (re)define any
box()arguments, including defaultwidth: 1fr(#ubox(width: 4cm)) and others.Basically, if there is no error, and everything works correctly, don’t use context blindly.
https://typst.app/docs/reference/context
Workaround by @bluss from here:
I’ve changed https://github.com/typst/typst/issues/1716#issuecomment-1690842054 to something like this:
I tried, and it looks good for any length, so I guess it’s precise. The main advantage over the old one is that the lines not only look uniform and as continuous lines on any zoom level (in Okular/MuPDF), but also you don’t have to fiddle with default offset/thickness anymore. And evasion obviously works. I also already changed one of my templates to this and it looks better, I guess basically like it supposed to.
You can use it like
#underline[ipsum]#ubox(width: ...), or make a wrapper like this:I have made a workaround helper today, hopefully useful for you:
Usage:
Try using this:
or
underlineskips whitespace I think.