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