# Questions tagged [matrices]

{matrices} is about matrices in {equations} and {diagrams}.

399 questions
Filter by
Sorted by
Tagged with
46k views

• 4,456
4k views

### Problem with defining shortcuts for TikZ matrices

For answering a question yesterday I wanted to define a shortcut for creating a matrix inside a tikzpicture. As a minimal example, consider \newcommand\mymatrix[1]{ \begin{tikzpicture} \...
• 90.2k
118k views

### What's the best way make an "augmented" coefficient matrix?

When studying systems of linear equations, it's nice to remind people that the last column of the coefficient matrix holds the constants. This is often done in books by putting a vertical line ...
• 935
7k views

### use of tikzpicture matrix in align or gather environment

So far I have found using the matrix command in the TikZ package is the only way of drawing a T-shape around the bottom row and middle column of entries in a matrix. I now need to use this matrix in ...
• 1,408
23k views

### Is there a way to automatically transpose a matrix written in Latex?

As writing matrices in LaTeX is an extremely time-consuming activity, I was wondering if a software or a site exists that automatically gave the transposed form of a matrix, that is to say, given a ...
20k views

### How do I label different rows or columns of a matrix using braces?

I have a matrix enclosed in brackets [ ] (or (), or {}, or |'s, or ||'s): - a b c d - | e f g h | | i j k l | - m n o p - which I want to label like so: R |---| -- - a b c d -...
• 3,575
104k views

### How can I increase the line spacing in a matrix?

I'm trying to create a pmatrix whose components are rather complicated fractions (Christoffel symbols), and the line spacing is too small making the whole thing a bit cramped and hard to read. Is ...
355k views

### How to add a matrix to a LaTeX document

How do we add a matrix to a LaTeX document?
• 2,540
37k views

### Matrix change row or column background

I have a matrix shown below. I would like to have the whole row green rather than only the cells. How can I do that? \label{eq:appendrow} \newcommand\x{\times} \newcommand\y{\...
• 1,897
3k views

### Foreach inside a TikZ matrix

Consider this MWE: \documentclass{article} \usepackage{tikz} \usetikzlibrary{matrix} \begin{document} \begin{tikzpicture} \matrix [matrix of nodes] { a \\ b \\ c \\ }; \end{tikzpicture} \end{...
• 8,151
9k 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 \end{array}\right],N=\left[\...
• 221
3k views

### Tikz foreach inside matrix

Apparently this question has been asked a hundred times already. But I couldn't get it to work with any of the answers provided. I want to have nested for loops inside a Tikz matrix. Something like: ...
• 295
21k views

### bordermatrix with blocks

I need to write a complicated matrix, that has a structure as in the attached picture.
16k 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: \usepackage{tabularx}...
• 2,447
134k views

### How do I left-align entries in a matrix with \begin{matrix}?

I'd like to left align the -1 entry in the following matrix so that the 1s line up. Is there a way to get matrices to ignore signs in that way? \begin{matrix} 1 & 1 \\ 1 & -1 \\ \end{...
• 3,721
250k views

### typesetting column vector

I would like to define a command which typesets a column vector. For one vector I can have something like: \left( \begin{array}{c} a\\ b\\ \end{array} \right) I would like the command to produce ...
• 22.8k
11k views

### Perform matrix operations (addition, product, transpose, etc.) in LaTeX?

I know the calc package can perform infix-notation arithmetic in LaTeX... but I want more! I'd like to perform (not necessarily infix-notation) linear-algebra operations such as scalar ...
• 59.5k
48k views

### How to create a matrix with 20 columns in latex

The code below works, but when I add 10 more columns, it does not. So, how can I add ten more columns to the matrix below? \documentclass{article} \usepackage{amsmath} \begin{document} \begin{...
• 3,483
24k views

### Matrix within equation

I am having some difficulty getting this to display properly. {\bf H} = -{\bf \mu} \cdot {\bf B} = - \gamma B_o {\bf S}_z = -\frac{\gamma B_o\hbar}{2} \begin{bmatrix} 1&0\\0&...
• 549
14k views

### Multirow/multicolumn cells in TikZ matrices?

Is it possible to make TikZ matrix cells span multiple rows/columns, like they can in LaTeX tables using \multirow or \multicolumn? Specifically, I'd like to typeset something like the following in a ...
• 1,022
9k views

### Horizontal row separation line in tikz matrix (like \hline in tabular)

In this question tikz-matrix-as-a-replacement-for-tabular a nice solution was given to let the matrix in tikz behave like tabular. In this solution cell/.style={rectangle} was used to draw lines ...
• 18.3k
4k views

### Drawing a large binary matrix as colored grid in TikZ

I have a pretty big binary matrix of maybe 70 rows and 64 columns. For ease of viewing, I would like to draw this matrix in TikZ where e.g. a 1 is represtented by a red square and a 0 is a white ...
5k views

### Broken matrix - gaps in brackets

This is my minimal working example. \documentclass[12pt,a4paper]{mwrep} %\usepackage{amsfonts} \usepackage{amsmath} %\renewcommand\baselinestretch{1.5} \begin{document} \chapter{Example} \begin{...
• 8,471
4k views

### How to Specify two level row and column labels of a matrix by braces?

I'm trying to write the following matrices. I used the following code (given by Caramdir) \documentclass{article} % Load TikZ \usepackage{tikz} \usetikzlibrary{matrix,decorations.pathreplacing,calc}...
• 8,631
31k views

### TikZ matrix as a replacement for tabular

I would like to use TikZ matrices to for some drawings. I am currently using nodes and positioning them manually to simulate a tabular. That helps in positioning arrows and shading. However, if I use ...
• 8,151
19k 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} \\ \dfrac{\...
• 1,087
71k views

### How to construct a confusion matrix in LaTeX?

A confusion matrix looks like: Is there an easy way to do the same using LaTeX? Otherwise I could just create a diagram with any software.
• 545
13k views

### braces over matrix

I want to make an overbrace and a side brace on my matrix in order to indicate its size. How can I achieve that. \begin{pmatrix} 1 & 1 & 0 & .& . & . & 0 & 1 \\ 0 &...
• 193
8k views

### Add Overbrace to describe a column of matrix

I want to add some over-braces to a matrix to get the following output: However, this this what I managed to get: I don't know how to get the neuron 1 and neuron 2 headings...I was thinking of ...
• 203
3k views

### Matrix with labels nested in braces

What's the best way to produce a matrix with labels that are nested in braces, like this:
• 323
7k views

### Underbraces in Matrix Divided in Blocks

How to put underbraces, inside the parenthesis of a matrix, to name both sides of the blocks? \documentclass[a4paper,12pt]{article} \usepackage{amsmath} \usepackage{array} \begin{document} . . . \[ \...
• 439
2k views

### Compilation problem with tikz diagram

As I said, I'm writing math books for school; one of them is about matrices and I have several problems with it. It's a big code, so I'm trying to summarize it: Problem with TikZ matrix: When I try ...
• 543
163k views

### Vertical line in matrix using LaTeXiT [duplicate]

Possible Duplicate: What's the best way make an “augmented” coefficient matrix? I am trying to make a vertical line in a matrix in LaTeXiT. I have read that it should be possible ...
• 503
74k views

### Diagonal dots spanning multiple lines/columns of a matrix

I'm filling in large sparse matrices, for example \begin{bmatrix} 0 & -2 & 1 & & -1 & 2 \\ 2 & \ddots & \ddots & \ddots & & -1 \\ ...
• 413
10k views

### Draw a line through one column of a matrix

I'd like to "cancel" (draw a line through) a column of a matrix (using \begin{pmatrix}..\end{pmatrix}). How can I do this?
• 4,272
33k views

### How to add dash lines in Matrix [duplicate]

I would like to know how to add dash lines in Matrix (see figuge) Cheers S.L. \documentclass{article} \usepackage{amsmath} \begin{document} \begin{bmatrix} N & B_i \\ B_i^T &...
• 715
10k views

### How to force nodes to have the same size in tikz matrices

Is there some intelligent way to have several tikz nodes have the same height and width? Consider the following example with output below. I'd like every node in each row to have the same height ...
• 13.7k
2k views

### Obstacles to simulating an amsmath matrix by a TiKZ matrix of math nodes

I'm trying to figure out a TiKZ-based solution to this problem involving arrows between matrix rows. To this end, I would like to at least be able to make a matrix of math nodes simulate the behaviour ...
• 14.5k
7k views

### braces on the sides of an easybmat matrix

I created the following matrix with easybmat, and I would like to add at the bottom (respectively right) something like an underbrace (resp. "rightbrace") under each of the two blocks, together with a ...
• 193
2k views

### Matrix decomposition dimensions diagram

What's the easiest way of making diagrams depicting matrix dimensions such as the following? I can do it with simple subscripts, but I like the visual effect that these diagrams give.
• 1,147
908 views

### Shrinking or splitting some equations in a group of equations

I have a group of equations, such as /begin{gather} Eq1 // Eq2 // Eq3 // Eq4 /end{gather} Unfortunately, some of the equations in the group are too long to fit on the page. For equations that are ...
• 291
24k views

### How do I typeset vertical and horizontal lines inside a matrix?

(From the notation used in course notes for Stanford CS229 available online.) I'm trying to typeset the following matrices made up of row or column vectors: Any ideas?
• 383
25k views

### Matrix in a matrix

I would like to draw a matrix with top left, top right, bottom left and bottom right blocks. The top left should be a 3x3 matrix with numerical entries, the top right is 0, the bottom left is 0 and ...
• 273
17k views

### Formatting arrows between rows of corresponding matrices

Some material I'm creating requires output that looks like this: (note the position of the arrows). I'm using the following code (with the AMS macros) to generate this, and I'm looking for ...
• 3,683
23k views

### Underbrace in a matrix

I want to display the structure of a matrix as shown in the image below: Can this be done using pmatrix and \underbrace? My attempt at combining pmatrix and \underbrace results in a compile error. \...
• 6,372