[NTG-context] Strange bug with overviewpage module.

Aditya Mahajan adityam at umich.edu
Sat Dec 20 06:51:41 CET 2014


Hi,

Some time ago, Hans had helped me to write an 'overviewpage' module, that 
makes it easy to show a overview of the important slides at the end of a 
presentation. I have tweaked this module slightly to be able to save an 
arbitrary page by using

\saveoverviewpage{reference}

and reuse the page by

\useoverviewpage{reference}

An example is:

\usemodule[overviewpage]
\setuppapersize[S4]

\setupframedtext[rulethickness=3pt]

\starttext

\startframedtext
   \input ward
\stopframedtext
\saveoverviewpage{ward}
\page

\input tufte
\page

\scale[width=0.5\textwidth]{\useoverviewpage{ward}}

\stoptext


However, when I save a page that contains a framed box (as in the above 
example), the box looses its right frame when it is displayed again (see 
page 3 of the attached pdf). It appears that the left edge is twice as 
thick.

Any idea why this is happening and how I can avoid this?

Thanks,
Aditya
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.pdf
Type: application/pdf
Size: 11510 bytes
Desc: 
URL: <http://www.ntg.nl/pipermail/ntg-context/attachments/20141220/ffad70d0/attachment-0001.pdf>
-------------- next part --------------
%D \module
%D   [     file=t-overviewpage,
%D      version=2013.08.31,
%D        title=\CONTEXT\ User Module,
%D     subtitle=Page Overviews,
%D       author=Aditya Mahajan and Hans Hagen,
%D         date=\currentdate,
%D    copyright=Aditya Mahajan,
%D        email=adityam <at> ieee <dot> org,
%D      license=Simplified BSD License]

\writestatus{loading}{Overview Page (ver: 2013.08.31)}

\startmodule [overviewpage]

\unprotect

\setupmodule
  [\c!level=]

\installnamespace{overviewpage}

\initializeboxstack{\????overviewpage}

\newconditional\c_overviewpage_state

\unexpanded\def\enablesaveoverviewpage
  {\global\settrue\c_overviewpage_state}

\unexpanded\def\saveoverviewpage#1%
  {\enablesaveoverviewpage
   \setevalue{\????overviewpage:page:#1}{\the\realpageno}}

\unexpanded\def\useoverviewpage#1%
  {\writestatus{overviewpage}{using page #1 (\getvalue{\????overviewpage:page:#1})}%
   \expanded{\foundbox{\????overviewpage}{\getvalue{\????overviewpage:page:#1}}}}

\unexpanded\def\overviewpage_save_page#1%
  {\ifconditional\c_overviewpage_state
     \setbox\nextbox\hbox{#1}%
     \setbox\scratchbox\copy\nextbox
     \cleanupbox\scratchbox % remove nodes that should not be seen in the backend twice
     \writestatus{overviewpage}{saving overviewpage \the\realpageno}%
     \savebox{\????overviewpage}{\the\realpageno}{\box\scratchbox}%
     \global\setfalse\c_overviewpage_state
     \page_shipouts_normal{\box\nextbox}%
   \else
     \page_shipouts_normal{#1}%
   \fi}

\appendtoks
    \doif {\headparameter{option:overviewpage}} \v!yes \enablesaveoverviewpage
\to \everyheadsynchronization

\installshipoutmethod{overviewpage}\overviewpage_save_page

\unexpanded\def\overviewpage_setup_head#1%
  {\setuphead[#1][option:overviewpage=\v!yes]}

\appendtoks
    \processcommacommand
      [\moduleparameter{overviewpage}\c!level]
      \overviewpage_setup_head
\to \everysetupmodule


\the\everysetupmodule

\setuppaper
  [\c!method=overviewpage]

\definelistalternative
  [overviewpage]
  [\c!renderingsetup=\??listrenderings:overview]

\setuplistalternative
  [overviewpage]
  [\c!before=\dontleavehmode,
   \c!after=\hskip\zeropoint\relax,
 % \c!width=\ctxlua{moduledata.overviewpage.calculatedwidth(\listlength)}]
   \c!width=\ctxlua{moduledata.overviewpage.calculatedwidth(structures.lists.size())}]

\startsetups[\??listrenderings:overview]
    \doifboxelse{\????overviewpage}{\structurelistrealpagenumber}
       {\listalternativeparameter\c!before
        \startcurrentlistentrywrapper
          \scale
            [\c!width=\listalternativeparameter\c!width]
            {\foundbox{\????overviewpage}{\structurelistrealpagenumber}}%
        \stopcurrentlistentrywrapper
        \listalternativeparameter\c!after}
       {}%
\stopsetups

\definemakeup
  [overviewpage]
  [\c!align=\v!middle]

\definelayout
  [overviewpage]
  [\v!page]

\startluacode
    moduledata              = moduledata              or { }
    moduledata.overviewpage = moduledata.overviewpage or { }

    function moduledata.overviewpage.calculatedwidth(pages)
        context("%f\\textwidth",1/math.ceil(math.sqrt(pages)))
    end
\stopluacode

% Ideally, we would like to simply use the definition below. 
% However, the `before` and `after` keys are not used with `\placecombinedlist`. 
% Therefore we use a more manual solution.
%
\definecombinedlist
    [overviewpage]
    [\moduleparameter{overviewpage}\c!level]
    [
      %\c!before=\startoverviewpagemakeup,
      %\c!after=\stopoverviewpagemakeup,
      \c!criterium=\v!all,
      \c!alternative=overviewpage,
    ]

\unexpanded\def\placeoverviewpage
  {\dosingleargument\doplaceoverviewpage}

\def\doplaceoverviewpage[#1]%
  {\startoverviewpagemakeup
      \placecombinedlist[overviewpage][#1]
   \stopoverviewpagemakeup}

\protect

\stopmodule


More information about the ntg-context mailing list