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'm struggling with this really simple (vanilla plainTeX) trick, which I'm not able to crack...

How does one draw a vertical (i.e. perpendicular to the horizon) line that leads from the top (or top margin or as topmost as possible) of the current page to the current position (specifically the position of text at the time where the macro solving this problem is called)?

P. S. It may have unclear but the current position is meant including both the horizontal and vertical position. I. e.

Here I \myruler am...

Another paragraph...

would produce sth like

       |
       |
       |
       |
       |
Here I | am...

Another paragraph...
share|improve this question

2 Answers 2

One possibility is to use the \pagetotal dimension which holds the accumulated natural height of the current page:

\newdimen\ruleht
\def\myrule{\par
  \ruleht=\pagetotal
  \vskip-\the\ruleht\llap{\vrule height\the\ruleht}
}

\def\Text{%some filler text for the example
text text text text text text text text text text text text text text text text 
text text text text text text text text text text text text text text text text 
text text text text text text text text text text text text text text text text 
text text text text text text text text text text text text text text text text 
text text text text text text text text text\par}

\Text\Text\myrule

\bye

enter image description here

share|improve this answer
    
ThX for the answer. However, can you tell how to do it with regard to horizontal position (viz edited question). Sorry, my bad for previously being unclear... –  mathemage Aug 26 '12 at 11:38

Building on Gonzalo's answer, maybe something like

\hsize=24pc
\def\lipsum{Lorem ipsum dolor sit amet. }
\def\llipsum{\lipsum\lipsum}
\def\lipsumV{\llipsum\llipsum\lipsum}
\def\pgtotrule{\dimen0=\pagetotal
  \advance\dimen0 by\ht\strutbox
  \advance\dimen0 by\baselineskip
  \smash{\vrule height\dimen0 depth\dp\strutbox}}

\lipsumV
\lipsumV

\llipsum \lipsum \pgtotrule \lipsumV

\bye

enter image description here

share|improve this answer
    
Unfortunately your solution doesn't always work; for example, with your settings and text given by \lipsumV \llipsum \lipsum \pgtotrule \lipsumV it won't give the desired rule. \pagetotal doesn't get the needed value. –  Gonzalo Medina Aug 26 '12 at 15:03
    
@Gonzalo: Yes, true. I think \pagetotal only updates in vertical mode, but setting a custom dimen inside a \vadjust doesn't seem to have any difference. Puzzling. –  morbusg Aug 26 '12 at 15:27
    
Yes, puzzling, indeed. I was thinking about using \lastbox for the current paragraph to measure the current depth inside the paragraph, but my attempts failed. –  Gonzalo Medina Aug 26 '12 at 15:34
    
i suspect this needs \pdfsavepos, then saving the values to a label-like structure, in a file which will be read next time the document is compiled. i know of no support in plain tex for this, but it's pretty trivial if you only need one of these odd constructions; in latex it's supported by heiko oberdiek's zref package, which allows any number of the things, stored in the extended labels that package offers. –  wasteofspace Aug 26 '12 at 16:31

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.