[texhax] dotfill leaders on first line of paragraph only ?
Philip TAYLOR
P.Taylor at Rhul.Ac.Uk
Mon Dec 5 19:17:13 CET 2011
Philip TAYLOR wrote:
> and here it is. Please treat it as "proof of concept" only --
> it records (but does not make use of) \lastskip and \lastpenalty,
> and obviously these should be re-inserted into the re-built
> \vtop if it is to be a perfect replica of the one with which
> we started.
The following is, I hope, a final iteration, although if anyone
spots errors in it, do please let me know. As far as I can
tell, this rebuilds the \vtops correctly, including re-incorporating
the interline glue and penalties.
** Phil.
--------
% !TeX Program=XeTeX
\font \Text = "Palatino Linotype" at 11.25 pt
\font \Vietnamese = "Palatino Linotype: color=0000FF" at 11.25 pt
\font \English = "Palatino Linotype: color=003F00" at 11.25 pt
\font \Seqno = "Palatino Linotype: color=FF0000" at 11.25 pt
\font \Price = "Palatino Linotype: color=0000FF" at 11.25 pt
\newif \ifmore
\newskip \Lastskip
\newskip \Prevskip
\newcount \Lastpenalty
\newcount \Prevpenalty
\tabskip = 0 pt plus 1 fil
\hsize = 24pc
\let \nobreak = ~
\catcode `\~ = \catcode `\@
\parindent = 0 pt
\parskip = 3 ex
\showboxbreadth = 400
\showboxdepth = 3
\def \Note #1{{\Text #1} \vskip 1 ex }
\def \Shewsample #1
{
%%% \showbox #1
\halign {&##\hfil \cr {\Seqno 1. }&\copy #1&{ \Price £9-99}\cr}
}
\def \Sample #1%
{
\setbox 0 = \vtop
\bgroup
\parindent = 0 pt
\raggedright
\emergencystretch = 1 pt
\multiply \tolerance by 8
#1
\egroup
}
\def \Dotfilllineone
{
\vtop
\bgroup
\global \setbox 4 = \vtop {}
\setbox 6 = \vtop {\box 4 }
\parindent = 0 pt
\unvbox 0
\loop
\setbox 0 = \lastbox
\ifvoid 0
\morefalse
\global \setbox 4 = \vtop
{
\setbox 0 = \hbox to \hsize {\unhbox 2 \unskip \ \dotfill}
\box 0
\ifvoid 4
\else
\penalty \Prevpenalty
\vskip \Prevskip
\unvbox 4
\fi
}
\else
\moretrue
\Prevskip = \Lastskip \Lastskip = \lastskip \unskip
\Prevpenalty = \Lastpenalty \Lastpenalty = \lastpenalty \unpenalty
\ifvoid 2
\else
\global \setbox 4 = \vtop
{
\box 2
\ifvoid 4
\else
\penalty \Prevpenalty
\vskip \Prevskip
\unvbox 4
\fi
}
\fi
\setbox 2 = \box 0
\fi
\ifmore
\repeat
\egroup
}
\Note {First test : one-line item}
\Sample {{\Vietnamese Heo nồi đất} \English ~ Minced pork hot pot}
\Shewsample 0
\Dotfilllineone
\Shewsample 4
\Note {Second test : two-line item}
\Sample {{\Vietnamese Heo nồi đất} \English ~ Minced pork hot pot with tofu and aubergine}
\Shewsample 0
\Dotfilllineone
\Shewsample 4
\Note {Third test : three line item}
\Sample {{\Vietnamese Heo nồi đất} \English ~ Minced pork hot pot with tofu and aubergine, topped with peanuts, and with a\nobreak Vietnamese salad on the side}
\Shewsample 0
\Dotfilllineone
\Shewsample 4
\end
More information about the texhax
mailing list