Tag Archives: html

Writing math for the web

Abstractmath

I built my website abstractmath.org during the years 2002 through 2006. After that I made sporadic changes, but medical operations and then teaching courses as an adjunct for a couple of years kept me from making much progress until 2010.

This post is an explanation of the tools I used for abstractmath, what went right and what went wrong, and my plans for redoing the website.

Methodology

My previous experience in publishing math was entirely with TeX. When I began work on abstractmath, I wanted to produce html files, primarily because they refloated the text when the window width changed. I was thinking of small screens and people wanting to look at several windows at once.

In those days, there was no method of starting with a LaTeX input file and producing an html file that preserved all the math and all the formatting. I have over the years spent many hours trying out various systems that claimed to do it and not found one that did not require major massaging to get the look I wanted. Most of them can cannot implement all LaTeX commands, or even most of the LaTeX formatting commands. (I have not looked at any of these since 2011.)

In contrast, systems such as PDFTeX turn even very complicated (in formatting and in math) LaTeX files into nearly perfect PDF files. Unfortunately, PDF files are a major impediment to having several windows open at once.

Word and MathType

My solution was to write abstractmath articles using Microsoft Word with MathType, which provides a plugin for Word.

The MathType interface was a very useful expansion of the Equation Editor in Word, and it produced little .gif files that were automatically inserted into the text. MathType also provided a command to create an html file. This file was produced with the usual “_files” folder that contained all the illustrations I had included as well as all the .gif files that MathType created. The html file contained code that put each .gif file in the right place in the typeset text.

That combination worked well. Using Word allowed me tight control over formatting and allowed floating textboxes, which I used freely. They very nicely moved around when you changed the width of the window.

I had used textboxes in my book A Handbook of Mathematical Discourse for apt quotations, additional comments, and (very clever if I say so myself) page indexes. The Handbook is available in several ways:

  • Amazon. The citations are not included.
  • The Handbook in paper form. A pdf file showing the book as it appears on paper (all the illos, textboxes and page indexes, no hyperlinks), plus all the citations. (This paragraph was modified on 2013-05-02).
  • A version with hyperlinks, This includes the citations but omits the boxes and the illustrations, and it has hyperlinks to the citations. The page indexes are replaced by internal hyperlinks.
  • The citations.

That book was written in TeX with much massaging using AWK commands. Boxes are much easier to do in Word than they are in TeX, and the html files produced by MathType preserved them quite well. The abmath article on definitions shows boxes used both for side comments and for quotations.

There were some problems with using MathType and Word together. In particular, a longish article would have dozens or hundreds of .gif files, which greatly slowed down uploading via ftp. I now have WebDrive (thanks to CWRU) and that may make it quicker.

Rot sets in

Without my doing anything at all, the articles on abstractmath began deteriorating. This had several main causes.

  • Html was revised over time. Currently it is HTML5.0.
  • Browsers changed way they rendered the html. And they had always differed among themselves in some situations.
  • Microsoft Word changed the way it generated html.

Two of the more discouraging instances of rot were:

  • Many instances of math formulas are now out of line with the surrounding text. This happened without my doing anything. It varies by browser and by when I last revised the article.
  • Some textboxes deteriorated. In particular, textboxes generated by newer versions of Word were sometimes nearly illegible. Part of the reason for this is that Word started saving them as images.

Failed Forays

The main consequence of all this was that I was afraid of trying to revise articles (or complete them) because it would make them harder to read or ugly. So I set out to find new ways to produce abmath articles. This has taken a couple of years, while abmath is a big mess sprawling there on its website. A mostly legible big mess, and most of the links work, but frustrating to its appearance-sensitive author.

Automatically convert to a new system

My first efforts were to find another system with the property that I could convert my present Word files or html files to the new system without much hand massaging.

I tried converting the Word files to LaTeX input. This was made easier (I thought) because MathType now provided a means for turning all the MathType itty bitty .gif files into LaTeX expressions. I wrote Word macros to convert much of the formatting (italics, bold, subheads, purple prose, and so on) into LaTeX formatting — although I did have to go through the Word text, select each specially formatted piece, and apply the correct macro.

But I had other problems.

  • Converting the Mathype images files to LaTeX caused problems because it messed up the spaces before and after the formulas.
  • I worked with great sweat and tears to write a macro to extract the addresses from the links — and failed. If I had presevered I probably would have learned how to do it, and learned a lot of Word macros programming in the process.

The automatic conversion process appeared to require more and more massaging.

I made some attempts at automatically converting the html files that Word generates (instead of the doc files), but they are an enormous mess. They insert a huge amount of code (especialy spans) into the text, making it next to impossible to read the code or find anything.

It was beginning to look like I would have to go to an entirely new system and rewrite all the articles from scratch. This was attractive in one respect: in writing this blog my style has changed and I was seeing lots of things I would say or do differently. I have also changed my mind about the importance of some things, and abmath now has stubs and incomplete articles that ought to be eliminated with references to Wikipedia.

Go for rewriting

Meanwhile, I was having trouble with Gyre&Gimble. The WordPress editor works pretty well, but two new products came along:

  • MathJax was introduced, providing a much better way to use TeX to insert formulas. (Note: MathType recently implemented the use of MathJax into its html output.)

  • Mathematica CDF files, which are interactive diagrams that can be inserted directly into html. (My post Improved Clouds has examples.)

Both MathJax and CDF Player require entering links directly in the html code the WordPress editor produces. The WordPress editor trashed the html code I had entered every time I switched back and forth between “visual” (wysiwyg) and html.

I switched to CKEdit, which preserved the html but has a lot of random behavior. I learned to understand some of the behavior but finally gave up. I started writing my blogs in html using the Coffee Cup HTML Editor — that is how I am writing this. Then I paste it into the WordPress editor.

My current plan is to start revising each abmath article in this way:

  • Write html code for the special formatting I want, mostly the code that produces the header, but also purple prose and other things. Once done I can use this code for all the abmath articles with little massaging.
  • Start with the Word doc file for an article and use MathType to toggle all the MathType-generated gif files into TeX.
  • Generate the html file in a way that preserves the TeX code with dollar signs. (There are two ways to do this and I have not made up my mind which to use.)
  • Start revising!

I have already begun doing this. My intention is to revise each abstractmath article, post it, and announce the posting on Gyre&Gimble or on Google+. If an article is heavily revised I expect to post it (or parts of it) on Gyre&Gimble. Some of these things will be ready soon.

Last minute notes

  • I used WinEdt, a text editor, to write the Handbook of Mathematical Discourse. It is a powerful html editor, with an extensive macro language that in particular allows rearranging the menus and adding new code to call other applications. It is especially designed for TeX, so is not as convenient as it stands for html. However, its macro language would allow me to convert it to a system that will do most of what Coffee Cup can do. I might do this because Coffee Cup has no macro language and (as far as I can tell) has no way to revise or add to menus.
  • It is early days yet, but I am thinking of including pieces of Abstracting Algebra into abstractmath.org.

Send to Kindle

Definition of “function”

I have made a major revision of the abstractmath.org article Functions: Specification and Definition.   The links from the revised article lead into the main abstractmath website, but links from other articles on the website still go back to the old version. So if you click on a link in the revised version, make it come up in a new window.

I expect to link the revision in after I make a few small changes, and I will take into account any comments from you all.

Remarks

1.  You will notice that the new version is in PDF instead of HTML.  A couple of other articles on the website are already in PDF, but I don’t expect to continue replacing HTML by PDF.   It is too much work.  Besides, you can’t shrink it to fit tablets.

2. It would also have been a lot of work to adapt the revision so that I could display it directly on Word Press.  In some cases I have written revisions first in WP and then posted them on the abmath website.  That is not so difficult and I expect to do it again.

Send to Kindle

Experiment with abstractmath.org

This is a rant about technical problems with creating abstractmath.org.  You will not get great new insights into mathematical language.  You will not get any purty pictures, either.  But if you read the following anyway and have suggestions, I would appreciate them no end.

I have long been frustrated with the process I used to create articles for abstractmath.  The process has been this:  I write the article in Word using MathType, then use their facility for generating an html file that uses pictures (stored in separate files) for the more complicated math expressions, then load them into the abstractmath website.

There are many good and bad things about this. Two of the most aggravating:

  • It is difficult to change links if I reorganize something.  With a TeX file I could write WinEdt macros to do it, but the Word macro language makes manipulating links (and doing many other things) a %#!!*.
  • The documents look different in different browsers.  IE Explorer 8 does the best job, Chrome looks uglier, and Firefox is the ugliest.  After a document has been posted for a while, sometimes I open it to discover weird things, such as the recent discovery that some of my bullets had turned into copyright signs (Firefox turns bullets into double hyphens that are close to invisible).

For the past few weeks I have experimented with generating PDF documents using PDFLaTeX.   I did this with the section called Functions: Notation and Terminology, the only one that is posted so far.  Posting it required 45 minutes  of fixing links in other articles by hand.

Creating that section in TeX was a pain.  I used GrindEQ Math to convert the original document to TeX, which required a great deal of preprocessing (mostly to recover the links, but for some formatting things too) and postprocessing to fix many many things.  I also had to recreate the sidebars by hand; I used wrapfig. Wrapfig does not work well.

In the process of converting this and some other files that I may post later, I created a bunch of macros in the Word macro language (horrible, although in principle I believe in OOP) and the WindEdt macro language, which is pretty good.  Even with the macros, it is a lot of labor to do the conversion.

I have decided to abandon the effort.  I may post a few more articles that I have already transferred to  PDF, but I doubt I will revise any more from scratch.

One thing that has changed since I started doing the conversions was that a recent revision of MathType allows you to type the equations directly in TeX and to toggle back and forth between MathType form and TeX form.  Before that you had to select symbols from a palette.  That was the single most frustrating thing about using Word with MathType.  I type fluently in TeX but I couldn’t use it.  Now that I can type the TeX in directly the prospect of editing articles and writing new ones using Word is much less painful.

So one direction I will go in is to revise the articles already on the web using Word and MathType.  I also expect to kill a good many of the incomplete or less well thought out ones in favor of links to Wikipedia.

But there is another direction, opened up by Mathematica’s Computable Document files.  I have published some experiments with this in the last four posts here.  I expect to be able to turn some of the articles in abstractmath.org into computable documents.  The reader will have to have to have the free CDF Player on their computer, but if you download it once you have it forever.

Send to Kindle

Presenting math on the web

This is a long post about ways to present math on the web, in the context of what I have done with The Handbook of Mathematical Discourse and abstractmath.org (Abmath).  “Ways to present math” include both organization and production technology.

The post is motivated by and focused on my plans to reconstruct Abmath this fall, when I will not be teaching.    During the last couple of years I have experimented with several possibilities for the reconstruction (while doing precious little on the actual website) and have come to a tentative conclusion about how I will do it.  I am laying all this out here, past history and future plans, in the hope that readers will have suggestions that will help the process (or change my mind).

I set out to write both the Handbook and Abmath using ideas about how math should be presented on the web.  They came out differently.  Now I think I went wrong with some of the ways in which I organized Abmath and that I need to reconstruct it so that it is more like the Handbook.  On the other hand, I have decided to stick with the production method I used for Abmath. I will explain.

Organization

My concept for both these works was that they  would have these properties:

1) Each work would be a cloud of articles. They would have little or no hierarchy.  They would consist of lots of short articles, not organized into chapters, sections and subsections.

2) The articles would be densely hyperlinked with each other and with the rest of the web. The reader would use the links to move from article to article. The articles might occur in alphabetical order in the production file but to the reader the order would be irrelevant.

I wanted the works to be organized that way because that is what I wanted from an information-presenting website.  I want it that way because I am a grasshopper. Wikipedia and n-lab are each organized as a cloud of articles. I started writing the Handbook in the late nineties before Wikipedia began.

The Handbook exists in two forms. The web version is a hypertext PDF file that consists of short articles with extensive interlinking. The printed book has the same short articles arranged in alphabetical order. In the book form, the links are replaced by page indices (“paper hyperlinks”). In both forms some links are arranged as lists  of related topics.

Abstractmath.org is a large, interlinked collection of html pages.  They are organized in four large sections with many subsections.

Many entrances

For this cloud of articles arrangement to work, there must be many entrances into the website, so that a reader can find what they want. The Handbook has a list of entries in alphabetical order. Certain entries (for example the entries on attitudes, on behaviors, and on multiple meanings) have internal lists of links to examples of what that entry discusses.  In addition, the paper version has an index that (in theory) provides links to all important occurrences of each concept in the book.  This index is not included in the current hypertext version, although the LaTeX package hyperref would make it possible to include it.  On the other hand, the hypertext version has the PDF search capability.

Abmath has a table of contents, listing articles in hierarchical form, as well as an index, which is different from the Handbook index in that it gives only one link from each word or phrase. In addition, it has header sections that briefly describe the contents of each main section and (in some cases) subsection, and also a Diagnostic Examples section (currently fragmentary)in which each entry provides a description of a particular problem that someone may have in understanding abstract math, with links to where it is discussed. The website currently has no search capability.

The Handbook is really a cloud of articles, and Abmath is not. I made a serious mistake imposing a hierarchy on Abmath, and that is the main thing I want to correct when I reconstruct it.  Basically, I want to dissolve the hierarchy into a cloud of articles.

Production methods

The Handbook was composed using LaTeX.  It originally existed in hypertext form (in a PDF file) and lived on the web for several years, generating many useful suggestions. I wrote a LaTeX header that could be set to produce PDF output with hyperlinks or PDF output formatted as a book with paper hyperlinks; that form was eventually published as a book.

I used a number of Awk programs to gather the various kinds of links.  For example, every entry referring to a math word that has multiple meanings was marked and an Awk program gathered them into a list of links.

I generated the html pages for Abmath using Microsoft Word and MathType.  MathType is very easy to use and has the capability (recently acquired) of converting all math entries that it generated  into TeX. The method used for Abmath has several defects.  You can’t apply Awk (or nowadays Python) programs to a Word document since it is in a proprietary format.  Another problem is that the appearance of the result varies with browser.

But the Abmath method also has advantages.  It produces html documents which can be read in windows that you can make narrower or wider and the text will adjust.  PDF files are fixed width and rigid, and I find clicking on links requires you to be annoyingly precise with your fingers.

So my original thought was to go back to LaTeX for the new version of Abmath. There are several ways to produce html files from LaTeX, and converting the MathType entries to TeX provides a big headstart on converting the Word files into text files.  Then I could use Awk to do a lot of bookkeeping and cut the hyperlink errors, the way I did with the Handbook.

So at first I was quite nostalgic about the wonderful time I had doing the Handbook in LaTeX — until I remembered all the fussing I did to include illustrations and marginal remarks. (I couldn’t just put the illo there and leave it.) Until I remembered how slowly the resulting PDF file loads because there seems to be no way to break it into individual article files without breaking the links.

And then I found that (as far as I could determine) there is no HTMLTeX that produces a reasonable HTML file from any TeX file the way PDFTeX produces a PDF file from any TeX file, using Knuth’s  TeX program. In fact all the TeX to HTML systems I investigated don’t use Knuth’s program at all — they just have code in some programming language that reads a TeX file and interprets what the programmer felt like interpreting.  I would love to be contradicted concerning this.

So now my thought is to stick with Word and MathType.  And to do textual manipulation I will have to learn Word Basic.  I just ordered two books on Word Basic. I would rather learn Python, but I have to work with what I have already done.  Stay tuned.

Send to Kindle