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 trying to create a document which looks like it's been printed on a ruled page. I know I can probably do this in tikZ, but I would like to be able to do this in pstricks.

The option absolute for the package pst-abspos only works correctly when the first command on a given page is \pstSetAbsoluteOrigin. If LaTeX is making the page breaks for me then I need a way to automatically call this.

To remedy this, I thought I could use afterpage to issue the \pstSetAbosluteOrigin at the beginning of each page. However, afterpage only seems to take effect on the second page of my document.

Here's my MWE:

\documentclass{article}
%--------------------------------------------------------------------------------%
\usepackage{multido}
\usepackage[absolute]{pst-abspos}
\psset{unit=1cm}%
\newcommand{\myrules}{%
    \pstSetAbsoluteOrigin%
    \pstPutAbs[](0.0,0.0){%
    \begin{pspicture}(0,0)(0,0)
        \multido{\rx=-2.5+-0.50}{50}{\psline[linecolor=blue!20](0,\rx)(\paperwidth,\rx)}%
        \psline[linecolor=red](2.5,0)(2.5,-\paperheight)
    \end{pspicture}}}
%--------------------------------------------------------------------------------%
\usepackage{lipsum}
\usepackage{afterpage}
\afterpage{\myrules}
\begin{document}

\lipsum[1-114]

\end{document}

I can duplicate this unexpected behavior of \afterpage with or without pst-abspos such as with \afterpage{Hello World}. But, I was worried that I'd get solutions that would work with something so minimal but not cooperate with the pst-abspos tricks I'm trying.

EDIT

After reading the documentation for afterpage for the umpteenth time now, I see that it only take effect after the current page. So, I guess what I want is something more like aftereverypage.

I know there's an everypage package, but when I use \AddEverypageHook{\myrule}, the formatting of the rules is completely wrong.

When I use the everyshi package, I'm getting extra space at the top of everypage (or so it seems to me).

Here's a slightly more complicated MWE which illustrates this:

\documentclass{article}
\usepackage[margin=1in]{geometry}
%--------------------------------------------------------------------------------%
\usepackage{multido}
\usepackage[absolute]{pst-abspos}
\psset{unit=1cm}%
\newcommand{\myrules}{%
    \pstSetAbsoluteOrigin%
    \pstPutAbs(0.0,0.0){%
    \begin{pspicture}(0,0)(0,0)%
        \multido{\dx=-2.5+-\baselineskip}{58}{\psline[linecolor=blue!20](0,\dx)(\paperwidth,\dx)}%
        \psline[linecolor=red](2.5,0)(2.5,-\paperheight)%
    \end{pspicture}}}
%--------------------------------------------------------------------------------%
\usepackage{lipsum}
\usepackage{everyshi}
\EveryShipout{\myrules}
\begin{document}\myrules%
\lipsum[1-50]
\end{document}

Notice how on page one the spacing at the top of the page is correct, but not on the subsequent pages. The space between the rules is much smaller than I actually want. But, I chose this spacing for this last MWE to help show the unwanted space appearing at the top of the pages after page one.

share|improve this question
1  
Have you tried background package? –  Harish Kumar Jan 17 '13 at 5:58

1 Answer 1

up vote 4 down vote accepted

that looks like a problem with package everyshi. Here is a solution with eso-pic:

\documentclass[a5paper]{article}
\usepackage[margin=1in]{geometry}
%-----------------------------------------------------------%
\usepackage{multido}
\usepackage[notitlepage,relative]{pst-abspos}
\newcommand{\myrules}{%
  \pstSetRelativeOrigin(0,0)%
    \pstPutAbs(0,0){%
        \multido{\dx=-2.5+-\baselineskip}{58}{\psline[linecolor=blue!20,unit=1cm](0,\dx)(\paperwidth,\dx)}%
        \psline[linecolor=red,unit=1cm](2.5,0)(2.5,-\paperheight)}}%
%--------------------------------------------------------------%
\usepackage{lipsum}
\usepackage[texcoord]{eso-pic}
\usepackage{showframe}
\AddToShipoutPictureFG{\myrules}
\begin{document}
\lipsum[1-50]

\end{document}

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.