Fun with multipart equations in Word 2007

In my latest article for PCPlus, I had to replicate an equation with several clauses, like this one from Wikipedia:

Definition of the sign of x

I fired up Word 2007 to use its new Equation Editor, since it's the best tool I have for this kind of work.

The "sgn x" bit I did via the Function menu, selecting "sin", and modifying the name of the function.

Starting to write the expression

Adding the brace was fine — there's a "structure" for it (as EE calls them).

The expression with a brace, but only one input block

But that's only one block to type anything in. I messed around trying to put a carriage return in there somehow, when I suddenly realized there was probably a structure with three input blocks, vertically. Yep, there is, in the Matrix menu.

Expression with three input blocks, one per line 

I then filled in the blanks to get this:

Nasty looking expression

Which is nasty. One of the problems is that the equation editor thinks text should be italicized since it's forming part of the expression. Even converting the ifs to Normal text doesn't help, since the clauses won't line up vertically. I did think about adding some spaces to line things up, but, no, abandon that.

Next attempt was inserting a matrix of 6 cells in a 2x3 arrangement.

Expression with a matrix of input blocks

Which finally gave me this, after setting the ifs to normal text:

Definition of sign function, written with EE in Word 2007

Having done that, I then applied what I'd learnt to the real equation I was trying to replicate, and got this:

Multipart expression with the clauses not lined up

Which I wasn't too happy with. I really wanted the clauses in the right column to line up on the left.  I played around for a little while (no, paragraph justify left doesn't work) and got to the answer: right-click on an element in that second column and select Column Alignment, Left. Adding some parentheses gave me this, which I feel is very readable.

Multipart expression written with EE in Word 2007 

The interesting thing is, this equation editor is only available in docx files in Word 2007. As soon as you convert the file to a Word 2003 doc file, you get a warning and the equation is converted into an image.

Also, a handy hint: if you are editing a Word document and you want to insert an equation, your instinct is to go to the Insert tab, and click on Equation. If it's disabled, you are editing a doc file and not a docx file. Save the file as docx, and the item will be enabled.

Oh, before you ask, the equation is part of the DCT (Discrete Cosine Transform) in the JPG compression algorithm.

Album cover for Disco Four Now playing:
Pet Shop Boys - Walking on thin ice
(from Disco Four)


Loading similar posts...   Loading links to posts on similar topics...

No Responses

Feel free to add a comment...

Leave a response

Note: some MarkDown is allowed, but HTML is not. Expand to show what's available.

  •  Emphasize with italics: surround word with underscores _emphasis_
  •  Emphasize strongly: surround word with double-asterisks **strong**
  •  Link: surround text with square brackets, url with parentheses [text](url)
  •  Inline code: surround text with backticks `IEnumerable`
  •  Unordered list: start each line with an asterisk, space * an item
  •  Ordered list: start each line with a digit, period, space 1. an item
  •  Insert code block: start each line with four spaces
  •  Insert blockquote: start each line with right-angle-bracket, space > Now is the time...
Preview of response