ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Strange bug with overviewpage module.
@ 2014-12-20  5:51 Aditya Mahajan
  2014-12-20  6:14 ` Otared Kavian
  0 siblings, 1 reply; 8+ messages in thread
From: Aditya Mahajan @ 2014-12-20  5:51 UTC (permalink / raw)
  To: mailing list for ConTeXt users

[-- Attachment #1: Type: TEXT/PLAIN, Size: 908 bytes --]

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

[-- Attachment #2: Type: APPLICATION/pdf, Size: 11510 bytes --]

[-- Attachment #3: Type: TEXT/PLAIN, Size: 3941 bytes --]

%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

[-- Attachment #4: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-12-23  9:06 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-20  5:51 Strange bug with overviewpage module Aditya Mahajan
2014-12-20  6:14 ` Otared Kavian
2014-12-20  7:20   ` Aditya Mahajan
2014-12-21 13:21     ` Otared Kavian
2014-12-21 18:50       ` Aditya Mahajan
2014-12-21 20:00         ` jdh
2014-12-21 23:03           ` Aditya Mahajan
2014-12-23  9:06         ` Otared Kavian

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).