6

Question: Is it possible to tag displayed equations (inside \startformula and \stopformula with an arbitrary tag in ConTeXt?

With LaTeX I can do

\documentclass[preview]{standalone}
\usepackage{amsmath}
\begin{document}
\begin{equation}
1+1=2\tag{A}
\end{equation}
\end{document}

with the result

Result from LaTeX code

I think that previously one could in ConTeXt write

\startTEXpage[offset=2bp]
\startformula
1+1=2\eqno{A}
\stopformula
\stopTEXpage

to have the equation tagged with an A, but now I get, with a recent standalone,

ConTeXt output, without tag

I would like to have the tag to the right as in the LaTeX example, and it is fine if it is not possible to refer to the equation later. Just to make the question clearer, I do not want to number the equations with characters A, B, ..., but really want to be able to set an arbitrary tag. Sorry for not being perfectly clear about this in the first version of the question.

My efforts so far is that I have looked for something that could fit in setup-en.pdf. I also made a search in the source, and the file strc-mat.mkiv looked interesting, but I could not find out if it had what I am looking for.

  • 3
    I have been looking at the source strc-mat.mkiv and I have to admit that this might not be possible currently. ConTeXt is apparently completely restricted to numerical numbering (or at least a counter). – Henri Menke Nov 8 '17 at 9:32
  • You should ask also on the mailing list ntg-context@ntg.nl. – Henri Menke Nov 8 '17 at 9:34
  • @HenriMenke Thank you, I will send an email to the list. I promise to update here with an answer if/when it appears. – mickep Nov 8 '17 at 9:38
5

As others have pointed out there is no clean solution right now. However, since you say that it is okay if you cannot refer to the formula, you can abuse the suffix mechanism:

\defineformula[tag][numbersegments=2]

\starttext

\placeformula[test1]
\startformula E = mc^2 \stopformula

\placeformula[test2]{ABC}
\starttagformula E = mc^2 \stoptagformula

\placeformula[test3]
\startformula E = mc^2 \stopformula

We can still refer to other formulas: \in[test1] and \in[test3], but not the
tagged formula: \in[test2].

 \stoptext

enter image description here

Note that \placeformula{suffix} changes the equation number to n.suffix, where n is the current equation number. The setup:

\defineformula[tag][numbersegments=2]

ensures that in tagformulas, only the second segment of this number (i.e., only the suffix) is shown).

Thanks to @Metafox for suggesting a simplification to my earlier hackish answer.

  • Many thanks, Aditya. This is the solution that fits my needs best. – mickep Nov 10 '17 at 11:45
  • 1
    @Aditya When you provide a suffix for each formula you can disable the number for the first level with \setupformula[numbersegments=2]. To hide only the separator between the number and the suffix you have to create first a new separatorset with \defineseparatorset[none][][] and apply it afterwards with \setupformula[numberseparatorset=none]. – Wolfgang Schuster Nov 10 '17 at 16:55
  • @Metafox: Thanks. I'll update the answer accordingly. – Aditya Nov 10 '17 at 17:26
6

You can setup a dummy conversion. But you need a new one for every new tag:

 \starttext

   \def\mytagforformulaA#1{testtesttest}
   \defineconversion[dummyA][\mytagforformulaA]
   \setupformulae[numberconversion=dummyA]
   \placeformula[test1]
   \startformula E = mc^2 \stopformula
   This is my reference: \in{formula}[test1].

   \def\mytagforformulaB#1{blublubblu}
   \defineconversion[dummyB][\mytagforformulaB]
   \setupformulae[numberconversion=dummyB]
   \placeformula[test2]
   \startformula E = mc^2 \stopformula
   This is my reference: \in{formula}[test2].

   This is my reference from 1: \in{formula}[test1].
 \stoptext

enter image description here

  • Thank you, upvoted. This will indeed work in case there is no "cleaner" solution. I just sent an email to the mail list, and missed your answer before sending it. Otherwise I would have mentioned it. – mickep Nov 8 '17 at 9:45
  • 1
    One can certainly hide the setup of the dummy conversion in some command -- in latex I would use some \csname with a counter. Btw: I got the idea from here: mail-archive.com/ntg-context@ntg.nl/msg84512.html – Ulrike Fischer Nov 8 '17 at 9:57
4

You can assign tags with \placefomula and change the appearance with \setupformulas:

\setupformulas[numberconversion=Character]

\starttext

\placeformula[formulalabel]
\startformula
1+1=2
\stopformula

You can refer to the formula like this: \in[formulalabel]

\stoptext

enter image description here

  • Thank you very much for your answer. My A was a bad example. I do not want them numbered, but really arbitrary. I will update my question to emphasize this. – mickep Nov 8 '17 at 8:53
  • 1
    Aditya asked for something like this quite a while back on the context mailinglist: mailman.ntg.nl/pipermail/ntg-context/2006/021038.html – DG' Nov 8 '17 at 12:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.