TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What are your techniques to make what's below look better? Thanks.


\begin{equation}\everymath{\displaystyle}\begin{pmatrix} \ud X_1
\\ \ud X_2 \\ \ud X_3
\end{pmatrix}=\begin{pmatrix} \ud x_1 \\ \ud x_2
\\\ud x_3 \end{pmatrix}+\begin{bmatrix}
\frac{\partial u_1}{\partial x_1} & \frac{\partial u_1}{\partial x_2} & 
\frac{\partial u_1}{\partial x_3} \\
\frac{\partial u_2}{\partial x_1} & \frac{\partial u_2}{\partial x_2} & 
\frac{\partial u_2}{\partial x_3} \\
\frac{\partial u_3}{\partial x_1} & \frac{\partial u_3}{\partial
x_2} & \frac{\partial u_3}{\partial x_3}
\end{bmatrix}\begin{pmatrix} \ud x_1 \\ \ud x_2 \\
\ud x_3 \end{pmatrix}

rendered code

share|improve this question
up vote 3 down vote accepted

This is more a mathematical than a TeXnical answer: I would typeset the matrix with \partial_1 u_1 instead of \frac{\partial u_1}{\partial x_1} and so on. Then it looks better, and I also find that it is better readable. You may want to explain that the notation \partial_j is a shorthand for \frac{\partial}{\partial x_j}.

share|improve this answer
interesting. Thanks – pluton Oct 2 '10 at 14:36

One other option is to use \phantom and \lefteqn as in this answer. For the pmatrix blocks, change it to, for example

\lefteqn{\phantom{\frac{\partial u_1}{\partial x_3}}} dx_1 \\
\lefteqn{\phantom{\frac{\partial u_2}{\partial x_3}}} dx_2 \\
\lefteqn{\phantom{\frac{\partial u_3}{\partial x_3}}} dx_3

Inside the \phantom should go the "tallest" term in the row you want to line up.

share|improve this answer
I would use \vphantom{...} in preference to \lefteqn{\phantom{...}}. I would also define a strut: \newcommand*{\mystrut}{\vphantom{\frac{\partial u_1}{\partial x_3}}} to make the latex more legible. – Lev Bishop Oct 2 '10 at 21:28
Thank you Lev, now my toolbox gets one more tool! Though I am undecided about the strut: I can't decide whether it is better to stretch all rows by the same, possibly much too large amount, or let the height of each row be decided by its tallest element. (Say if the example has \int_0^{2^{3^{4^5}}} f(x) dx in the third column of the third row of the bmatrix, which would you prefer?) – Willie Wong Oct 3 '10 at 1:55

Here's a way improving the spacing of you notation. It's a redefinition of an internal amsmath macro. It allows to add an optional space to each matrix row and it's extending all amsmath matrix environments like bmatrix, pmatrix, vmatrix, Bmatrix etc. (except smallmatrix).


Now, with the common LaTeX matrix commands, omit the optional argument to get their standard behavior, or specify the additional space. In your example, writing \begin{bmatrix}[2.5ex] instead results in:

alt text

You could do that very similar using an optional argument that's temporarily set for \arraystretch. But the first method keeps the delimiters right, the \arraystretch way may leave undesired space at the top of the matrix because it's vertically stretching all rows including the first one.

I used \expandafter avoiding a recursion to add the space in brackets to the \@arraycr macro using its own definition. \g@addto@macro would do it easier but works globally. That's why some classes or packages define a local \l@addto@macro.

share|improve this answer

You might try using \\[0.5em] (or your favorite spacing) to spread out all the arrays vertically so that the rows line up horizontally. This will also relieve some of the crowding in the 3x3 array caused by your use of \displaystyle.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.