1

I find array environment pretty useful for aligning some blocks of equations, especially more flexible way of aligning each column as a whole, unlike alugn, however it has a couple of issues

  1. You have to put array inside another math environment
  2. All math like fractions, sum limits, integrals look small, because array isn't a display environment
  3. Spacing between rows is different from other amsmath environments like align. I want spacing to be exactly the same as in gather for example

Here's a comparison with align

enter image description here

The solution that I'm looking for has to take care of all listed issues above, but also keep the key feature of array: full control of columns type: l, r and especially c and all other properties like @{}, >{} <{}, vertical lines c|c , etc.

Basically I need a standalone display variant default array that has same spacing as other amsmath environments. Making each row being labeled isn't the most important thing for me, but it would be nice to have such an option.


Here's the "MWE" of desired environment and it's output

\documentclass{article}

\begin{document}

\begin{displayArray}{ *{3}{c} }
a^2+b^2=c^2 & \frac{m}{n} = q & 1+2+3+4+5=15 \\
\sum_{i=1}^n & \int_a^bf(x)dx=F(x) & k=j
\end{displayArray}

\end{document}

enter image description here

5
  • 3
    Why not just use align? By adding another & before each = sign (three on easch line, six in all), that should give the same result as your displayArray. Proper use of align is described in the user guide for amsmath -- texdoc amsldoc. May 22 at 16:48
  • @barbarabeeton How would you produce centered columns via align?
    – antshar
    May 22 at 16:51
  • 1
    I don't understand your question. align will format multiple two-part expressions (each "part" is what is separated by an &, as a&=b) separated by another & (where it will insert a space), and finally center the entire environment, except for the equation numbers. The result is very like what you've produced with your dusplayArray, but spaced a bit differently. It's what is used in publications of the American Mathematical Society, so is "publication quality" according to the guidelines of a major math publisher. May 22 at 20:42
  • You can put \displaystyle inside an array. That will fix the small fractions. You can adjust the row spacing with \arraystretch. Not much you can do about the equation numbers except use align or flalign, && and possibly \mathmakebox (mathtools). May 23 at 0:15
  • 2
    This is essentially a duplicate of the question I answered here tex.stackexchange.com/a/381402/1090 May 30 at 21:38

4 Answers 4

3
+25

This is the way align is meant to be used:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
some text
\begin{align}
\frac{a+b}{c} &= d &\quad x+y &=z \\
\frac{k}{i-j} &= n &\quad m &=n
\end{align}
some more text
\end{document}

output of example code

3
  • I want to be able to create centered columns!!! Why would I ask for display version of array environment then?
    – antshar
    May 25 at 9:12
  • The separately centered columns isn't clear from your question; if in your DisplayArray you had used the c alignment, that would have ruled out this answer. I should probably just delete it. May 25 at 16:42
  • Thank you for understanding. And sorry for not being clear enough. I edited the post to include demands more precisely.
    – antshar
    May 25 at 19:43
1

I use IEEEeqnarray a lot, so much that it's actually the only math environment I use at all. It can do a lot of stuff and is perfectly suitable for your example. I did not have to modify your MWE much to get the output you want to have:

\documentclass{article}

\usepackage{IEEEtrantools}

\begin{document}

\begin{IEEEeqnarray}{C'C'C}
a^2+b^2=c^2 & \frac{m}{n} = q & 1+2+3+4+5=15 \\
\sum_{i=1}^n & \int_a^bf(x)dx=F(x) & k=j
\end{IEEEeqnarray}

\end{document}

So the things I had to do were loading the package, changing the column specification a bit (no repetition operator is possible for IEEEeqnarray) and change the environment name of course. That's it and the output is:

latexoutput

Regarding the column specification: Default spacing between the columns is a bit different than in your example, but this can be easily changed by inserting spacing modifiers between the columns, for instance ' gives 1em of spacing between columns.

More Details

IEEEeqnarray works with column specifications and you place a & between every column, similar to a table. For simple things, align can do the same but I always find align clumsy and difficult to grasp for more complex cases. For example, I had some struggles with putting aligned text at the right of equations. IEEEeqnarray has extra column types for exactly this!

In general, IEEEeqnarray uses less abstraction from the underlying \halign than other environments, which I think is a good thing in this case. You can define your own column types as well as inter-column glue in an easy way and at least for me it's more logical where the ampersands have to go. So this is a clear recommendation to use IEEEeqnarray wherever possible :) For simple equations with aligned equal-signs, my go-to column specification is {rCl}, works like a charm.

1
  • Looks like this environment is advanced indeed and can cover most of my demands. It's interesting to find it out, thanks. Since it's not exactly the array with its columns operators, I won't accept the answer just yet, but it's the best candidate so far.
    – antshar
    May 25 at 21:49
0

You could always define new column types to set all math in display style, and wrap an array into another environment where \arraystretch is larger.

\documentclass{article}
\usepackage{amsmath}
\usepackage{array}
\newcolumntype{C}{>{\displaystyle}c}
\newcolumntype{L}{>{\displaystyle}l}
\newcolumntype{R}{>{\displaystyle}r}
\newenvironment{displayArray}[1]{%
    \let\currentstretch\arraystretch
    \renewcommand*{\arraystretch}{2}
    \[\begin{array}{#1}
}{%
    \end{array}\]
    \let\arraystretch\currentstretch
}
\begin{document}

\begin{displayArray}{LR}
\frac{a+b}{c} = d & x+y=z \\
\frac{k}{i-j} = n & m=n
\end{displayArray}

\end{document}
2
  • 1. I want to use default rcl column types. 2. How do you know that \renewcommand*{\arraystretch}{2} makes it exactly the same size as other amsmath environments?
    – antshar
    May 25 at 9:11
  • @antshar 1. Well, sorry about that. At least it doesn't change much to have to write capital letters instead. 2. Unfortunately I don't, but the picture looks pretty much like your desired output.
    – Vincent
    May 25 at 13:59
0

Here is a possible solution with tabularray package: cells = {mode=dmath} sets display math mode for all cells.

\documentclass{article}
\usepackage{tabularray}
\usepackage{amsmath}
\NewTblrEnviron{displayArray}
\SetTblrInner[displayArray]{
  cells = {mode=dmath},
  colsep = 5pt,
  rowsep = 0.5\jot,
}
\begin{document}

\section{align}

\begin{align}
a^2+b^2=c^2 && \frac{m}{n} = q && 1+2+3+4+5=15 \\
\sum_{i=1}^n && \int_a^bf(x)dx=F(x) && k=j
\end{align}

\section{displayArray}

\begin{displayArray}{ *{3}{c} }
a^2+b^2=c^2 & \frac{m}{n} = q & 1+2+3+4+5=15 \\
\sum_{i=1}^n & \int_a^bf(x)dx=F(x) & k=j
\end{displayArray}

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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