I’m trying to build a construct with a box of a fixed filled with \leaders
followed by \leaders
with \hfill
. However at the moment there is a little gap between these two making the pattern irregular, but I want equidistant symbols for the whole line. In the following MWE you'll see the problem in (output) line: The gap between ::::
and .....
is a bit too large (red arrows). Also the distance between A
and the following leaders is different depending on the presence of the \hbox
(green arrows).
It gets better with \cleaders
instead of \leaders
(as shown in the lower four lines).
\documentclass{article}
\newlength{\dotskip}
\setlength{\dotskip}{1mm}
\begin{document}
A \hbox to 20\dotskip {\leaders\hbox to \dotskip {\hss:\hss}\hfill}B
A \leaders\hbox to \dotskip {\hss:\hss}\hfill B
A \leaders\hbox to \dotskip {\hss.\hss}\hfill B
A \hbox to 5\dotskip {\leaders\hbox to \dotskip {\hss:\hss}\hfill}%
\leaders\hbox to \dotskip {\hss.\hss}\hfill B
\bigskip
A \hbox to 20\dotskip {\cleaders\hbox to \dotskip {\hss:\hss}\hfill}B
A \cleaders\hbox to \dotskip {\hss:\hss}\hfill B
A \cleaders\hbox to \dotskip {\hss.\hss}\hfill B
A \hbox to 5\dotskip {\cleaders\hbox to \dotskip {\hss:\hss}\hfill}%
\cleaders\hbox to \dotskip {\hss.\hss}\hfill B
\end{document}
Rephrased question
How can I align \leaders
contained in an \hbox
(colons in the example) with those lying on the “global” grid of \leaders
outside of an \hbox
(periods in the example).
\documentclass[a5paper]{scrbook}
\usepackage[right=50mm,marginparsep=5mm,marginparwidth=40mm,left=10mm]{geometry}
\usepackage{xcolor}
\setlength{\parindent}{0pt}
\newcommand{\margbox}[1]{%
\unskip\marginpar{%
\itshape
\tiny
#1\par
}\ignorespaces
}
\newlength{\dotskip}
\setlength{\dotskip}{3mm}
\begin{document}
{\tiny\itshape
\textcolor{green}{left edge of leader hbox grid box}\qquad
\textcolor{red}{middle of box}\qquad
\textcolor{blue}{right edge of box}
\par}
\kern0pt
\strut\leaders\hbox to \dotskip {%
\smash{\color{green}\vrule height 1ex depth 100mm width 0.15pt}%
\hss
\smash{\color{red}\vrule height 1ex depth 100mm width 0.3pt}%
\hss
\smash{\color{blue}\vrule height 1ex depth 100mm width 0.15pt}%
}\hfill\strut
\normalcolor
\minisec{\texttt{\string\leaders}}
A \hbox to 10\dotskip {\leaders\hbox to \dotskip {\hss:\hss}\hfill}B
\margbox{fixed width hbox}
A \leaders\hbox to \dotskip {\hss.\hss}\hfill B
\margbox{hfill}
A \hbox to 5\dotskip {\leaders\hbox to \dotskip {\hss:\hss}\hfill}%
\leaders\hbox to \dotskip {\hss.\hss}\hfill B
\margbox{fixed width hbox + hfill}
AAAA \hbox to 5\dotskip {\leaders\hbox to \dotskip {\hss:\hss}\hfill}%
\leaders\hbox to \dotskip {\hss.\hss}\hfill B
\margbox{fixed width hbox + hfill}
\minisec{\texttt{\string\cleaders}}
A \hbox to 10\dotskip {\cleaders\hbox to \dotskip {\hss:\hss}\hfill}B
\margbox{fixed width hbox}
A \cleaders\hbox to \dotskip {\hss.\hss}\hfill B
\margbox{hfill}
A \hbox to 5\dotskip {\cleaders\hbox to \dotskip {\hss:\hss}\hfill}%
\cleaders\hbox to \dotskip {\hss.\hss}\hfill B
\margbox{fixed width hbox + hfill}
AAAA \hbox to 5\dotskip {\cleaders\hbox to \dotskip {\hss:\hss}\hfill}%
\cleaders\hbox to \dotskip {\hss.\hss}\hfill B
\margbox{fixed width hbox + hfill}
\minisec{\texttt{\string\leaders}}
A \hbox to 10\dotskip {\xleaders\hbox to \dotskip {\hss:\hss}\hfill}B
\margbox{fixed width hbox}
A \xleaders\hbox to \dotskip {\hss.\hss}\hfill B
\margbox{hfill}
A \hbox to 5\dotskip {\xleaders\hbox to \dotskip {\hss:\hss}\hfill}%
\xleaders\hbox to \dotskip {\hss.\hss}\hfill B
\margbox{fixed width hbox + hfill}
AAAA \hbox to 5\dotskip {\xleaders\hbox to \dotskip {\hss:\hss}\hfill}%
\xleaders\hbox to \dotskip {\hss.\hss}\hfill B
\margbox{fixed width hbox + hfill}
\end{document}
The example starts with some colored lines showing the “global” grid (red line = middle of the boxes on the grid). And then the different results of \leaders
, \cleaders
and \xleaders
. In fact I wan’t the behaviour of \leaders
, i.e. stick to a grid, but it seems like an \hbox
gets its own grid instead of sticking to the global one.
\hfill
with\hskip 1em plus 1fill
. However for me the (rephrased) question is still interesting to learn more about the functionality of leaders.\gleaders
(whereg
stands for global) command which aligns the symbols on the largest enclosing box.