summaryrefslogtreecommitdiff
path: root/macros/generic/misc/tabto.tex
blob: 457bd9e4edc00890dc9373069e029833b7510239 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
%-------------- tabto.tex ------------
% Donald Arseneau   <asnd@triumf.ca>
%
% This software is contributed to the public domain.
% See tabto.sty for more useful definitions for LaTeX.
%
% Tab to a position relative to the left margin in a paragraph:
%   some text \tabto{1in} more text, and \tabto 3in final text.
% If the text on the line already goes past the desired position,
% the tab starts a new line.
% Note that braces are allowed, but not required.
%
 
\newdimen \scratchdim % or use \@tempdima in LaTeX
\newdimen \scratchDIM % or use \@tempdimb in LaTeX
 
% this preliminary mess is just TeX's awful way of reading a parameter
% with or without braces.
 
\def\tabto{\futurelet\nExt\tabtO}
\def\tabtO{\ifx\nExt\bgroup\let\nExt\TabTo\else\let\nExt\tabtOO\fi\nExt}
\def\tabtOO{\afterassignment\tabTOO\scratchDIM }
\def\tabTOO{\TabTo\scratchDIM}
 
\def\TabTo#1{\begingroup\leavevmode
\ifinner\scratchdim=0pt\relax   % in a \hbox, so ignore
\else % unrestricted horizontal mode
 \parfillskip=0pt plus 1fill % must swamp the -1fil glue
 \hfil\null\penalty20 \hskip0ptplus-1fil
 \hbox{\mathstrut\kern\hsize\kern-#1}\vadjust{\nobreak}\par
 \scratchdim=\prevdepth
 \prevdepth=-999pt % make sure I get an exact \baselineskip
 \parskip=-999pt   % but cancel the extra space
 \advance\parskip-\baselineskip % cancel the \baselineskip
 \advance\parskip-\scratchdim
 \noindent
\fi \hbox to#1{\vrule depth\scratchdim width0pt\hss}\endgroup
\ignorespaces}