[pstricks] Use of variable parameters in PSTRICKS

Denis Girou Denis.Girou at idris.fr
Tue Feb 19 21:30:47 CET 2002


>>>>> "John.Culleton" == John Culleton <john at wexfordpress.com> writes:

    John.Culleton> I am still working on the problem of creating a sidebar
    John.Culleton> with a tinted background. I have the sidebar part
    John.Culleton> taken care of. Now I want to add a tinted background.
    John.Culleton> The sidebar will vary in length depending on conten of course.

    John.Culleton> Can I use a TeX variable (e.g. \pagetotal) instead of
    John.Culleton> an explicit quantity in a Pstricks macro? 

  Of course.


  If I have not completely misunderstood what you try to do (which can be the
case!), you can look at this quick and dirty (LaTeX) example. You can compute
the hight of your sidebar in the same way than here I compute the position of
the page number.

  You can perhaps also found some ideas in the `fancyhdr' manual in
paragraph 20.

\documentclass[a4paper]{article}

% Warnings :
%  - this file must be compiled twice
%  - the coordinates of the \fancyput macro are set for the A4 format

\usepackage{pstcol}
\usepackage{fancybox}

\makeatletter

\newcount\TotalPages
\TotalPages=\z@

% To know the number of pages (we write it in the .aux file)
\def\NumberLastPage{9999} % Initialization

\AtEndDocument{%
\immediate\write\@auxout{%
  \string\gdef\string\NumberLastPage{\the\TotalPages}}}

\fancyput(17.5cm,2.5cm){%
\psframe[linestyle=none,fillstyle=solid,fillcolor=yellow](1,-\paperheight)
\rput(0.5,-\pst at dimh){%
  \pscirclebox[fillstyle=solid,fillcolor=black]{%
    \textcolor{white}{\textbf{\thepage}}}}}

\let\@outputpageORIG\@outputpage

\def\@outputpage{%
\global\advance\TotalPages\@ne
\pst at cnth=\NumberLastPage
\advance\pst at cnth\@ne
\pst at dimh=\paperheight
\divide\pst at dimh\pst at cnth
\pst at dimg=\pst at dimh
\divide\pst at dimg\tw@
\pst at cntg=\thepage
\advance\pst at cntg\m at ne
\multiply\pst at dimh\pst at cntg
\advance\pst at dimh\pst at dimg
\@outputpageORIG}

\makeatother

\begin{document}

1111

\clearpage
2222

\clearpage
3333

\clearpage
4444

\clearpage
5555

\clearpage
6666

\end{document}


D.G.



More information about the PSTricks mailing list