I have forgotten
my Password

Or login with:

  • Facebookhttp://facebook.com/
  • Googlehttps://www.google.com/accounts/o8/id
  • Yahoohttps://me.yahoo.com
Index » Products » LaTeX Equation Editor »

Nice Display Bug (not imortant)

tdt.hain\′s Photo
17 Jan 11, 5:45AM
(7 replies)
Nice Display Bug (not imortant)
Input: \mathbf{\textbf{\bigotimes}} juhu tiny font

Not really important but ok :D hf Torsten
will\′s Photo
17 Jan 11, 12:15PM
Now that's a cool fault. I've seen something similar with \frac{ }, but have no idea internally what causes it.
stephem\′s Photo
26 Jan 11, 10:18AM
This is a fascinating bug which is caused by the underlying TeX engine not the CodeCogs implementation of it. You can reproduce the bug in a document by using
$\displaystyle\mathbf{\textbf{\bigotimes}}$
which results in 44 errors!

The cause of the error is that \bigotimes must be in maths mode but
\textbf{\bigotimes}
puts it in text mode. You can see this if you type
\mathbf{\textbf{\ensuremath{\bigotimes}}}
and the bug disappears.

Of course the question is why does this cause such an odd display of 4 different fonts? The answer lies deep inside TeX. It's really the \text command that's causing the problem as it adjusts the font according to whether the contents are subscripts, superscripts etc. It does this using \mathchoice.

The details are given in Knuth's TeXbook (Knuth is the author of TeX of course):

TeX has a special feature called \mathchoice that comes to the rescue in such situations: You write

\mathchoice{<math>}{<math>}{<math>}{<math>}

where each < math > specifies a subformula. TeX will choose the first subformula in style D or D', the second in style T or T', the third in style S or S', the fourth in style SS or SS'. (TeX actually typesets all four subformulas, before it chooses the final one, because the actual style is not always known at the time a \mathchoice is encountered; for example, when you type '\over' you often change the style of everything that has occurred earlier in the formula.

(D,D' = displaystyle, T,T' = textstyle, S,S' = scriptstyle, SS,SS' = scriptscriptstyle; D',T',S',SS' are cramped versions which don't raise exponents so much but are otherwise the same)

It's clear then that TeX never makes a choice due to the errors so leaves the 4 styles there, which explains the different font sizes.

will\′s Photo
26 Jan 11, 10:01PM
Steve thanks for the great insight.

I've been following the work on the latest incarnation of LaTeX3 project, but haven't tried using it. Have you any experience with this; would this fix the above bug?
stephem\′s Photo
26 Jan 11, 10:45PM
I haven't tried it either. LaTeX3 has been in development for over 10 years though progress has accelerated recently. The problem is that it is a vast task that is being written by people like Joseph Wright and Will Robertson in their spare time, so it may be a long time before it is ready. So I haven't got too excited about it!

The question is, how will LaTeX3 deal with syntax errors like the above? One person who might know the answer is the British developer Joseph Wright who maintains a blog at Some TeX Developments
will\′s Photo
27 Jan 11, 8:04AM
I should follow up with Joseph. My problem is that while we've optimised everything we can within our LaTeX rendering system, including catch all known bugs (except the current one!), to coding into one module many of the translators from DVI to gif, svg etc, we are ultimately reliant on the underlying LaTeX distribution. However we actually only what a small subset of everything LaTeX can do, so its now our only bottleneck.

If you follow the work of Mathjax which evolved from jsmath , then you rapidly come to the appreciation that we should be able to write our own maths rendering engine and bypass the entire LaTeX2 suite. The trouble with this is this is just something else to do, and I'm certainly busy enough, and we'll potentially struggle to remain fully compliant. Hence my interest in LaTeX3, and the hope this is more modular and we can link into our code the bits we need.

In case you're wondering, mathjax though beautifully done has a slightly different market. We can put equations anywhere, on other peoples blogs, in excel, word, etc. Mathjax can only really be installed by site admin and has a fairly hefty footprint when you only want 1 or 2 equations on your page.
stephem\′s Photo
27 Jan 11, 10:22AM
My only problem with Mathjax is that the equations can be quite slow to load. Images may not be immediate but they are faster than Mathjax which even has a little counter to show how far it has got.

I notice that the original version of LatexRender gives an error with
\mathbf{\textbf{\bigotimes}}
so somewhere your code may be suppressing this error.
will\′s Photo
28 Jan 11, 11:23PM
I'll have to investigate exactly how this is being handled. For the most part we have a accepted list of keywords, that we know are reliable, like \frac{..}{..} etc. Anything outside that, and we through LaTeX into strict mode so it stops with the slightest error. This way we have a staggeringly stable system.
Currently you need to be logged in to leave a message.