Three Monkeys, Three Typewriters, Two Days

May 7, 2003

Speaking of TeX

When I first typed TeX in my previous comment, I entered it as "TeX". Then I thought to myself, "This is the Web, not a plaintext document. Surely I can use some CSS to mark this up so that it will look right!"

And indeed, simply doing

T<span style="vertical-align: -0.5ex;
              line-height: 0;
              text-transform: uppercase">e</span>X

did sort of what I wanted. Here the -0.5ex was a guess based on what I knew the result should look like, the line-height was needed to not cause an unsightly line-spacing increase (CSS3 has some proposed properties for handling this globally), and the text-transform was used to allow non-CSS clients to degrade gracefully.

There was just one problem. The result looked ugly as sin. Still does, really. So I took a peek at what \TeX is actually defined as. And that is:

T\kern-.2em\lower.5ex\hbox{E}X

So I was right about the vertical-align; what I was missing was the kerning. It's still missing, as you can tell, because I cannot think of a good way to do it in CSS (relative positioning is no good, since that will make the space after the "X" too big). Oh, well. Chalk up a point for 20-year-old technology.

On a related note, this is actually a case when use of the "style" attribute seems to be in order. I suppose I could set a class="e-in-TeX" on those spans and move the style into the site stylesheet, but that seems pretty silly too (though now that I have that markup in two or three places on this page that may indeed make sense). What I would like is a way to say, "Put TeX logo here," without having to repeat the icky markup for it every time. Chalk up a second point for 20-year-old technology, I guess.

Posted by bzbarsky at May 7, 2003 11:14 PM
Comments

As long as you serve the documents as some xml mime type, you can (using Mozilla at least), use an entity defined in the doctype to store the markup for the TeX logo and insert it as required. At least that worked when I tried it (FWIW my test page is at http://zeus.jesus.cam.ac.uk/~jg307/mozilla/TeX.xml). Of course that doesn't help here, since it would require the page to use a different doctype and be served with the appropriate mime type (my assertations being based on the behaviour of Mozilla rather than on any actual knowledge of the specifcations, so feel free to correct me). It would probably also break the page horribly in some other browsers.

The point is that the technology exists to do a lot of cool things, but they are underused. The problem is that UA implementations often suck, and the web being what it is requires ~100% backwards compatibility from all new documents, whereas documents for local use don't suffer this restriction.

Posted by: jgraham on May 8, 2003 2:39 PM

Ah, true. I could do that; I had not thought of it. Unfortunately, I'm not sure that would leave the document valid XHTML, and as you note as long as IE does not understand XML it the whole point is theoretical.... :(

Posted by: Boris on May 9, 2003 1:24 AM

How about <span style="letter-spacing: -.2em;">T</span> for creating the kerning?

Posted by: Tim on May 15, 2003 3:29 PM

Since there is only one letter in the , I would expect that to do absolutely nothing (since letter-spacing is applied _between_ letters, implementations bugs in Mozilla notwithstanding). I suppose I could wrap both the T and the E in the span, though...

Posted by: Boris on May 15, 2003 3:36 PM

If you were a purist and didn't want the style="" attribute in your markup, you could always use XBL to generate it... ;)

Posted by: Ben Smedberg on May 22, 2003 2:30 PM

Been there... The content management system of Macsanomat supports automatic span+CSS spesentation of TeX and LaTeX. That is, the author of the entry only writes “TeX” or “LaTeX” and the spans are added to the HTML output.

For example: http://www.macsanomat.com/nayta.php?id=451

Posted by: Henri Sivonen on July 9, 2003 8:32 AM

Yeah... the letter-spacing they end up using makes the 'X' pretty much overlap the 'E', which looks terrible. :(

Posted by: Boris on July 9, 2003 1:01 PM
Post a comment