ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen <pragma@wxs.nl>
Cc: ntg-context@ntg.nl
Subject: Re: Pesky sidebars.
Date: Fri, 10 May 2002 01:12:03 +0200	[thread overview]
Message-ID: <5.1.0.14.1.20020510010704.033db188@remote-1> (raw)
In-Reply-To: <200205081717.42337.john@wexfordpress.com>

At 05:17 PM 5/8/2002 -0400, John Culleton wrote:

>Is there something wrong with my overall approach?

Of course -)

You should use the other background mechanism, the atributes one, which (of 
course) is not yet documented since it's quite new and under development 
(details.pdf will cover it).

However, that method would be overkill, so best use a simpler approach. The 
attached file demos it.

(BTW, i haven't used side bars for years and don't expect to use them in 
the future, so testing is for others)

Hans

You can test the following file:

   texexec --mode=demo --pdf m-yesno

It supports colered sidebars, crossing pages, nested bars, etc

============ m-yesno.tex =========================

%D \module
%D   [       file=m-yesno,
%D        version=2000.05.10,
%D          title=\CONTEXT\ Extra Modules,
%D       subtitle=Handy, Yes or No?,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright=PRAGMA-ADE]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

\unprotect

\newcounter\currentsidebar
\newdimen\sidebardistance

\definesystemvariable{sr}

\def\setupsidebars
   {\dodoubleargument\dosetupsidebars}

\def\dosetupsidebars[#1][#2]%
   {\ifsecondargument
      \getparameters[\??sr#1][#2]%
    \else
      \getparameters[\??sr][#1]%
    \fi}

% \setupMPvariables
%   [mpos:bar]
%   [linecolor=red,
%    linewidth=2pt,
%    distance=5pt]

\setupsidebars
   [\c!lijndikte=2pt,
    \c!lijnkleur=red,
    \c!afstand=.5\bodyfontsize]

\def\definesidebar
   {\dodoubleempty\dodefinesidebar}

\def\dodefinesidebar[#1][#2]%
   {\copyparameters
      [\??sr#1][\??sr]
      [\c!lijndikte,\c!lijnkleur,\c!afstand]%
    \getparameters
      [\??sr#1][#2]}

\def\startsidebar
   {\dosingleempty\dostartsidebar}

\def\dostartsidebar[#1]%
   {\bgroup
    \dontleavehmode
    \checktextbackgrounds
    \doglobal\increment\currentsidebar
    \doifelsenothing{#1}
      {\advance\sidebardistance\@@srafstand}
      {\doifelsevaluenothing{\??sr#1\c!afstand}
         {\advance\sidebardistance\@@srafstand}
         {\sidebardistance\getvalue{\??sr#1\c!afstand}}}%
    \startpositionoverlay{text-1}%
      \expanded{\setMPpositiongraphicrange
        {b:side:\currentsidebar}%
        {e:side:\currentsidebar}%
        {mpos:bar}%
        {self=side:\currentsidebar,
         linewidth=\getvalue{\??sr#1\c!lijndikte},
         linecolor=\getvalue{\??sr#1\c!lijnkleur},
         distance=\the\sidebardistance}}%
    \stoppositionoverlay
    \bpos{side:\currentsidebar}\ignorespaces}

\def\stopsidebar
   {\removelastspace\tpos{side:\currentsidebar}\egroup}

\startMPpositionmethod{mpos:bar}
   \startMPpositiongraphic{mpos:bar}{linecolor,linewidth,distance}%
     StartPage ;
       path p ; p :=
       if \MPp\MPbself=\MPp\MPeself :
         (xpart ulcorner Field[Text][Text],\MPy\MPbself+\MPh\MPbself) --
         (xpart llcorner Field[Text][Text],\MPy\MPeself-\MPd\MPeself) ;
       elseif RealPageNumber=\MPp\MPbself :
         (xpart ulcorner Field[Text][Text],\MPy\MPbself+\MPh\MPbself) --
         (llcorner Field[Text][Text]) ;
       elseif RealPageNumber=\MPp\MPeself :
         (ulcorner Field[Text][Text]) --
         (xpart llcorner Field[Text][Text],\MPy\MPeself-\MPd\MPeself) ;
       else :
         (ulcorner Field[Text][Text]) --
         (llcorner Field[Text][Text]) ;
       fi ;
       draw p shifted (-\MPvar{distance},0)
         withpen pencircle scaled \MPvar{linewidth}
         withcolor \MPvar{linecolor} ;
       anchor_par(\MPanchor\MPbself) ;
     StopPage ;
   \stopMPpositiongraphic
   \MPpositiongraphic{mpos:bar}{}%
\stopMPpositionmethod

\protect

\doifnotmode{demo}{\endinput}

\showframe \setupcolors[state=start]

\definesidebar[whow][rulecolor=green,distance=]

\starttext

\input tufte \par
\startsidebar
   \input tufte \par
   \input tufte \par
   \startsidebar[whow]
     \input tufte \par
     \input tufte \par
     \input tufte \par
   \stopsidebar
   \input tufte \par
   \input tufte
\stopsidebar
\input tufte \par
\input tufte \par
\startsidebar
   \input tufte \par
   \input tufte \par
   \input tufte \par
   \input tufte \par
   \input tufte
\stopsidebar
\input tufte \par
\input tufte \par
\startsidebar
   \input tufte
   \input tufte
   \input tufte
   \input tufte
   \input tufte
\stopsidebar

\stoptext

-------------------------------------------------------------------------
                                   Hans Hagen | PRAGMA ADE | pragma@wxs.nl
                       Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
  tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com
-------------------------------------------------------------------------
                        information: http://www.pragma-ade.com/roadmap.pdf
                     documentation: http://www.pragma-ade.com/showcase.pdf
-------------------------------------------------------------------------


  parent reply	other threads:[~2002-05-09 23:12 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-05-08 21:17 John Culleton
2002-05-09  8:54 ` Patrick Gundlach
2002-05-09 13:17   ` OT: maps23 emacs/auctex article Idris Samawi Hamid
2002-05-09 14:10     ` Taco Hoekwater
2002-05-09 23:12 ` Hans Hagen [this message]
2002-05-10 13:51   ` Pesky sidebars John Culleton
2002-05-10 17:16     ` Hans Hagen
2002-05-10 19:57       ` John Culleton
2002-05-11  9:11         ` Hans Hagen
2002-05-11 10:19         ` Re[2]: " Giuseppe Bilotta
2002-05-13 19:22           ` John Culleton
2002-05-13 21:29             ` Re[4]: " Giuseppe Bilotta
2002-05-14 15:41               ` John Culleton
2002-05-11  4:36       ` Drop words, Drop boxes Idris Samawi Hamid
2002-05-11 13:03         ` Hans Hagen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5.1.0.14.1.20020510010704.033db188@remote-1 \
    --to=pragma@wxs.nl \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).