With ConTeXt, one generally uses \underbar to underline. \underline also exists, but only for mathematics. I also played a bit with the ideas proposed on this wiki page. My tests can be seen on the following MWE.

Hello, this is \underbar{a test}. And now, this is \underbar{a $a_{e}$ test}. 
And this is $\underline{\text{a } a_{e} \text{ test}}$. \\
And this is \myunderline{a $a_{e}$ test}.

enter image description here

However, none of these behaviors suit me. When there is a subscript, I would expect the bar to be broken and restart immediately after (like the underbar example, but restarting earlier and not underlying the subscript). I also notice that \underbar started inside a math environment behaves exactly like \underline.

Is it possible to tune this behavior ?

  • 2
    Related: petr.olsak.net/opmac-tricks-e.html#jumping – Henri Menke Jul 24 '16 at 8:39
  • This is indeed related, but OPmac is a plain TeX solution, I would like something more ConTeXt-like, or at least independant from OPmac. I tried to copy-paste the macro, then the called macros and so on... and finally, even if I input all opmac.tex, I get a "Missing number, treated as zero" error, so it doesn't seem to be a usable solution for a Plain TeX non-user. – A. Licari Jul 24 '16 at 9:12

Here is the ConTeXt-adapted OPMac solution. Keep in mind that because this is a box it doesn't break across lines.

  \dontleavehmode\vbox to0pt{\vss
    \hrule height.4pt
    \vskip-\baselineskip \kern2.5pt
    \hbox{\strut\rlap{\color[white]{\pdfliteral{2 Tr 1.5 w}#1\pdfliteral{0 Tr 0 w}}}#1}

\underlinee{a $a_{e}$ test}

enter image description here

  • 1
    @A.Licari This is actually not answer. It was just too long for a comment. I'm sure there is a better method using Metafun which I'm not capable of producing. – Henri Menke Jul 24 '16 at 9:18
  • Well, at least it is usable, plug-and-play, and it works. I think it is sufficient to be accepted, at least as long no one else submits a "better" answer. – A. Licari Jul 24 '16 at 9:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.