1

I am trying to define three commands, say \wave, \underdots and \jagged such that \wave{hello} produces the word hello, with a wave underline it. Similarly, \jagged{hello} produces the word hello, with a jagged underline, and \underdots{word} produces a word with \circ-like symbols underneath it.

Hopefully, the commands would be able to adapt to variable-length text.

I don't even know where to get started with something like this. enter image description here

1

I actually copied most of this from an answer I posted some days ago here. Shame! 🔔 🔔 🔔

Using ulem (plus a tiny little bit of code to modify it ;)

enter image description here

\documentclass[a4paper,11pt]{article}
\usepackage{ulem}
\usepackage{graphicx}
\usepackage{xparse}
\usepackage{tikz}
\usepackage{tikzducks}
\usepackage{tikzmarmots}

\ExplSyntaxOn
\keys_define:nn { uline } {
  ,text   .code:n       = \cs_set:Nn \uline_text: { #1 }
  ,pre    .dim_set:N    = \l_uline_kern_pre
  ,pre    .initial:n    = 0.1em
  ,pos    .dim_set:N    = \l_uline_kern_pos
  ,pos    .initial:n    = 0.04em
  ,depth  .dim_set:N    = \l_uline_depth
  ,depth  .initial:n    = 0.08ex
}
\NewDocumentCommand{\SetULine}{ m }
  { \keys_set:nn { uline } { #1 } }
\cs_new:Npn \uline_text: { . }
\NewDocumentCommand\ULine
  { o }
  {
    \c_group_begin_token
    \IfValueT { #1 }
      { \keys_set:nn { uline } { #1 } }
    \use:c { UL@setULdepth }
    \markoverwith
      {
       \group_begin:
         \dim_add:Nn \ULdepth { \l_uline_depth }
         \box_move_down:nn { \ULdepth }
           {
             \hbox:n {
               \tex_kern:D \l_uline_kern_pre \scan_stop:
               \uline_text:
               \tex_kern:D \l_uline_kern_pos \scan_stop:
             }
           }
       \group_end:
      }
    \ULon
  }
\ExplSyntaxOff
\NewDocumentCommand\wave{}
  {%
    \ULine[%
      text = {\tikz[scale=0.01,very thin]\draw [variable=\x,domain=0:360,xscale=0.02,smooth] plot (\x,{cos(\x)});},
      pre = -0.11pt,
      pos = -0.11pt,
      depth = 0.05ex,
    ]%
  }
\NewDocumentCommand\jagged{}
  {%
    \ULine[%
      text = {\tikz[scale=0.03,very thin]\draw [variable=\x,domain=0:9,xscale=0.8,samples=10] plot (\x,{mod(\x,2)});},
      pre = -0.9pt,
      pos = -0.0pt,
      depth = 0.05ex,
    ]%
  }
\NewDocumentCommand\underdots{}
  {%
    \ULine[%
      text = {\scalebox{0.25}{$\circ$}},
      pre = 0.00pt,
      pos = 0.00pt,
      depth = 0.05ex,
    ]%
  }

\begin{document}
\pagenumbering{gobble}

Normal text hello there more text.

Normal text \wave{hello there} more text.

Normal text \jagged{hello there} more text.

Normal text \underdots{hello there} more text.

Normal text \ULine[text={\tikz[scale=0.05]\duck;},pre=-0.05em]{hello there} more text.

Normal text \ULine[text={\tikz[scale=0.10]\marmot;},pre=-0.05em,depth=1ex]{hello there} more text.

\end{document}
  • hmmm. Do you think that you could have the jagged be much more consistent? Like it would be constant lines (resembling /\/\/\/\\/\ rather than randomly generated?} – Michael Klyachman Sep 21 '18 at 17:50
  • @MichaelKlyachman Your drawing looks more random than consistent :) Anyway, I updated my answer. – Phelype Oleinik Sep 21 '18 at 17:57
  • Another question- how would I make the period of the cosine wave larger? I would like for it to be more streched out, but I can't seem to get the numbers right. Similarly, I would like the \wave to be more shallow and to have a longer period. Thanks in advance! – Michael Klyachman Sep 22 '18 at 1:06
  • 1
    +1 for \marmot. ;-) – marmot Sep 22 '18 at 5:10

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.