ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Aditya Mahajan <adityam@umich.edu>
Subject: Re: formula, bookmarks and misc
Date: Sun, 29 Oct 2006 01:38:21 -0500 (EST)	[thread overview]
Message-ID: <Pine.WNT.4.63.0610290128070.2908@nqvgln> (raw)
In-Reply-To: <4543FF4E.5050905@free.fr>

On Sun, 29 Oct 2006, Sebastian Rooks wrote:

> Dear ConTeXters,
>
> 1/ I would like to use a named formula with a reference containing
> several subformulae each with a reference. The closer I can get to is to
> add an empty namedformula followed by subformulae (see test file below).
> How can I get rid of the empty line with a number in the pdf ?

I took a different approach to this. I had written some macros that do 
automatic subformula numbering, and I added a macro there to do have a 
named subformulas. See the code at the end.


> 4/ How can I redefine the \vec command in my formulae without having a
> warning "system          : command \vec is already defined"


\def\vec#1{whatever}

will not give you a warning. You get a warning only if you use 
\define.


> 5/ I do like a lot the minimum distribution so easy to install. It would
> be even better if bibtex can be added. It's only 82.8 KiB

bibtex is part of the minimal distribution for windows. It is in 
texmf-mswin/bin/


Now, coming back to the code for subformulas. I defined a 
\startnamedsubformulas[tag]{name} to take care of "named" subformulas. 
This is build on top of an existing \startsubformulas ... 
\stopsubformulas that do automatic numbering of subformulas. See the 
examples in the end.


\unprotect

\definesystemvariable {fn}   % subForMulas
                              % Suggestion by Hans to use fn

%D \macros{setupsubformulas}

\def\setupsubformulas
   {\dodoubleargument\getparameters[\??fn]}

\definenumber
   [parent\v!formula]

\def\subformulaconversion#1%
   {\getnumber[parent\v!formula]%
    \@@fnseparator%
    \convertnumber{\@@fnconversion}{#1}}

\defineconversion[sub\v!formula\c!conversion][\subformulaconversion]

%D \macros{startsubformulas}

\def\startsubformulas%
   {\dosingleempty\dostartsubformulas}

\def\dostartsubformulas[#1]%
   {\incrementnumber[\v!formula]
    \makesectionnumber[\v!formula]
    \iffirstargument
      \rawreference{\s!for}{#1}{\composedsectionnumber}
    \fi
    \expanded{\setupnumber
      [parent\v!formula]
      [start={\rawnumber[\v!formula]},
       \c!way=\@@fmway,
       conversion=\@@fmconversion]}
    \savenumber[\v!formula]
    \bgroup

\setupformulas[\c!conversion=sub\v!formula\c!conversion,\c!way=\v!by\v!text]
    \resetnumber[\v!formula]}

\def\stopsubformulas%
   {\restorenumber[\v!formula]
    \resetlastlinewidth
    \nonoindentation
    \dochecknextindentation{\??fn}%
    \egroup
    \dorechecknextindentation} % here ?

% I have just copied the indentation checking from \stopformulas. I am not
% sure on how this works. I did not change this to take care of side 
% floats

%D Named subformulas

\def\startnamedsubformulas%
   {\dosingleempty\dostartnamedsubformulas}

\def\dostartnamedsubformulas[#1]#2%
   {\iffirstargument
      \def\next{\startsubformulas[#1]}%
     \else
       \let\next\startsubformulas
     \fi
     \setformulalistentry{#2}%
     \next}

\def\stopnamedsubformulas{\stopsubformulas}

\setupsubformulas
   [\c!conversion=\v!character,
    \c!separator=\@@fmseparator,
    \c!indentnext=\@@fmindentnext]

\protect

%D Possible features
%D * One should be able to refer to the subformula number, without the 
formula
%D   number, e.g., see equations 3a--c.
%D * Allow
%D    a = b    1
%D    c = d    2.a
%D    e = f    2.b
%D    g = h    3
%D  Algorithm do do this automatically
%D  flag = previous_subnumbered ;
%D  \let\afterNR\relax
%D  previous_subnumbered = false ;
%D  for (each row)
%D  if (subnumber_present_row == true)
%D    if (previous_subnumbered == true)
%D      \def\afterNR{\decrementnumber[formula]}
%D    end
%D    previous_subnumbered = true ;
%D  else
%D    previous_subnumbered = false ;
%D  end


% Examples

\starttext

\placelist[formula]


\section{Math Formulas}

\startnamedsubformulas[eq:well_known]{Well Known Equalities}
   \placeformula[eq:first]  \startformula
     1 + 0 = 1
   \stopformula
   \placeformula[eq:second] \startformula
     1 + 1 = 2
   \stopformula
\stopnamedsubformulas
\page

Other examples from an email discussion with Mojca.

\startbuffer
\placeformula \startformula
a^2 + b^2 = c^2
\stopformula
\stopbuffer


\setupsubformulas
  [conversion=romannumerals]


\startsubformulas[Maxwell]
   \placeformula \startformulas
     \startformula \startalign
       \NC \nabla\cdot\bf E  \NC = \frac{\rho}{\varepsilon_0} 
\NR[Maxwell 1]
       \NC \nabla\times\bf E \NC = - \frac{\partial\bf B}{\partial t}
       \NR[Maxwell II]
       \stopalign \stopformula
       \startformula \startalign
         \NC \nabla\cdot \bf B \NC = 0 \NR[Maxwell III]
         \NC \nabla\times\bf B \NC = \mu_0{\bf
j}+\varepsilon_0\mu_0\frac{\partial\bf E}{\partial t} \NR[Maxwell IV]
       \stopalign \stopformula
   \stopformulas
\stopsubformulas

Maxwell : \in [Maxwell]

II : \in [Maxwell II]



\section{conversion}

\setupformulas
   [conversion=character]
\setupsubformulas
   [conversion=n]

\getbuffer

\startsubformulas[subformula]
  \dorecurse{2}{\getbuffer}
  \placeformula[my x formula] \startformula x \stopformula
\stopsubformulas

\placeformula[my y formula] \startformula y \stopformula


reference for subformula: \in [subformula]

reference for x: \in [my x formula]

reference for y: \in [my y formula]

\setupformulas[way=bysection]

\section{a}

\getbuffer

\startsubformulas
  \dorecurse{2}{\getbuffer}
  \placeformula[my x2 formula] \startformula x \stopformula
\stopsubformulas

\placeformula[my y2 formula] \startformula y \stopformula

  reference for x: \in [my x2 formula]

  reference for y: \in [my y2 formula]



\stoptext

  reply	other threads:[~2006-10-29  6:38 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-29  1:09 Sebastian Rooks
2006-10-29  6:38 ` Aditya Mahajan [this message]
2006-10-29 16:47   ` Sebastian Rooks
2006-10-29 17:18     ` Aditya Mahajan
2006-10-31  8:45 ` Wolfgang Schuster
2006-10-31 20:55   ` Aditya Mahajan
2006-11-02  8:23     ` Wolfgang Schuster
2006-11-02 17:22       ` Aditya Mahajan
2006-11-01 23:57   ` Sebastian Rooks
2006-11-03 10:52     ` Wolfgang Schuster

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=Pine.WNT.4.63.0610290128070.2908@nqvgln \
    --to=adityam@umich.edu \
    --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).