Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I need to draw lines at specific distances (in mm). For example:

---- line 0
---- line 1 at 35.64 mm below line 0
---- line 2 at 33.64 mm below line 1

The macro I'm using is as follows (I don't remember from where I copied it):

\def\fr#1{
  \vbox{  
    \dimen0=#1
    %\advance \dimen0 by -2.41pt
    \advance \dimen0 by -1pt
    \vskip \dimen0
    \vrule height 0.5pt depth 0.5pt width 2in
  }
}

And I use it as follows:

\parindent=0pt
\baselineskip=-\maxdimen
\lineskiplimit=\maxdimen
\lineskip=0pt


\#0 \fr{1mm}
\#1 \fr{35.64}
\#2 \fr{33.64}

However I cannot get the lines to appear at the desired positions.

share|improve this question

2 Answers 2

This should be a matter of \vrule and \vskip only. The following should work:

\def\fr#1#2{\vskip #2\noindent\smash{#1}%
  \vrule height 0.4pt depth 0pt width 2in\relax}

\fr{0}{0mm}
\fr{1}{35.64mm}
\fr{2}{33.64mm}

\bye

Note how the \smash macro is used to prevent the numbers from adding any height or depth.

share|improve this answer
    
Is the AMS \smash very different in use/behaviour from plain \smash? –  morbusg Feb 22 '12 at 6:52
    
@morbusg: No, it's just that I didn't know Plain TeX also has it. –  Andrey Vihrov Feb 22 '12 at 7:25
    
i may be missing something, but doesn't the rule height accumulate? it's not smashed ... –  barbara beeton Feb 22 '12 at 15:17
    
@barbarabeeton: It does, and it's what I intended. The question asks for relative line position, not absolute. egreg has the other alternative, so let the op choose the correct one. –  Andrey Vihrov Feb 22 '12 at 16:30

A Plain solution (inspired by Andrey's one):

\def\fr#1#2{\vskip #2\smash{#1 \vrule height 0.4pt depth 0pt width 2in}}

\offinterlineskip

% A ruler in the margin to show alignment
\llap{\smash{\vtop to 100pt{
  \leaders\vbox to 20pt{\leaders\vrule\vfill\hrule width 2mm}\vfill}}}

\fr{0}{20pt}
\fr{y}{40pt}
\fr{2}{20pt}

\bye

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.