# Underlining with dash-dotted line

How to underline a word with a dash-dotted line?

Actually there should be the dash-dotted line under the word and under this line here should be a dashed line.

Note: I know, that underlining shouldn't be done.

Example:

longword
._._._._
_ _ _ _


Heavily based on https://tex.stackexchange.com/a/27260/36296

\documentclass{article}

\usepackage{tikz}

\newcommand{\mydash}[1]{%
\tikz[baseline=(todotted.base)]{
\node[inner sep=1pt,outer sep=0pt] (todotted) {#1};
\draw[dash dot] (todotted.south west) -- (todotted.south east);
\draw[dashed] ([yshift=-2pt]todotted.south west) -- ([yshift=-2pt]todotted.south east);
}%
}%

\begin{document}

\mydash{double line}

\end{document}


While the above solution is sensitive to the decent of the words to be underlined (e.g. if there are letters such as j in the words), the following will place the lines at the same position, regardless the characters.

 \documentclass{article}

\usepackage{tikz}
\usepackage{lipsum}

\newcommand{\mydash}[1]{%
\tikz[baseline=(todotted.base)]{
\node[inner sep=1pt,outer sep=0pt] (todotted) {\strut #1};
\draw[dash dot] ([yshift=3pt]todotted.south west) -- ([yshift=3pt]todotted.south east);
\draw[dashed] ([yshift=2pt]todotted.south west) -- ([yshift=2pt]todotted.south east);
}%
}%

\begin{document}

\mydash{doguble line}
\lipsum[2]

\mydash{double line}
\lipsum[2]

\end{document}

• this seems to affect the linespread. – Runar Sep 5 '16 at 18:55
• @RunarTrollet That depends. As far as I can see, the linespread is affected in case the lines take more space than the gap between the lines. But isn't this good? The alternative would be the lines interfering with the next line? i.stack.imgur.com/BKf1J.png – samcarter_is_at_topanswers.xyz Sep 5 '16 at 19:07
• Yes, I agree that in the case one uses a too big underline, that should happen to give a clear indication that the underlining is too big. But in my opinion one shouldn't make a underling that streches below the lowest part of characters, like g,y and such. Don't know the typographical name for this in English. – Runar Sep 5 '16 at 19:17
• @RunarTrollet I think they are called "decent". And you're right, I just tried my example with a decenting character and it looks horrible. I think I know why I use underlining only in handwritten text :) – samcarter_is_at_topanswers.xyz Sep 5 '16 at 19:31
• Thank you. There was a post here somewhere with some underlining which did not go into the descendants but left a bit of space around it, which made underlining almost beautiful. Cannot find it at the moment though. – Runar Sep 5 '16 at 19:36

Updated with the dashing and dashdot. Also doesn't effect spacing on the line below anymore.

### Code

\documentclass{article}
\usepackage{calc}
\newcommand{\underDotDash}[1]{%
\parbox[b][0pt][l]{0pt}{%
\raisebox{-.3ex}{%
\makebox[\widthof{#1}]{%
}
}%
\parbox[b][0pt][l]{0pt}{%
\raisebox{-.6ex}{%
\makebox[\widthof{#1}]{%

• Using . and _ aren't at the same high, so .\_ doesn't really produce a line – Ben Sep 4 '16 at 19:09