4

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.

  • 1
    Have you tried background package? – user11232 Jan 17 '13 at 5:58
4

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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