NOTE: I am searching for a LaTeX solution. The ConText code was offered, which is a good answer, but that doesn't fit my purpose.
I want to underline some words in text to show the parts of sentence. As mentioned in the comments, only words, not spaces between them should be underlined. Keeping hyphenation is preferable. Unfortunately, there is no dash-dotted
style presented in the ulem
package.
Here is the solution using TikZ (taken from Underlining with dash-dotted line)
\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 double line double line double line double line double line double line }
\lipsum[2]
\end{document}
No line breaking is allowed, which is bad. I want a solution that will not affect other text (will not widen the vertical space between lines, i. e. the dash-dotted line should have zero height) and will allow linebreaking.
Here Raise or lower \hrulefill some ways to create lines were discussed. egreg provided the following MWE:
\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn
\NewDocumentCommand{\xhrulefill}{O{}}
{
\group_begin:
\severin_xhrulefill:n { #1 }
\group_end:
}
\keys_define:nn { severin/xhrulefill }
{
height .dim_set:N = \l_severin_xhrule_height_dim,
thickness .dim_set:N = \l_severin_xhrule_thickness_dim,
fill .skip_set:N = \l_severin_xhrule_fill_skip,
height .initial:n = 0pt,
thickness .initial:n = 0.4pt,
fill .initial:n = 0pt plus 1fill,
}
\cs_new_protected:Nn \severin_xhrulefill:n
{
\keys_set:nn { severin/xhrulefill } { #1 }
\leavevmode
\leaders\hrule
height \dim_eval:n { \l_severin_xhrule_thickness_dim + \l_severin_xhrule_height_dim }
depth \dim_eval:n { -\l_severin_xhrule_height_dim }
\skip_horizontal:N \l_severin_xhrule_fill_skip
\kern 0pt
}
\ExplSyntaxOff
\setlength{\textwidth}{6cm} % just for the test
\begin{document}
abc\hrulefill
abc\xhrulefill
abc\xhrulefill[height=-3pt]
abc\xhrulefill[height=-2pt,thickness=1pt,fill=3cm]
abc\xhrulefill[height=-3pt,thickness=1pt]
abx\xhrulefill[height=0pt,thickness=1ex]
\end{document}
I wonder if it can be modified with xparse
of expl3
for my needs.
ulem
does provide\dashuline
which, as far as I can see, meets most of the requirements (except that it underlines also the spaces). In which respects is it not sufficient for you?