# Draw a short, inter-letter vertical line without affecting letter spacing

I want to draw small, thin separators between letters, without changing the letter spacing (tracking) in Xetex. Here's a failed attempt with \rule:

\documentclass{minimal}
\setlength{\parindent}{0cm}

\usepackage{fontspec}
\setromanfont[LetterSpace=50.0]{Noto Serif}
\newcommand{\mysep}{\rule[0.125em]{1pt}{0.5em}}

\begin{document}
HLHHLLH\\
HL\mysep{}HHL\mysep{}LH

\end{document}


Result:

I'd like the letters in the two lines above to line up with each other exactly, despite the extra separators in the bottom line. I'm open to alternative solutions like drawing stuff on tikz, as long as the result may be used inline, mid-text (unline, say, a tabular).

• @DavidCarlisle sorry about that. I must have garbled something when copy-pasting. Both issues are the same, since the paragraph-end \\⁠ was intended to start the missing line. I've fixed it now, and double-tested that the code results in the sample output this time. – melissa_boiko Apr 19 '17 at 16:19
• sadly I think it's quite hard to do (it would be easier in luatex:-) – David Carlisle Apr 19 '17 at 16:25
• oh you didn't require the letterspace spacing??? (judging from the accepted answer) That massively simplifies the problem:-) – David Carlisle Apr 19 '17 at 17:31

The code below defines a command \vlines[optional position]{letter sequence} such that the input

Some text \vlines{HL|HHL|LH} some more text.

Some text \vlines[t]{HL|HHL|LH} some more text.

Some text \vlines[b]{HL|HHL|LH} some more text.


results in

\documentclass{minimal}
\setlength{\parindent}{0cm}

% \usepackage{fontspec}
% \setromanfont[Scale=2,LetterSpace=50.0]{Noto Serif}
\newcommand{\mysep}{\rule[0.125em]{1pt}{0.5em}}

\makeatletter
\newcommand\vloop{\@ifnextchar|{\vloopa}{\vloopb}}
\makeatother
\newcommand\vloopa[1]{\let\sep\vline\vloop}
\newcommand\vloopb[1]%
{\ifx\relax#1%
\else
\sep
\let\sep\NoVline
#1%
\expandafter\vloop
\fi
}
\newcommand\sep{}
\newcommand\NoVline{\makebox[0.5em]{}}
\newcommand\Vline{\makebox[0.5em]{\mysep}}
\newcommand\vlines[2][]%
{\begin{tabular}[#1]{@{}l@{}}%
\let\vline\NoVline\def\sep{}\vloop#2\relax\\
\let\vline\Vline\def\sep{}\vloop#2\relax
\end{tabular}%
}
\begin{document}
Some text \vlines{HL|HHL|LH} some more text.
\bigskip

Some text \vlines[t]{HL|HHL|LH} some more text.
\bigskip

Some text \vlines[b]{HL|HHL|LH} some more text.
\end{document}


Edit: According to the comments only one line of equally spaced letters is needed, with separators in-between. This simplifies the code a bit.

\documentclass{minimal}
\newcommand{\mysep}{\rule[0.125em]{1pt}{0.5em}}

\makeatletter
\newcommand\vloop{\@ifnextchar|{\vloopa}{\vloopb}}
\makeatother
\newcommand\vloopa[1]{\let\sep\Vline\vloop}
\newcommand\vloopb[1]%
{\ifx\relax#1%
\else
\sep
\let\sep\NoVline
#1%
\expandafter\vloop
\fi
}
\newcommand\sep{}
\newcommand\NoVline{\makebox[0.5em]{}}
\newcommand\Vline{\makebox[0.5em]{\mysep}}
\newcommand\vlines[1]{\def\sep{}\vloop#1\relax}
\begin{document}
Some text \vlines{HL|HHL|LH} some more text.
\end{document}

• Thanks! I think I expressed myself poorly—I don't actually need to stack two rows in a single line; just to draw the vertical bars between evenly spaced letters in a normal, single text line. Still, your answer solves my problem. – melissa_boiko Apr 19 '17 at 16:47