0

Can I have different kinds of lines actually drawn using LaTeX boxes? I was curious to know about the definition of \underline{}. I am sure it uses boxes, because If I type something like this -

\documentclass{standalone}

\begin{document}
\underline{\underline{\underline{\underline{\underline{content}}}}}
\end{document}

I get five underlines, but with some significant space in between. Which means underline is defined as a box which doesn't intersect into another. I want exactly same function, but for curly underlines (like we get when we misspell a word.) but one important thing is if I use it twice, it should not clash with the first (as it happens in underline) I also wish to do this using plain TeX/LaTeX (without the help of packages like Tikz). I've read about package ulem, but I want to try it out on my own. Can somebody explain how the underline is defined?

Niranjan
  • 3,435
  • Underline is (basically) a TeX primitive. It knows the bounding box of its contents, so (quoting The TeXBook) "The \sqrt and \underline and \overline operations are able to place lines above or below subformulas of any size or shape; the bar lines change their size and position, so that they are long enough to cover the subformula, and high enough or low enough not to bump into it." – Phelype Oleinik Sep 11 '19 at 11:10
  • From where to look there actual code? I want to develope some similar functions? Can you explain them? – Niranjan Sep 11 '19 at 11:35
  • It's a TeX primitive, so you need to look at the TeX source (texdoc tex, section 735) for it's definition. But you can't change this primitive (perhaps with LuaTeX you can, I'm not sure) to print a squiggly line. I think you need to start from the code in soul or ulem and modify them to behave like \underline. – Phelype Oleinik Sep 11 '19 at 11:51
  • I don't want to change any functions. I just want to learn "how" underlines are drawn in TeX. I want to add some functios of my own. I'll check from the section referred by you. Thanks. – Niranjan Sep 11 '19 at 11:55
  • Note that "TeX primitive" basically means hardwired into the compiler. You'd have to change the compiler to add new such primitives, which is very likely not what you want. If the suggested packages don't suit your needs, one option would be using tikz with a similar approach described in this listings highlighting solution. – siracusa Sep 11 '19 at 12:52
  • @siracusa can't I apply the commands which are primitives without changing the compiler? Basically I wish to not use any package and achieve some lines, specialised boxes. Do you still think it is not possible without the help of package? If it is that complicated I'll think of using packages. – Niranjan Sep 11 '19 at 17:48
  • In theory anything is possible by just using primitive commands, that's how all of LaTeX and all packages are built from. However, especially in the case of graphical output (like curly lines) you'd have to use very low-level commands from the coresponding output format (DVI, PDF etc.). I don't think it's worth spending a lot of time re-implementing these things just to avoid the use of a package that has already done it and, like tikz, has alredy been tested by many, many users. – siracusa Sep 12 '19 at 09:15

0 Answers0