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
._._._._
_ _ _ _
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityHow 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}
Updated with the dashing and dashdot. Also doesn't effect spacing on the line below anymore.
\documentclass{article}
\usepackage{calc}
\newcommand{\underDotDash}[1]{%
\parbox[b][0pt][l]{0pt}{%
\raisebox{-.3ex}{%
\makebox[\widthof{#1}]{%
\xleaders\hbox{\rule{.8ex}{0.5pt}\,\rule{.5pt}{0.5pt}\,}\hfill}%
}
}%
\parbox[b][0pt][l]{0pt}{%
\raisebox{-.6ex}{%
\makebox[\widthof{#1}]{%
\xleaders\hbox{\rule{1ex}{0.5pt}\,}\hfill}%
}
}%
#1%
}
\begin{document}
Here is \underDotDash{some text}, doesn't it look wonderful? Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur imperdiet ante a turpis pulvinar, quis pharetra lorem finibus. Sed iaculis ritus sed molestie elementum. Duis porta maximus velit quis imperdiet. Sed nec lacis vitae nisl rutrum accumsan. Nam molestie purus hendrerit ex tempus volutpat. Donec luctus, nulla nec molestie eleifend, lectus sapien rhoncus nisl, id maximus diam ex sed metus. Present volutpat eu mi in vehicula. In lobortis vitae magna at finibus. Phasellus tempor urna eros, consequat blandit sem rhoncus a. Aliquam erat volutpat. Aliquam venenatis maximus felis, vel feugiat mauris tincidunt mattis. Maecenas accumsan metus nec tortor tempor maximus.
\end{document}
.
and _
aren't at the same high, so .\_
doesn't really produce a line