Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

\documentclass{article}
\usepackage{amsmath}
\newcommand{\ud}{\mathop{\mathrm{{}d}}\mathopen{}}

\begin{document}
\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}
\end{equation}
\end{document}

rendered code

share|improve this question
add comment

4 Answers

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
add comment

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

\begin{pmatrix}
\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
\end{pmatrix}

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

share|improve this answer
1  
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
add comment

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).

\makeatletter
\let\origenv@matrix\env@matrix
\renewcommand*{\env@matrix}[1][0pt]{%
  \expandafter\def\expandafter\@arraycr\expandafter{\@arraycr[#1]}
  \origenv@matrix}
\makeatother

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
add comment

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
add comment

Your Answer

 
discard

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.