ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: David Munger <mungerd@users.sourceforge.net>
Subject: Re: \presentationstep
Date: Sat, 06 Nov 2004 03:07:20 -0500	[thread overview]
Message-ID: <1099728440.7428.19.camel@tempete.lac.qc.ca> (raw)
In-Reply-To: <p06110402bdae48b1a915@[10.0.1.7]>

Hi all,

Inspiring from Otared Kavian's code and Han's presentation styles with
support for steps, I cooked the following in order to solve the non
JavaScript version issue. I post it in case it could be useful to other
people.

This implementation supports an \{Only|From|Until}Step[n] syntax as well
as the simple \NextStep-style one.

Otared: Any comments or suggestions?

And here is an example of usage:

-------------------------------------------
\StartSteps[Slide Title]           % the title is passed to
                                   % the \Subject macro

\startitemize
\item Item 1
\OnlyStep[2]  {\item (oops!)}
\UntilStep[4] {\item Item 2*}
\FromStep[4]  {\item Item 2}
\stopitemize

\StopSteps
-------------------------------------------

And here is a mixed example:

-------------------------------------------
\StartSteps[Navier||Stokes equation]

\[
  \frac{D\vec u}{Dt} =
    \FromStep[2][reserve]{-{\red \frac1\rho \vec\nabla p}}
    \FromStep[3][reserve]{+\;{\green \vec g}}
    \FromStep[4][reserve]{+\;{\blue \frac1\rho \div S}}
\]

Momentum transport:	\NextStep
\item {\red   Pressure gradient}	\par\NextStep
\item {\green Gravity}                  \par\NextStep
\item {\blue  Stress (viscous, turbulent, Maxwell)}

\StopSteps
-------------------------------------------

And here's the code:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% steps for slides
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\unprotect

\newif\ifUseSteps
\UseStepstrue
% \UseStepsfalse


\long\def\StartSteps[#1]#2\StopSteps{%
  \let\steps@number\plusone%
  \let\steps@counter\plusone%
  \ifUseSteps%
    \loop%
      \let\steps@autocounter\zerocount%
      \Subject{#1}\par\steps@startstep#2\steps@stopstep%
      \steps@updatenumber\steps@autocounter%
    \ifnum\steps@counter<\steps@number%
      \increment\steps@counter%
    \repeat%
  \else%
    \Subject{#1}\par\steps@startstep#2\steps@stopstep%
  \fi}

\def\NextStep{\steps@stopstep\steps@startstep}

\def\OnlyStep[#1]{%
  \steps@updatenumber#1%
  \def\steps@cond{\steps@counter=#1}%
  \dosingleempty\steps@dostep}

\def\FromStep[#1]{%
  \steps@updatenumber#1%
  \let\steps@tmpcounter\zerocount%
  \increment(\steps@tmpcounter,#1-1)%
  \def\steps@cond{\steps@counter>\steps@tmpcounter}%
  \dosingleempty\steps@dostep}

\def\UntilStep[#1]{%
  \steps@updatenumber#1%
  \def\steps@cond{\steps@counter<#1}%
  \dosingleempty\steps@dostep}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% internal macros
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcounter\steps@counter
\newcounter\steps@autocounter
\newcounter\steps@number
\newcounter\steps@tmpcounter

\def\steps@startstep{%
  \increment\steps@autocounter%
  \def\steps@hide{no}%
  \ifUseSteps%
    \ifnum\steps@autocounter>\steps@counter%
      \def\steps@hide{yes}%
    \fi%
  \fi%
  \starthidden}

\def\steps@stopstep{\stophidden}

\def\steps@updatenumber#1{\ifnum\steps@number<#1%
  \doglobal\let\steps@number\zerocount%
  \doglobal\increment(\steps@number,#1)\fi}

\defineframedtext
  [step@frame]
  [offset=overlay,width=broad,height=fit,frame=off]

\def\starthidden{\startstep@frame[empty=\steps@hide]}
\def\stophidden{\stopstep@frame}


\long\def\steps@dostep[#1]#2{%
  \processallactionsinset
    [#1]
    [	reserve=>\let\steps@next=\steps@dostepreserve,
	\s!default=>\let\steps@next=\steps@dostepnoreserve]
  \steps@next{#2}}

\long\def\steps@dostepreserve#1{%
  \def\steps@hide{no}%
  \ifUseSteps%
    \ifnum\steps@cond\else%
      \def\steps@hide{yes}%
    \fi%
  \fi%
  \ifmmode\expandafter\mframed\else\expandafter\framed\fi%
  [empty=\steps@hide,frame=off,offset=overlay]{#1}%
  \ifmmode\;\fi}

\long\def\steps@dostepnoreserve#1{%
  \def\steps@next{#1\ifmmode\;\fi}%
  \ifUseSteps%
    \ifnum\steps@cond\else\def\steps@next{\relax}\fi%
  \fi\steps@next}

\protect

  parent reply	other threads:[~2004-11-06  8:07 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-03  8:35 \presentationstep Otared Kavian
2004-11-03 16:42 ` \presentationstep David Munger
2004-11-03 17:25   ` \presentationstep Otared Kavian
2004-11-06  8:07 ` David Munger [this message]
2004-11-07 22:10   ` \presentationstep Otared Kavian
2004-11-08  0:57     ` \presentationstep David Munger
2004-11-08 12:59       ` \presentationstep Otared Kavian
2004-11-08 18:01         ` \presentationstep David Munger
2004-11-08 20:02           ` \presentationstep Otared Kavian
2004-11-08 21:10             ` \presentationstep David Munger
2004-11-10 14:51               ` \presentationstep Otared Kavian
2004-11-10 17:08                 ` \presentationstep David Munger
2004-11-10 17:39                   ` \presentationstep Hans Hagen
2004-11-10 18:08                     ` \presentationstep David Munger
2004-11-10 18:44                   ` \presentationstep Otared Kavian
2004-11-10 18:25                 ` \presentationstep Vit Zyka
2004-11-10 19:05                   ` \presentationstep Otared Kavian
  -- strict thread matches above, loose matches on Subject: below --
2004-11-02  6:04 \presentationstep David Munger
2004-11-02  7:45 ` \presentationstep Henning Hraban Ramm
2004-11-02  9:58   ` \presentationstep Hans Hagen
2004-11-02 22:22     ` \presentationstep David Munger
2004-11-02 22:55       ` \presentationstep h h extern
2004-11-02 23:38         ` \presentationstep David Munger
2004-11-03  9:39           ` \presentationstep Hans Hagen
2004-11-09 10:18 ` \presentationstep Eckhart Guthöhrlein

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=1099728440.7428.19.camel@tempete.lac.qc.ca \
    --to=mungerd@users.sourceforge.net \
    --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).