Friday, 5 September 2014

Creating matrix of any size in Microsoft Equation Editor

I sometimes have to work with Microsoft Word Equation Editor. I cannot see very well from the peace of paper, so it’s easier for me to write equations using computer. There are a lot of shorthands that can accelerate work in the editor, but today I’m going to show you how to do something, which is hard to do with mouse. We are going to build a custom matrix.

In the toolbar we have some matrixes to choose from. We have all options including one, two and three rows and columns. It’s not sufficient for many equations. How to do something custom.

Firs way is to just build the matrix from many smaller matrixes. If we need for example 4x4 we can just put one 2x2 and in every cell of that matrix put additional 2x2 matrix. It may be good solution, but if the length of the content is diverse it becomes ugly. Cells in each matrix are adjusted different.

Better way is to “write” matrix yourself. You can use LaTeX-like syntax in equation editor, so lets make matrix using this syntax. Currently I need just a 2x1 matrix to create Newton’s binomial. Yes – I can get it from the toolbar, but it causes getting hands out from the keyboard. I prefer writing instead of clicking, so I write almost everything. Let’s go back to our binomial. We need to type:

\matrix(@)

Word is going to create matrix just after typing right bracket and spacebar. During the typing a black rectangle and one left bracket appears, but don’t worry about that. “/matrix” means that we’ll create some custom matrix. By using symbols in the brackets we tell equation editor how big the matrix will be. We can use two symbols there. “@” tells to create a new row and “&” tells to do a now column. Note, that we start from 1x1 matrix and we specify just how to enlarge it – not how many cells will appear. Two rows – one “@”. Two columns – one ampersand. So let’s create a 4x6 matrix.

\matrix(&&&&&@&&&&&@&&&&&@&&&&&)

Again – six cells in each row means that we need to type “&” five times – five “separators” between cells. Four rows means that we need “@” three times – the “line breaks”. It’s easy – isn’t it?

Anyway Equation Editor in Word 2013 is always creating square matrix matching maximum rows and columns declared in the code, so you can declare your cells and rows one time. Let’s get 3x7 matrix (3 rows with each of 7 cells).

\matrix(&&&&&&@@)

It’s shorter and it works well. Just keep in mind that you shouldn’t mix “&” and “@”.\

\matrix(&&@&)

would create 2x3 matrix because maximum row length is 2. The last “&” says that we need two columns in the second row. EQ editor is going to create 3 rows as I said before.

So now we can create any matrix we need. EQ editor is keeping them aligned and ordered just how we need. Have fun creating your own equations.

No comments:

Post a Comment