Page MenuHomePhabricator

latex and spanish projects (sine function wrongly displayed)
Closed, ResolvedPublic

Description

Author: pdsanchez

Description:
png showing the proper spacing for operatorname

There's a very frequent and recurrent headache on spanish projects relating to latex: the proper way to typeset "sine funcion" in spanish is "sen", not "sin".

This leads to several inconsistent situations and ugly hacks.
Currently, the common hack is typeset \mathrm{sen} everytime sine function is needed (if not just typeset it on english)
However, the problem is that it breaks spacing in the formula.

Now, mediawiki's latex loads AMS's classes (amsmath.sty) allowing to use \operatorname in order to solve the problem.
Typing \operatorname{sen} should give proper spacing, as shown here:

The expected behavior is: http://matmor.unam.mx/~drini/seno.png


Now back to mediawiki: as mentioned, latex's mediawiki allows "\operatorname" to be used, but although it typesets in roman font, the spacing is bad. See

http://es.wikipedia.org/wiki/Usuario:Drini/seno

The ONLY way to get the proper effect on mediawiki at this moment is to use the ugliest hack
\operatorname{sen\, }

So, this bugs raises the following issues (any of which would solve the problem):

  • fix \operatorname parsing to give proper spacing
  • allow a definition of \sen globally for spanish projects
  • modify \sin so it typesets "sen" in spanish projects (like latex babel's package does)
  • fully allow babel package for texvc (so these sorts of problems won't arise on other languages, and every language gets proper math typesettting)

Now, this is not a bug asking to allow custom latex commands everywhere.
It's a *very exceptional case* since \sin is one of the most widely used commands yet it doesn't get displayed right and poor hacks with wrong spacing that ruin formulas are commonly used.


Version: unspecified
Severity: enhancement
URL: http://es.wikipedia.org/wiki/Usuario:Drini/seno

Attached:

seno.png (203×664 px, 19 KB)

Details

Reference
bz18912

Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 10:38 PM
bzimport set Reference to bz18912.
bzimport added a subscriber: Unknown Object (MLST).

nmichalo wrote:

It seems the code adds a { } around \operatorname (or any function taking 1 argument) and runis the spacing. The following patch to the code should fix it.

Attached:

nmichalo wrote:

*** Bug 14825 has been marked as a duplicate of this bug. ***

pdsanchez wrote:

A neat way to solve this and a whole class of related international problems would be:

Add \usepackage{language}[babel]
to the sitewide preamble, where language=spanish for spanish wikis

A more useful, albeit more complex
would be creating
MediaWiki:Latex
or something like that where (similarly to MediaWiki:common.css or MediaWiki:Vector.js) custom latex preambles could be set for each wiki

pdsanchez wrote:

Also, fixing "\operatorname" is not an optimal solution, since it would still be necessary to write \operatorname{sen} EVERYTIME sine funcion is shown (which may be a dozen times within an article, for hundreds of articles).

The proper (understandably more difficult than a quick hack) would be allowing a wiki to define either own latex commands (custom latex preambles as above) to define \sen or correctly set babel's package language so \sin shows "sen" without having to define a new command.

nmichalo wrote:

Well I agree allowing custom preambles is the way to go, but with what little passing familiarity I have of the code, I think it would require a complete re-write of texvc. Which is generally needed for many reasons, but I don't think the texvc portion of the code has any developers interested in it. So it may be a long wait before any serious changes get made.

I only just started looking at the code, but probably getting it to add simple \DeclareMathOperators would be workable, which would take care of sen. More general preambles like including new packages pose a problem because the current code try's to independently validate every accepted latex command. So if you include a new package, you then need to write code for every command that package is supposed to make available. This is why not all AMS commands work on wiki.

nmichalo wrote:

A patch has been added that defines \sen and the spacing of \operatorname has been corrected.

pdsanchez wrote:

This needs to be reopened as it doesn't seem to do what it says on the closing:

http://es.wikipedia.org/wiki/Usuario:Magister_Mathematicae/seno

using said \sen causes math errors (undefined function)

What does this have to do with XML snapshots?

pdsanchez wrote:

I don't know, I just clicked on reopen and pressed OK

nmichalo wrote:

I forgot to mention that it was r86962 that fixed this bug in texvc.

r86962 has been provisionally reverted pending test cases.

It should be straightforward to add a parser test case to confirm that \sen x, \sen{x}, \sen(x) work.

Not sure about confirming the output spacing on \operatorname{sen} x - but I think it'll make a difference to output hash, and therefore the rendered PNG image filename -- which will turn up on parser test output. So that should be able to protect against regression.

Created attachment 9057
Provisional parser tests for 6722 & 18912

The \sin{x} forms no longer work as they previously did with r86962 and r87117 in -- this seems to be a nasty regression?

Note that r86962 and r87117 remain reverted on trunk for now.

Attached:

Ok, with r87936 and r87941 added in that's fixed up -- was hard to tell what revs connected to what. :) Looking good so far, should be merged shortly.