{array} is an environment used in {math-mode}. It can be useful when aligning terms.

learn more… | top users | synonyms

31
votes
3answers
1k views

Programming Conway's Game of Life in LaTeX

My aim is to program Conway's Game of Life in LaTeX, and make the output into an animated PDF. I intend to use PGF/TikZ for this, especially pgfmath, but I'm stuck at the moment because I need to ...
28
votes
4answers
4k views

Using display style fraction in a matrix environment

I'd like use the \dfrac command in a bmatrix environment as follows: \documentclass{article} \usepackage{amsmath} \begin{document} \[ \begin{bmatrix} \dfrac{\partial f}{\partial x} \\ ...
22
votes
1answer
306 views

Does \\ in the last line of an array have any effect?

Consider the following example: \begin{array}{l} line 1 \\ line 2 \\ \end{array} Is the \\ in the last line completely optional or are there circumstances under which it has any effect?
20
votes
3answers
2k views

How do I create a Shidoku grid?

I can't figure out how to create a Shidoku grid using LaTeX. In other words, I am trying to have a 4x4 grid with a bold line separating the 2x2 subsquares. I have the sudoku package but it won't ...
19
votes
4answers
1k views

How can I display an array (as in the data structure from Computer Science, not the mathematical version) in LaTeX?

I'm finding this extraordinarily difficult to search for, as the mathematical meaning of "array" is much more common in LaTeX documentation. I essentially want a single row of boxes, into which I can ...
17
votes
5answers
9k views

bordermatrix with blocks

I need to write a complicated matrix, that has a structure as in the attached picture.
14
votes
3answers
669 views

How to find the length of a PGF array?

A few of my macros currently require the user to pass the length of an array along with the array itself. It would be nice if the length could be calculated for them, as the user in question (myself) ...
14
votes
1answer
2k views

Multivariate polynomial long division using LaTeX

How do I typeset polynomial long division using multiple variables in LaTeX? I am hoping to be able to do polynomial long division using 2 or more divisors. Currently, the packages I am using are: ...
13
votes
5answers
4k views

Create an array of variables

I'm creating a package for my question papers. (I'm aware of the exam class but I don't want to use that.) I have everything ready but I want to create a grading table at the top of the first page. ...
13
votes
1answer
4k views

A Matrix with labels, dashed lines

I'm trying to TeX the following matrix, from Guillemin and Pollack (1.4 #13) The best I've been able to do is get the dashed lines with \[ \left( \begin{array}{c:c} B & C \\ \hdashline D ...
12
votes
4answers
3k views

PGF/TikZ: How to store strings in array?

I'm trying to generate a lot of name badges. I'm wondering, is it possible to store the names as strings in one array, according to the PGF manual: ...
12
votes
2answers
773 views

Array cell highlighting tikz

I'm beginning to write up a PhD thesis and am pretty new to LaTeX. I'm trying to explain a numerical method I'm using and in doing this I wish to highlight sections of arrays to aid explanation. The ...
12
votes
2answers
2k views

Array with labeling columns

Is there an intelligent way to label (or name) columns in a matrix? I would like to have something like \[M=\left[\begin{array}{c|cc} 1 & 2 & 3\\ 4 & 5 & 6 ...
11
votes
4answers
456 views

How to construct a logic argument with colored hline with length under control?

How to construct a logic argument like this one? I can construct it like this: Latex of my argument: \documentclass[10pt]{article} \usepackage{newtxtext} \usepackage{newtxmath} ...
11
votes
3answers
2k views

Using \underbrace with table columns

I have the following code: \begin{displaymath} \begin{array}{|c|c|c|c} p & q & p\lor{}q & p\land{}q \\ \hline 0 & 0 & 0 & 0 \\ 0 & 1 & 1 & 0 \\ 1 & 0 ...
11
votes
2answers
791 views

Problems with alignment of sequences

I want to align two sequences: a_1, b_1, c_1, d_1, e_1 etc. a_2, b_2, c_2, d_2, e_2 etc. here's what I wrote \begin{align} \notag &a_1,\ &b_1,\ &c_1,\ &d_1,\ &e_1\ ...
10
votes
3answers
4k views

Convert numpy array into tabular

I am doing some data analysis in python, putting the results in form of a matrix stored into a numpy array. I would like to put this results into a report and the best way would be to put a table with ...
10
votes
3answers
636 views

How to create vertical and horizontal dotted lines in a matrix?

Similar to this question, I am trying to output a similar matrix with dotted line instead of dashed line. Is there anyway to do this? I also try to use these three packages: ...
10
votes
3answers
107 views

Array padding not right

I have the following array environment: \begin{array}{ccc} 0 & = & \text{some equation} \\ 0 & = & \text{some other equation} \\ & \vdots \\ 0 & = & \text{last equation} ...
10
votes
2answers
303 views

Selective alignment tabs in tabular/array?

For a while now I've been thinking about an array/tabular feature that would be quite nice to have. It doesn't seem to exist yet, as far as I can discover. And unfortunately, I can't spare the time ...
10
votes
3answers
2k views

Border matrix with multiple indices on top and bottom

How can I write a matrix where there is an index at the top and also at the bottom? \bordermatrix doesn't seem to have an option for multiple indices.
10
votes
2answers
2k views

Gaussian reduction of matrices

I have to show a Gaussian reduction in an assignment, and I was wondering what the more space-efficient and neatest way of expressing this is. I thought about using \begin{smallmatrix} (it's only a ...
10
votes
1answer
3k views

Negative Sign and Matrix Alignment

I am having trouble centering the elements of a matrix such that the negative sign is not taken into account during alignment. Additionally, I would also like the space between the left parenthesis ...
9
votes
3answers
2k views

Problems using `\left\{` in array environment

I am trying to define a matrix in segments by enclosing the entries of the matrix in boxes, and also using the open and closed braces to label those segments. So far I have developed the following ...
9
votes
4answers
2k views

Text above matrices

I am new to latex and I am trying to create So far I have been able to create the matrices, like so: \[ N\textrm{ spectra} \begin{bmatrix} a_{11} & a_{12} & \cdots & a_{1M} \\ ...
9
votes
4answers
153 views

Restore the original array code

The arraypackage redefines array in various ways. I was woundering if anyone had made a package containing a localized (prefixed) version of the kernel array? I have a document were we have a simple ...
9
votes
1answer
137 views

Matrix looks flat

I would like to typeset a partitioned matrix in LaTeX with dashed lines. After a quick search on TeX.SE, I found this post with a nice example of such matrices. I tried it on my computer and the ...
9
votes
1answer
136 views

Using an array environment inside an xparse command

I would like to define a macro for optimization problems. My attempt is given below. I am wondering why \optimizationproblema works, but \optimizationproblemb does not (I get a "misplaced alignment ...
9
votes
1answer
268 views

What is best practice for aligning distinct arrays or tables side-by-side?

I have two related tables that could naturally be displayed side-by-side but don't have to be. However, it saves space to display them side-by-side rather than one atop the other. If I do so without ...
8
votes
3answers
265 views

Vertically Centering Text/Numbers in Rows of Array using Math Mode

I am trying to center text in an array of two rows inside a math mode environment so that the text in the second column of the array appears half way between the first and second row of the first ...
8
votes
3answers
2k views

Page with Symbols and Notation

I want to make a section for symbols and special notation, which should look like this: What would you suggest in doing this? Should I just do like a table and create an array of 3 columns?
8
votes
3answers
11k views

Adjusting space between array rows and columns

\documentclass[english]{article} \usepackage[T1]{fontenc} \usepackage[latin9]{inputenc} \usepackage{babel} \begin{document} % ... \[ \begin{array}{ccccc} x(1) & = & \frac{x(0)}{1} & = ...
8
votes
3answers
2k views

How to align piecewise functions?

I have two piecewise functions defined like this: \begin{align*} \left\{ \begin{array}{ll} i = x^2 + y^2 \\ j = a^2 + b^2 \\ \end{array} \right. \\ \left\{ ...
8
votes
1answer
4k views

Systems of equations with a single number

I want to write a numbered system of equations. Right now, this is what I do and I am satisfied with the output, but I have a feeling it's not the best way to do it. \begin{equation} ...
8
votes
2answers
395 views

Pretty lists for sorting algorithms

I would like to obtain easily something like in this picture so as to illustrate several sorting algorithms. To produce one line, I would like to use one command of the following kind where the ...
8
votes
3answers
565 views

array within frac, using nath package

I use the nath package to get automatically-sized delimiters, but it breaks having a \begin{array}{…}…\end{array} within a \frac{}{} (simply removing the \usepackage{nath} below fixes the example, but ...
8
votes
1answer
3k views

Add more horizontal space in an array

Is there a setting I can input to the array environment, which will slightly increase the horizontal spacing between each entry? I would appreciate it if you could test your code on the following ...
8
votes
2answers
735 views

Enforcing That \array Stays Square When Drawing Matrix

I'm trying to draw a block matrix in LaTeX, and this is what I have so far: \begin{array}{|c|c|} \hline I_{r \times r} & 0 \\ \hline 0 & 0 \\ \hline \end{array} Here's a ...
8
votes
1answer
266 views

Replacing Leading Minus Signs in Environment

In this question concerning negative signs and the alignment of entries in matrix environments, Heiko Oberdiek gave a great answer in which he uses a user-defined command called \matminus instead of ...
7
votes
2answers
434 views

cases environment inside an array

LyX is giving a lot of error messages for my Latex code which runs in other places. \[ \begin{array}{rl} p_{Y \mid H_1}(y \mid H_1) & = f_X(g^{-1}(y))\left| \dfrac{dg^{-1}(y)}{dy} \right| \\ \\ ...
7
votes
4answers
528 views

What is the best way to indicate repeated off diagonal elements in a matrix/array?

I'd like to typeset a matrix of the following kind: When the symbols involved are big, like, in place of $r$, suppose we had $\mu(k-1)$ and in place of $\lambda$, we had $\mu(k-2)$, the matrix B below ...
7
votes
3answers
2k views

Drawing Multiple Diagonal Arrows in a Table

My question is basically the same as this one, but with many arrows instead. (I'd like to see the TikZ solution--I feel like once I get it here, I'll be able to extrapolate and do it in other cases ...
7
votes
3answers
5k views

aligned environment of amsmath vs array environment

Today I found out the existence of the aligned environment of the amsmath package. However, I can't see the advantage of using it instead of the array environment from the example provided in ...
7
votes
4answers
3k views

How to align a system of multiline equations?

I've got a system of equations, each of them doesn't fit the page width, so I'm searching the way to align them so that: the brace should appear to the left with no indentation the first line of ...
7
votes
2answers
290 views

Is it blkarray compatible with beamer?

When I try next code \documentclass{beamer} \usepackage[utf8]{inputenc} \usepackage{blkarray} \begin{document} \begin{frame}{Title} \[ \begin{blockarray}{c|c} ...
7
votes
2answers
270 views

How to stop fractions in display equations from running into each other?

Is there some standard way to create multiple display equations like the following without having to use: \renewcommand*{\arraystretch}{2} (so that the two rows in the second equation don't get ...
7
votes
4answers
163 views

Draw a vertical line over the entries of a column in an array

I'd like to draw vertical/horizontal lines over the entries of a column/row in an array. I find the method to draw horizontal lines at Draw a horizonal line over the entries of a row in an array. But ...
7
votes
3answers
149 views

Vertically Centering Math and Text in Array?

One problem I've always had is trying to make text and/or math text vertically centered in either the tabular or array environments. Take this for example: \documentclass{article} ...
7
votes
3answers
297 views

How can I determine the size of an array?

After a long search period, I was not able to figure out how to determine and use the len of an array like this: \def\mar{ 1,2 } \path let \p1=($(rec.west)-(rec.east)$), ...
7
votes
1answer
2k views

Make every element of an array displaystyle?

Is there a way to make every element of an array be \displaystyle? I don't want to do something like \everymath={\displaystyle} (or whatever it should be) because I want this for a particular array ...