Last modified: 2014-09-23 22:41:41 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T8636, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 6636 - texvc produces misaligned math output for some tex commands
texvc produces misaligned math output for some tex commands
Status: RESOLVED DUPLICATE of bug 32694
Product: MediaWiki extensions
Classification: Unclassified
Math (Other open bugs)
unspecified
All Linux
: Low normal with 3 votes (vote)
: ---
Assigned To: Nobody - You can work on this!
: patch, patch-need-review
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2006-07-12 00:53 UTC by Michael Vanier
Modified: 2014-09-23 22:41 UTC (History)
5 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
Changes to fix vertical alignment of png-rendered math formulas (16.25 KB, patch)
2009-11-07 05:15 UTC, Cotton Seed
Details

Description Michael Vanier 2006-07-12 00:53:40 UTC
This page:
http://meta.wikimedia.org/wiki/Help:Formula#Align_with_normal_text_flow  says
that the default settings of the mediawiki (monobook) stylesheet should give
correctly centered math formulas when used inline in the middle of a sentence of
normal wikitext.  The example given does indeed center properly, but some other
kinds of formulas do not.  For instance: this formula: <math>2 \cdot 2 =
4</math> renders about 15% below the text line (the dot is aligned with the
bottom of the text line), which looks completely wrong.  This can be fixed by
putting font tags into the wikitext, but this is extremely tedious.
Comment 1 Raimond Spekking 2007-05-25 07:37:13 UTC
This is an texvc issue --> changing product/component
Comment 2 Random832 2007-11-15 16:06:43 UTC
[[w:en:User:Random832/Math baseline]] demonstrates a hypothetical fix using CSS vertical alignment (texvc would need to determine where the baseline is located in the image, and generate an appropriate pixel value for the vertical-align, to be applied via style="" to the img tag)
Comment 3 Random832 2007-11-15 16:08:09 UTC
The correct address is [[User:Random832/Math baseline]] - I'd assumed wikilinks were relative to meta rather than enwiki.
Comment 4 Cotton Seed 2009-11-06 16:05:35 UTC
I wrote a fix for this bug.  Random832's suggestion is good (use vertical-align to set the baseline for math formulas rendered as images), but the question is: how do you compute the baseline?  My idea is this: (1) underline the formula, on the baseline, in red, (2) write a tool invoked by texvc to find the underline (= baseline) in the image, and (3) call ImageMagick to strip out the underline in the final image, and (4) store the baseline in the math table for use when generating HTML linking to the image.

The result looks really good.  These changes are mixed with a bunch of others in a live wiki, but hopefully next week I'll have time to extract them and post diffs.
Comment 5 Cotton Seed 2009-11-07 05:15:02 UTC
Created attachment 6757 [details]
Changes to fix vertical alignment of png-rendered math formulas

Here are my proposed changes.  There is one thing I did not deal with properly: the program that computes the baseline uses libpng and is written in C.  I added a naive target to math/Makefile to build it using gcc, but a proper, portable build script is beyond me.  Maybe someone familiar with autoconf would be willing to contribute such a thing?  Although, honestly, expecting gcc and libpng to be installed seems less onerous than expecting ocaml to be installed.

Feedback welcome.
Comment 6 Alexey Sergushichev 2010-03-23 18:26:47 UTC
(In reply to comment #4)
> I wrote a fix for this bug.  Random832's suggestion is good (use vertical-align
> to set the baseline for math formulas rendered as images), but the question is:
> how do you compute the baseline?  My idea is this: (1) underline the formula,
> on the baseline, in red, (2) write a tool invoked by texvc to find the
> underline (= baseline) in the image, and (3) call ImageMagick to strip out the
> underline in the final image, and (4) store the baseline in the math table for
> use when generating HTML linking to the image.
> 
> The result looks really good.  These changes are mixed with a bunch of others
> in a live wiki, but hopefully next week I'll have time to extract them and post
> diffs.

There is a very simple way to compute baseline position. LaTeX has a standard package called preview http://www.gnu.org/software/auctex/manual/preview-latex.html#Package-options.
If a formula is in preview section latex put information about baseline to dvi file. Then it can be extracted by dvipng with -depth option.

Example:
assaron@assaron:~/tmp$ cat ex.tex                   
\documentclass{article}
\usepackage[displaymath,active]{preview}
\begin{document}
\thispagestyle{empty}
\begin{preview}
$a_{a_a}$
\end{preview}
\end{document}

assaron@assaron:~/tmp$ latex ex.tex                 
This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian)
 restricted \write18 enabled.
entering extended mode
(./ex.tex
LaTeX2e <2009/09/24>
Babel <v3.8l> and hyphenation patterns for english, usenglishmax, dumylang, noh
yphenation, bulgarian, ukrainian, russian, loaded.
(/usr/share/texmf-texlive/tex/latex/base/article.cls
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
(/usr/share/texmf-texlive/tex/latex/base/size10.clo))
(/usr/share/texmf/tex/latex/preview/preview.sty) (./ex.aux)
Preview: Fontsize 10pt
[1] (./ex.aux) )
Output written on ex.dvi (1 page, 280 bytes).
Transcript written on ex.log.

assaron@assaron:~/tmp$ dvipng -T tight -depth ex.dvi
This is dvipng 1.12 Copyright 2002-2008 Jan-Ake Larsson
[1 depth=3]
Comment 7 intnumerix 2011-02-10 15:21:32 UTC
This bug is always open : some formulas are correctly aligned but with two or more in whole line, there is some misalignments...

The solution found by Aleksey Sergushichev seems to be pretty.

Can someone take care of this issue ?
Comment 8 Brion Vibber 2012-03-02 00:42:46 UTC
I'm duping this to bug 32694, where there's some work in progress using the preview package and -depth option on dvipng. This has a more recent patch, and I trust that method better than the pixel scan used in the original patch here.

*** This bug has been marked as a duplicate of bug 32694 ***
Comment 9 Sumana Harihareswara 2012-03-02 00:43:39 UTC
Cotton Seed -- just wanted to say, thanks for the patch.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links