Skip to main content

Questions tagged [matrices]

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

Filter by
Sorted by
Tagged with
72 votes
13 answers
46k views

Highlight elements in the matrix

I have a matrix and need to highlight some elements in the matrix. I have found how to highlight a single element (I want to put the cell in the square): $$ A = \begin{bmatrix} \fbox{0} & \fbox{0}...
Eugene's user avatar
  • 721
95 votes
2 answers
41k views

How to use more than 10 tab stops in bmatrix or other amsmath matrix environments?

I'm using bmatrix environment from the amsmath package, and I'm trying to do something like this: \documentclass{article} \usepackage{amsmath} \begin{document} \begin{equation} \begin{...
Martin Tapankov's user avatar
77 votes
5 answers
132k views

Label rows of a matrix by characters

How to add label to index the rows and columns of the matrix ? because I want to number the line outside the matrix \[ \begin{array}{lc} \ Mat_{\varPhi to M} & \left(\begin{array}{@...
Chouria Ali's user avatar
  • 1,303
86 votes
2 answers
23k views

"Single ampersand used with wrong catcode" error using tikz matrix in beamer

I am having trouble getting a basic example of a matrix of notes to show up in my beamer presentation. I am using the code copied from the pgf manual. Here is a complete working example. The error I ...
user avatar
32 votes
4 answers
35k views

Where is the \matrix command?

From what I can see, \matrix was a TeX command, but I cannot seem to find documentation on it. It works in MathJax, so I wonder if it can be used in LaTeX. ie this is valid MathJax: $$ \left[ \...
bobobobo's user avatar
  • 4,456
28 votes
4 answers
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} \...
Caramdir's user avatar
  • 90.2k
78 votes
10 answers
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 ...
Dan Ramras's user avatar
16 votes
3 answers
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 ...
Jason Whyte's user avatar
  • 1,408
58 votes
12 answers
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 ...
Revolucion for Monica's user avatar
52 votes
5 answers
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 -...
Larry Wang's user avatar
  • 3,575
92 votes
3 answers
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 ...
Saran Tunyasuvunakool's user avatar
112 votes
5 answers
355k views

How to add a matrix to a LaTeX document

How do we add a matrix to a LaTeX document?
Ashwin Nanjappa's user avatar
40 votes
7 answers
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? \begin{equation}\label{eq:appendrow} \newcommand\x{\times} \newcommand\y{\...
SkyWalker's user avatar
  • 1,897
18 votes
1 answer
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{...
ipavlic's user avatar
  • 8,151
16 votes
3 answers
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[\...
Mats's user avatar
  • 221
12 votes
2 answers
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: ...
Lemming's user avatar
  • 295
24 votes
6 answers
21k views

bordermatrix with blocks

I need to write a complicated matrix, that has a structure as in the attached picture.
user avatar
16 votes
4 answers
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}...
wonderich's user avatar
  • 2,447
88 votes
7 answers
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{...
Will's user avatar
  • 3,721
61 votes
9 answers
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 ...
Dror's user avatar
  • 22.8k
51 votes
5 answers
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 ...
jub0bs's user avatar
  • 59.5k
63 votes
2 answers
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{...
Günal's user avatar
  • 3,483
13 votes
4 answers
24k views

Matrix within equation

I am having some difficulty getting this to display properly. \begin{equation} {\bf H} = -{\bf \mu} \cdot {\bf B} = - \gamma B_o {\bf S}_z = -\frac{\gamma B_o\hbar}{2} \begin{bmatrix} 1&0\\0&...
Shinobii's user avatar
  • 549
41 votes
4 answers
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 ...
amonakov's user avatar
  • 1,022
20 votes
4 answers
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 ...
Martin H's user avatar
  • 18.3k
19 votes
6 answers
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 ...
Martin Lauridsen's user avatar
15 votes
2 answers
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{...
Ichibann's user avatar
  • 8,471
8 votes
3 answers
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}...
MYaseen208's user avatar
  • 8,631
47 votes
2 answers
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 ...
ipavlic's user avatar
  • 8,151
43 votes
8 answers
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{\...
caustic's user avatar
  • 1,087
29 votes
8 answers
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.
kkudi's user avatar
  • 545
11 votes
4 answers
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 &...
rima101's user avatar
  • 193
10 votes
3 answers
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 ...
Saed's user avatar
  • 203
22 votes
4 answers
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:
Noam Ross's user avatar
  • 323
10 votes
3 answers
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} . . . \[ \...
Paulo H's user avatar
  • 439
0 votes
1 answer
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 ...
mvfs314's user avatar
  • 543
40 votes
2 answers
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 ...
SimonBS's user avatar
  • 503
31 votes
5 answers
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 \\ ...
ZulfiqarIII's user avatar
26 votes
4 answers
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?
jtbandes's user avatar
  • 4,272
14 votes
1 answer
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{equation} \begin{bmatrix} N & B_i \\ B_i^T &...
SLN's user avatar
  • 715
14 votes
2 answers
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 ...
JPi's user avatar
  • 13.7k
12 votes
5 answers
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 ...
Niel de Beaudrap's user avatar
9 votes
3 answers
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 ...
vito's user avatar
  • 193
6 votes
3 answers
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.
Memming's user avatar
  • 1,147
2 votes
3 answers
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 ...
KevinB's user avatar
  • 291
28 votes
3 answers
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?
zellyn's user avatar
  • 383
27 votes
2 answers
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 ...
Karlr's user avatar
  • 273
23 votes
7 answers
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 ...
rogerl's user avatar
  • 3,683
23 votes
3 answers
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. \...
I Like to Code's user avatar
17 votes
4 answers
16k views

Typesetting a Row Vector

In the question typesetting a column vector, a very nice solution was given for typesetting a column vector with an arbitrary number of rows. I am attempting to modify the code to produce row vectors ...
3Sphere's user avatar
  • 3,701

1
2 3 4 5
8