ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Otared Kavian <otared@gmail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: displaying lines of formulas one by one
Date: Fri, 13 May 2011 08:50:43 +0200	[thread overview]
Message-ID: <64BB9034-D8BC-4E97-800E-EDEBB84B3974@gmail.com> (raw)
In-Reply-To: <7FB40D20-86AC-4E2B-8AC4-BF7858D10F62@me.com>

[-- Attachment #1: Type: text/plain, Size: 1158 bytes --]

Hi Jeong,

If you are interested in using the commands defined in the old t-rsteps.tex for showing formulas or text step by step, below is an example I use (it works with mkii and mkiv). The input file I  use can be found here
	http://dl.dropbox.com/u/4316076/t-rsteps-ok.tex
but I attach it also to this message. 
The old « raw steps » is handy when one may need to go backward in the steps or when you want to show, say, the third line of your formula before the second line, but it has the disadvantage of creating one page per step.

\starttext

\setuppapersize[S6][S6]
\setuppagenumbering[state=stop]
\input t-rsteps-ok.tex
\setupinteraction[state=start] 
% uncomment the following when not needing teps
% \UseStepsfalse
% when using \UseStepstrue, we redefine \placeformula...
\ifx\UseStepstrue{\def\placeformula[#1]{\PlaceFormula[#1]}}\fi

\StartSteps[Formula with steps]

\startformula
\startalign
\Step{1}{\NC T(4) \NC = T(3) + 4 \NR} 
\Step{2}{\NC \NC= T(2) + 3 + 4 \NR}
\Step{3}{\NC \NC= T(1) + 2 + 3 + 4 \NR}
\Step{4}{\NC \NC= 1 + 2 + 3 + 4 = 10 \NR}
\stopalign
\stopformula
\StopSteps
\stoptext

Best regards: OK

[-- Attachment #2: t-rsteps-ok.tex --]
[-- Type: application/octet-stream, Size: 5944 bytes --]

%D \module
%D   [      file=t-rsteps,
%D        version=2004.11.10,
%D          title=\CONTEXT\ User Module,
%D       subtitle=Raw steps for slides,
%D         author=David Munger,
%D           date=\currentdate,
%D      copyright={David Munger}]

%D Thanks to Otared Kavian whose work inspired this module,
%D and who contributed to its development.

%%D Changed \Subject to \Title (OK, December 13, 2004)

\def\Title[#1]{\start%
\page\switchtobodyfont[palatino,24pt]\centerline{#1}\bigskip\stop }

\def\Step#1#2{\FromStep[#1]{#2}}


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

\unprotect

\newif\ifUseSteps
\UseStepstrue
% \UseStepsfalse

\definecolor [highlightcolor] [blue]

\long\def\StartSteps[#1]#2\StopSteps{%
  \begingroup%
  \let\steps@number\plusone%
  \let\steps@counter\plusone%
  \ifUseSteps%
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %% Workaround to make formula numbers "stick"
    \def\PlaceFormula[##1]{%
      \incrementnumber[formula]%
      \expandafter\xdef\csname steps@eqnum##1\endcsname{\rawnumber[formula]}
      \expandafter\xdef\csname steps@eqnum\endcsname{\rawnumber[formula]}
      \dodoubleempty\doplaceformula}
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \loop%
      \let\steps@autocounter\zerocount%
      \Title[#1]\par\steps@startstep#2\steps@stopstep%
      \steps@updatenumber\steps@autocounter%
    \ifnum\steps@counter<\steps@number%
      \increment\steps@counter%
      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      %% Workaround to make formula numbers "stick"
      \def\PlaceFormula[####1]{%
	\setnumber[formula]{\csname steps@eqnum####1\endcsname}%
	\setfalse\incrementformulanumber%
	\ifnum\steps@counter=\steps@number%
	  \def\steps@fnext{\dodoubleempty\doplaceformula[####1]}%
	\else
	  \def\steps@fnext{\dodoubleempty\doplaceformula}%
	\fi\steps@fnext}
      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \repeat%
  \else%
    \Title[#1]\par\steps@startstep#2\steps@stopstep%
  \fi%
  \endgroup}

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

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

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

\def\AfterStep[#1]{%
  \relax
  \steps@updatenumber#1%
  \def\steps@cond{\steps@counter>#1}%
  \dosingleempty\steps@dostep}

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

\def\HighlightStep[#1]#2{%
  {\UntilStep[#1]{#2}\OnlyStep[#1]{\highlightcolor #2}\AfterStep[#1]{#2}}}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 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

\doifnotmode{demo}{\endinput}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% usage example
% partly contributed by: Otared Kavian
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usemodule [pre-original]
%\usemodule [rsteps]

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

\startitemize
\item Item 1
\OnlyStep[2]  {\item (oops!)}
\UntilStep[4] {\item Item 2*}
\FromStep[4]  {\item Item 2}
\HighlightStep[3]{\item Here is another version of Navier-Stokes equation}
\stopitemize

\StopSteps

\StartSteps[Navier||Stokes equation]

\placeformula[eq:incompressibility]
\startformula
  \vec\nabla\cdot\vec u = 0
\stopformula

\placeformula[eq:NS]
\startformula
  \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 \vec\nabla\cdot S}}
\stopformula

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

\StopSteps

\StartSteps[Navier Stokes equation]


\placeformula[eq:div-nul]
\startformula
   \vec\nabla\cdot\vec u = 0
\stopformula

\placeformula[eq:NStokes]
\startformula
   { \partial u \over \partial t} - \Delta u
     \FromStep[1][reserve]{{\red  \; +\; (u\cdot \nabla)u}}
     \FromStep[2][reserve]{{\green \; +\;  \nabla p}}
     \FromStep[3][reserve]{{\blue \; =\;  f(t,x)}}
\stopformula

Comments:
\NextStep \item Nonlinear equation (same is true for equation
(\in[eq:NS]) \par\NextStep
\item One should add initial conditions \par\NextStep
\item and boundary conditions

\StopSteps

\stoptext

[-- Attachment #3: Type: text/plain, Size: 1348 bytes --]


On 13 mai 2011, at 02:13, Jeong Dalyoung wrote:

> Dear all,
> 
> I'd like to show the following formula line  by line in a presentation,
> For example, 
> \startformula\startalign
> \NC T(4) \NC = T(3) + 4 \NR
> \NC \NC= T(2) + 3 + 4 \NR
> \NC \NC= T(1) + 2 + 3 + 4 \NR
> \NC \NC= 1 + 2 + 3 + 4 = 10 \NR
> \stopalign\stopformula
> 
> 
> I tried to use \StartSteps and \StopSteps but not succeed.
> 
> \starttext
> \usemodule[pre-60]
> 
> \StartSteps
> \startformula\startalign
> \NC T(4) \NC = T(3) + 4 \NR\FlushStep %(nor \FlushStep\NR)
> \NC \NC= T(2) + 3 + 4 \NR\FlushStep
> \NC \NC= T(1) + 2 + 3 + 4 \NR\FlushStep
> \NC \NC= 1 + 2 + 3 + 4 = 10 \NR\FlushStep
> \stopalign\stopformula
> \StopSteps
> 
> \stoptext
> 
> Is there a way to do so?
> 
> Thank you.
> 
> Best regards,
> 
> Dalyoung
> ___________________________________________________________________________________
> 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
> ___________________________________________________________________________________



[-- 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
___________________________________________________________________________________

  parent reply	other threads:[~2011-05-13  6:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-13  0:13 Jeong Dalyoung
2011-05-13  2:44 ` Wolfgang Schuster
2011-05-13  6:50 ` Otared Kavian [this message]
2011-05-14  1:11 Jeong Dalyoung
2011-05-14  3:40 ` Wolfgang Schuster
2011-05-14  7:08 ` Otared Kavian

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=64BB9034-D8BC-4E97-800E-EDEBB84B3974@gmail.com \
    --to=otared@gmail.com \
    --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).