Last modified: 2014-09-04 16:52:40 UTC
Hi, I'm struggling with figure numbering in articles, because it has to be done manually at the moment. An automatic figure numbering system in the way of the cite.php extension would make it a lot simpler and would avoid errors when modifying an article. An identical system for equations would also be great. The LaTeX code for this is very simple (at least from the user point of view!): the \label{<nameoftheanchor} command is used in the equation or the figure (and is respectively replaced during compilation by "(1)" or "Fig. 1") and the command \ref{<nameoftheanchor>} is placed wherever you need to refer to the label (and is respectively replaced at compilation-time by "(1)" or "figure 1"). I have no real idea of the amount of work such an extension would require (I had a look at Cite.php, and I can imagine it is quite a lot...), but I think it is of great importance for long wikipedia articles (and might even be mandatory for wikibooks!). What do you think? Cyril
It shouldn't be too difficult. The biggest problem is forcing the system to treat the resulting output as wikitext too... nothing on surmountable though. A few cleverly placed global counters and a developer with SVN access to spearhead it should make it work out. I could volunteer to write preliminary code.
I guess this enhancement is feasible, as this kind of feature exists in many softwares, and its requirements look pretty close to those of the current "cite" plugin. However, I don't know anything about MediaWiki or php, so I would spend ages trying to implement it myself, and I would end up with a mix of security holes and bugs... So please, if you think you could work on it, this feature would be really helpful for long articles in wikipedia and wikibooks. Cyril
Perhaps this could be done as a extension. Moving to extension requests.
This feature was also requested recently by a new user on Portuguese Wikibooks: [[wikibooks:pt:Tópico:Utilizador Discussão:Rpez/Oi!/resposta (4)]]
For Debian there is the mediawiki2latex package. It gives you the latex source. There you can easily enable the equation numbering.
Is there a reason not to use templates for numbered equations. Id's in the \latex style can be assigned by the id attribute of the math element.
oups I wanted to write Id's in the \label style can be assigned by the id attribute of the math element.
That will not automatically generate the numbering, I think.
OK. I was thinking there are templates that can benefit from css based numbering. If that's not the case I'm happy to fix that problem. The math extension can not look outside of the math tag. There is a hook that could be used wfRunHooks( 'MathFormulaRendered', array( &$renderer, &$renderedMath, $parser->getTitle()->getArticleID(), $parser->nextLinkID() ) );// Enables indexing of math formula In practice $parser->nextLinkID() creates numbers 0 to n. But I think that's not guaranteed to be the case in the future. For example http://demo.formulasearchengine.com/index.php/Spectrum_%28functional_analysis%29#math22 is the 23'th math tag that has been processed on that page. Like MathSearch it would be simple to develop an extension that adds a custom tag for numbered equations. But I'm not sure if that's a feature that should go to the Math extension. If you think that's a feature that should go to the math extension I'm happy to implement that... should not be hard at all.
PS: It would be great if someone would use the https://www.mediawiki.org/wiki/Extension:Math/Roadmap#Wanted_features page. So we can see if something is really a wanted feature of if it's just an outdated bug from 2006... that's what I thought at a first look
The main problem we need to solve is to provide a wiki equivalent syntax for the following simple feature of LaTeX, so that Mathematic and Physics books can be written collaboratively on Wikibooks projects: [[b:Some book/Chapter 1]] -------------------------------------- Let \begin{equation}\label{foobar} x = 1 + 2. \end{equation} Equation \eqref{foobar} is known as... -------------------------------------- [[b:Some book/Chapter 2]] -------------------------------------- By \eqref{foobar}, it follows that... -------------------------------------- The automatically numbering is necessary not only for formulas in a single page, but also for several pages (chapters) of a single book. However, since not even <ref>s work like that yet (see bug 10092), a first step would be to allow cross references like the ones above in a single page. Not having something like this prevent us from importing good quality content to Wikibooks projects.
I see different problems. The label problem and the numbering and and numbered label generation problem. That might be independent of the Math extension since it applies to images as well. I created a test page here https://en.wikipedia.org/wiki/User:Physikerwelt/bug5600#foobar to demonstrate what works today. Basically the link could be replaced by an interwiki link to [[w:User:Physikerwelt/bug5600#foobar]] to be a global reference. I think a template should replace [[w:User:Physikerwelt/bug5600#foobar]] by [[w:User:Physikerwelt/bug5600#foobar|equation reference]] A global table of all equations is desired. I see that a table of all equations would be helpful here. I implemented that for the MathSearch extension. (Recently I updated the fact that the references link to revisions and not pages. Just to be sure...) But before we start to implement something we should exactly describe what we want to achieve. For me it's still not clear what this bug is about.
The main point is that the label for the link [[#foobar]] should be generated automatically, based on the number of equations (in the current page/book/etc). E.g. it would be like [[#foobar|1]] in that page (since that is the first formula, and this number "1" should increase/update automatically - as in LaTeX - if another formula is added before it).
Any sort of counter like this would inherently be a side effect, which we're trying to move away from.
Copying below the relevant conversation from today on #mediawiki-parsoid: <helderwiki> didn't we have a change in the way references (from Cite) are automatically numbered? Any chance of using something similar to fix this? <helderwiki> https://bugzilla.wikimedia.org/show_bug.cgi?id=5600#c9 <helderwiki> (change = using CSS or something) <helderwiki> the link above is to a feature request: automatic figure and (math) equation numbering <subbu> helderwiki that feature is not yet there. but, WIP. <subbu> cite auto-numbering <gwicke> helderwiki: visual numbering is fairly easy with CSS <gwicke> it's already used for Parsoid content <helderwiki> gwicke: subbu|coffee could you add any input to that bug? See the use case I mentioned on <helderwiki> https://bugzilla.wikimedia.org/show_bug.cgi?id=5600#c11 <gwicke> helderwiki: it sounds like you'd like to reference formulas too, which goes beyond what CSS counters can do <gwicke> you probably want to specify an id on the math tag <gwicke> <math id="foobar">...</math> <gwicke> which would just translate to that HTML id in the output <gwicke> & can be displayed with CSS <helderwiki> Added one more comment at https://bugzilla.wikimedia.org/show_bug.cgi?id=5600#c13 <helderwiki> gwicke: yeah, for one hand we want the numbering of the formulas to be added automatically (which could be done with CSS, I think), but it should be possible to reference these formulas by name in the wikitext, and "something" should be able to label it accordingly to the same (CSS?) number <gwicke> it's possible to display either a counter or a label <gwicke> using css <helderwiki> jackmcbarn: could you elaborate what you mean by "side effect" in that context? <helderwiki> WONTFIXING something like that would mean no Mathematics on Wikibooks projects... It is sad to hear that. <gwicke> helderwiki: nobody said wontfix <jackmcbarn> helderwiki: adding an equation at the top of the page would mean all of the rest of them would get renumbered <jackmcbarn> gwicke: i did <gwicke> oh, missed that <gwicke> well, numbering for display is fine with css <helderwiki> jackmcbarn: that is exactly the feature from tex which we are lacking in wikitext <gwicke> for linking you want stable ids <jackmcbarn> helderwiki: deliberately so <jackmcbarn> it would be like Cite all over again <helderwiki> and which is preventing us from convincing a few teachers to writte their books on Wikibooks collaborativelly <gwicke> helderwiki: I don't see a problem really <jackmcbarn> helderwiki: if you can find a css way to do that, you can do it, but what you asked for in the report would mean the parser would have to be in charge of numbering, which can't happen <jackmcbarn> gwicke: the problem is they don't just want numbers on the equations. they want to be able to say "figure 1", etc. dynamically from the prose <helderwiki> exactly! <jackmcbarn> that's what the problem is <gwicke> ah.. so not figure foobar <helderwiki> but by referring to these formulae/figures by their labels/ids <helderwiki> In latex source, it is like "foobar", but once we compile the document, the labels are generated automatically <gwicke> helderwiki, jackmcbarn: that's definitely harder <jackmcbarn> gwicke: wouldn't it be equivalent to another Cite? <gwicke> is the numbering absolutely needed? <helderwiki> yep. it is the way it works on Physics and Math texts nowadays (outside wikis) <gwicke> "figure foo" could work from a functional pov <gwicke> there is always JS <jackmcbarn> helderwiki: if you know of any way to do it that would let you add an equation to the top of a page, and only have to parse it rather than reparse the entire page, then it'll be doable <jackmcbarn> js would probably be the least bad solution <gwicke> yeah, if CSS doesn't work & those labels absolutely need to be numbered rather than named.. <gwicke> it's worth considering the trade-offs carefully though <helderwiki> where is the patch (WIP?) of the CSS implementation for the numbering of Cite refs? <helderwiki> also, can I copy this log to Bugzilla? <gwicke> helderwiki: the CSS for that is deployed <helderwiki> hmm... it seems I missed that :-) <gwicke> helderwiki: http://git.wikimedia.org/blob/mediawiki%2Fcore/8fde6c3da0eed6cdadb8372397c338ca04bf3a38/resources%2Fsrc%2Fmediawiki.skinning%2Fcontent.parsoid.less#L13 <gwicke> for auto-numbered external links <gwicke> helderwiki: so it seems that it's not yet deployed for Cite <subbu> helderwiki, for cite, marcoil is working on it and said he will have soemthing on friday. <helderwiki> do we have things like "mw:ExtLink" in the HTML already? <gwicke> in Parsoid HTML, yes <gwicke> that's the HTML you see when you use VE or Flow <helderwiki> ok <helderwiki> its not used on normal page views yet, right? <gwicke> not yet, yes <gwicke> we are working on it ;)
The problem of referencing the content generated automatically by CSS without using JavaScript is discussed here: http://stackoverflow.com/q/16453488
I think it gives a wrong impression to mark this bug as wontfix. It's just not a problem of the Math extension. It's a more general problem: We can create a new bug that describes what we really want. What I got is: " Replace labels of links to an named HTML entities by an auto-generated subsequent number. "
(In reply to physikerwelt from comment #17) > Replace labels of links to an named HTML entities by an auto-generated > subsequent number. That would also be WONTFIX, for the same reason (unless you did it with JavaScript or something else hacky like that).
I have no inside knowledge about WikiSource, but the title of the project indicates that the feature is required. All sources contain numbered equations, figures, tables etc. It is a major requirement to the MediaWiki software that those numbers will be added automatically. Technical limitations and performance optimizations are of minor importance. So I can not understand the conclusion that this short coming will not be fixed (wontfix).
How is Cite going to work around the restriction "Any sort of counter like this would inherently be a side effect, which we're trying to move away from." (comment 14). In particular, in the following extract the footnote numbers of both <ref> tags have to be coincide and the links have to go to the same footnote: Some statement.<ref name="source1">Details of source 1</ref> ... Another statement supported by the same source.<ref name="source1" /> It would be helpful if the constraint on side effects is explained somewhere so that we know what we have to work around (or overturn).
Reopening since this is a necessary feature (even if its only possible implementation is based on JS)
Do you think this issue is specific to the math extension. If not please change the product and component.
(In reply to Jitse Niesen from comment #20) > How is Cite going to work around the restriction "Any sort of counter like > this would inherently be a side effect, which we're trying to move away > from." (comment 14). > > In particular, in the following extract the footnote numbers of both <ref> > tags have to be coincide and the links have to go to the same footnote: > > Some statement.<ref name="source1">Details of source 1</ref> > ... > Another statement supported by the same source.<ref name="source1" /> > > It would be helpful if the constraint on side effects is explained somewhere > so that we know what we have to work around (or overturn). Parsoid includes its own implementation of Cite as an extra parsing pass, which gets used instead of the "real" Cite. Building and maintaining that is a lot of work for the Parsoid team, and it's the only way things with side effects can work under Parsoid.
I would say that's good news. I think there is a way to separate the counter and reference generation from the cite extension. That said it would reduce he maintenance effort for the Parsoid team in the future.
removing wikisource, has not been a required functionality, and would generally be hard coded to match a work, especially where individual pages are being replicate, and would need anchors
At least conceptually it should be possible to use Cite for formulas. The following wikitext in fact gives something close to what we want. A standard limit is :<ref name=sinlim> <math> \lim_{x\to0} \frac{\sin x}{x} = 1 </math> </ref> We can proof <ref name=sinlim /> using l'Hopital's rule. The main difference is that <ref> puts the contents in a footnote, while we want it to appear at the same location - this should actually simplify matters. Thus, if we could add an extra attribute to the ref tag like contentsLocation=here and get the Cite extension to honour this attribute, we're in business. Then there is some styling to get right but that should not be too much of a problem. The same mechanism can also be used to refer to tables. To be clear, this gives only the possibility to refer to equations on the same page, not on other equations. Are there any issues with this?