New answers tagged

0

Here is an example: draw the matrix in a pic, and then set the value by some key value to be changed. The benifit is that you can access the coordinate of the matrix as usual. \documentclass{article} \usepackage{tikz} \usetikzlibrary{matrix,shapes,arrows,fit,automata,positioning} \usepackage{adjustbox} \tikzset{ value to be changed/.store in=\anytl, ...


1

You can perform operations on the entries of the matrix, with may depend on the counts \pgfmatrixcurrentrow and \pgfmatrixcurrentcolumn. The matrix content are stored in \myarray. If you just say \mymatrix you will get the corresponding matrix, but if you say e.g. \mymatrix[\ifnum\pgfmatrixcurrentcolumn=2 \pgfmathparse{int(\pgfmatrixcurrentrow+\...


4

Below I define gaussmat as a matrix-like construction/environment that sets a 3 x 3 Gaussian elimination matrix. The column entries are all the same, capturing its argument and passing it on to a measurement scheme from eqparbox. This finds the widest length of the column entries, thereby creating a uniform look across all columns. An optional argument to ...


3

The tool of choice for vertical padding in tabular is cellspace, which defines a minimal padding in cells of columns with specifier prefixed with the letter S (or C if you load siunitx, which defines an S column type). I also propose a different layout, with only horizontal rules from booktabs, and the use of the measuredfigure environment from ...


10

The package nicematrix can compute for you the width of the widest entry of all the matrices in a portion of your document and give that width to all the columns. For that, you have to use the environment {NiceMatrixBlock} with the key auto-columns-width. You need several compilations. \documentclass{article} \usepackage{nicematrix} \begin{document} ...


3

The key parallelize-diags is available only in \NiceMatrixOptions (the scope of such a setting is the current TeX group). Moreover, there is in your code two redundant commands \Ddots. \documentclass{article} \usepackage{nicematrix} \begin{document} \NiceMatrixOptions{parallelize-diags=false} \begin{equation*} A_c+B_c K_c=\begin{bNiceMatrix} 0 ...


6

nicematrix allows you to set the column width. \documentclass{article} \usepackage{nicematrix} \begin{document} First, we write this system using matrices. \[ \begin{bNiceArray}[columns-width = 2em]{RRR|R} 1 & 2 & 3 & 4\\ 7 & 5 & 3 & 1\\ -2 & -3 & -4 & -5\\ \end{bNiceArray} \] We preform $\mathbf{R_{2}} \rightarrow \...


3

Welcome to the TeX.SE. You can use \renewcommand{\arraystretch}{1.4} into the code near to tabular. \documentclass[a4paper,12pt]{article} \usepackage{amsmath,amssymb} \begin{document} \begin{figure}[h!] \centering {\renewcommand{\arraystretch}{1.4}\begin{tabular}{|c|c|c|c|} \hline \text{sign of} c & f & i & \text{...


4

You could just insert some horizontal space. \documentclass[12pt]{article} \usepackage{float} \usepackage[margin=1in]{geometry} \usepackage{amsmath} \usepackage{mathtools} \usepackage{gauss} \begin{document} \begin{align*} T\left(s, a_1, s^\prime\right) &= \begin{bmatrix} 0 & 0.5 & 0.5 & 0 & 0\\ ...


2

I'd simply use a single column array (and avoid pure colors): \documentclass{article} \usepackage{amsmath} \usepackage{xcolor} \newcommand{\redtt}[1]{\textcolor{red!90!blue}{\mathtt{#1}}} \begin{document} \[ \left[\begin{array}{@{}ccc|c@{}} 1 & 0 & 0 & \redtt{b1} \\ 0 & 1 & 1 & \redtt{b2} \\ 0 & 0 & 1 & \redtt{...


6

Please consider posting complete examples such that others do not have to reverse engineer commands like \redtt. As for your question, you can use aligned or an array. \documentclass{article} \usepackage{amsmath} \usepackage{array} \usepackage{xcolor} \newcommand{\redtt}[1]{\textcolor{red}{\mathtt{#1}}} \begin{document} \begin{align*} \left[\begin{array}...


1

Let mi convert my comment to an answer: the case when images have the same heights \documentclass{article} \usepackage{mathtools} \usepackage[font=small]{caption, subcaption} \usepackage[demo]{graphicx} \begin{document} \begin{figure}[htb!] \centering \begin{subfigure}[t]{0.45\textwidth} \centering \includegraphics[width=\textwidth]...


1

\documentclass{beamer} \usepackage{amsmath} \begin{document} \begin{frame} \[ \begin{pmatrix} 1 & 0 & \cdots{} & 0 & c_{1,r+1} & \cdots{} & c_{1n}\\ 0 & 1 & \cdots{} & 0 & c_{2,r+1} & \cdots{} & c_{2n}\\ \vdots{} & \vdots{} & & \vdots{} & \vdots{} & & \vdots{}\\ 0 & 0 & ...


1

You want to insert to the item of the outer table (\halign) the nested table (\haling). It is not problem if the nested \halign is realized as a macro which reads its parameter in {...}. Then such parameter can include tabs & and \cr used for its inner nested \halign. But if you want to use a macro with separated parameter and not in {...} then the tabs &...


2

There is no problem. You create a matrix 4×4 and you put your coefficients at the right place: \documentclass{article} \usepackage{array} \usepackage{amsmath} \begin{document} \begin{align} G^\mu{}_\nu &= \frac{\partial x ' {}^\mu}{\partial x^\nu} \\ \notag &= \left( \begin{array}{c|ccc} \frac{\partial x ' {}^0}{\partial x^0} & & \frac{...


3

You can use nicematrix which constructs the matrix while creating Tikz nodes. You can use these nodes to draw what you want with Tikz. \documentclass{article} \usepackage{nicematrix,tikz} \NewDocumentEnvironment {crossmatrix} { } { \begin{pNiceArray}{CC}[margin] } { \CodeAfter \tikz \draw (row-2-|col-1) -- (row-2-|col-3) (row-1-...


1

The problem is the syntax. Here I propose to specify the parts as arguments to the environment. \documentclass{article} \usepackage{amsmath} \newenvironment{crossmatrix}[3] { \left( \def\crossmatrixfinal{&#1\\\hline#2&#3} \begin{array}{@{}c|c@{}} \begin{matrix} } { \end{matrix} \crossmatrixfinal \end{array} \right) } \begin{...


0

\documentclass{article} \usepackage{amsmath} \usepackage[pdftex]{graphicx} \usepackage{tikz} \usepackage[utf8]{inputenc} \begin{document} \begin{tabular}{c c} $ \gamma^0 =$ &{$\left[ \begin{tabular}{p{0.75cm}p{0.75cm}} 0 & $ \sigma _{2} $\\[1em] $ \sigma _{2}$ & 0 \end{tabular}\right]$} \end{tabular}\\...


2

A nicematrix attempt: Wrap the aligned environment inside NiceMatrixBlock, and use option auto-columns-width. Use bNiceMatrix instead of bmatrix environment, and use options R to align every cell to the right. Note that the option auto-colums-width uses equal width for every column, hence the result may be a bit too wide for some column without \...


4

If you prefer the centered alignment, the tabstackengine package allows the fixing of all column widths to the widest in the matrix. This way, you only need to pad a single element of the narrower matrix to bring them to a common width: \documentclass{article} \usepackage{amsmath,tabstackengine} \setstacktabbedgap{10pt} \begin{document} \[ \...


4

I suggest you (a) load the mathtools package, (b) use {bmatrix*}[r] environments instead of bmatrix environments, and (c) use one \phantom{-} instruction each in columns 2 and 3 of the third matrix, to equalize the widths of these columns with the columns of the matrix that hovers above it. \documentclass{article} \usepackage{mathtools} % for 'bmatrix*' env....


1

I guess that you changed your setting of line spacing. \documentclass{article} \usepackage{amsmath,arydshln} \usepackage{setspace} \newcommand{\vn}[1]{#1} \begin{document} \begin{equation} \vn{M}= \left( \begin{array}{c:cc:c} \vn{\tilde{M}} & & & \vn{L}_{AB} \\ \hdashline & \vn{M}^{c}_{B} & \vn{M}^{cb}_{B} & \\ & \vn{M}^{...


0

\documentclass{article} \usepackage{amsmath} \begin{document} \Large \begin{tabular}{ccc} {\begin{tabular}{c} $\left[ \begin{tabular}{r} $ y_{11}$\\ $ y_{12}$\\ $ y_{13}$\\ $ y_{14}$\\ $y_{21}$\\ $y_{22}$\\ $y_{23}$\\ $y_{31}$\\ $ y_{32}$\\ $y_{33}$ \end{tabular}\right]$\\...


1

\documentclass{article} \begin{document} \begin{tabular}{cccc} $ A = \left[ \begin{tabular}{rr} 1 & 0 \\ 0 & $\sqrt{2}$ \\ 0 & $\sqrt{2}$ \\ \end{tabular} \right]$ & $\left[ \begin{tabular}{rrr} 1 & 0 & 0 \\ 0 & $\sqrt{2}$ & $\sqrt{2}$ \\ \end{tabular}\right]$ & $\left[ \...


0

\documentclass[a4paper,12pt]{article} \usepackage[utf8]{inputenc} \usepackage{amsmath} \begin{document} % % You can use tablar envronment with flexibility % For proper orientation of negative numbers better use r in tabular % environment \[ \left[ \begin{tabular}{rrr} 1 & -9 & 3 \\ 1 & 2 & -2 \\ -2 ...


3

My proposal. I prefer brackets for the matrices, because parentheses are already overused. The trick is to nest matrices and to add a small vertical space between the two rows. \documentclass{article} \usepackage{amsmath} \begin{document} \[ \exp(tA_j)=\begin{bmatrix} \exp\left( t \begin{bmatrix} 1 & 1 & 0 \\ 0 & 1 & 1 \\ 0 & 0 &...


4

\documentclass[12pt,a4paper]{article} \usepackage{amsmath} \renewcommand{\rmdefault}{ptm} \usepackage[lite]{mtpro2} \begin{document} \[ \exp(tA_J) = \begin{pmatrix} \exp\begin{pmatrix}t\begin{pmatrix}1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1\\ \end{pmatrix}\end{pmatrix} & \begin{matrix}0\\0\\0\end{matrix}\\[1.5em] \begin{matrix}0&...


6

I have just chose the way to recreate your picture with the clone of Times New Roman. \documentclass[a4paper,12pt]{article} \usepackage{mathtools} \usepackage{newtxtext,newtxmath} \begin{document} \[\exp(At_y)=\begin{pmatrix} \exp(t \begin{pmatrix} 1 & 1 & 0\\ 0 & 1 & 0\\ 0 & 0 & 1 \end{pmatrix}) & \begin{matrix} 0 \\ 0 \\ 0 \...


4

One possibility is to use nicematrix. \documentclass{article} \usepackage{newtxmath} \usepackage{nicematrix} \usepackage{mleftright} \mleftright \begin{document} \[\exp(t A_J)= \begin{pNiceArray}{CCCC}[margin] \Block{3-3}{\exp\left(t\, \begin{pmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1\\ \end{pmatrix} \right)} & & &...


0

It's possible to do that with nicematrix. This package creates a PGF/Tikz node under each cell of the array. Then, it's possible to use tikz to draw what we want. \documentclass[svgnames]{article} \usepackage{nicematrix} \usepackage{tikz} \begin{document} $\begin{bNiceMatrix}[margin] 0 & 2 & 1 \\ 3 & -1 & 2 \\ 4 & 0 & 1 \...


5

It has been already remarked that you can use nicematrix. However, a particularly nice aspect of nicematrix is that it introduces the counters jCol and iRow that can be used to avoid a lot of repetition. That is, you can use code-for-first-row = \Circled{\scriptstyle\mathbf{\number\value{jCol}}}, code-for-first-col = \Circled{\scriptstyle\mathbf{\number\...


4

You can use nicematrix. \documentclass{article} \usepackage[T1]{fontenc} \usepackage{amsmath,amssymb} \usepackage{nicematrix} \usepackage{pifont} \newcommand{\cdigit}[1]{\text{\ding{\numexpr171+#1}}} \begin{document} \[ \begin{pNiceMatrix}[first-row,first-col] & \cdigit{1} & \cdigit{2} & \cdigit{3} & \cdigit{4} & \cdigit{5} \\ \cdigit{...


2

Yes, using the blkarray package works fine. \documentclass{article} \usepackage[T1]{fontenc} \usepackage{amsmath,amssymb,amsfonts} \usepackage{pifont} \usepackage{blkarray} \begin{document} \begin{blockarray}{cccccc} & \ding{172} & \ding{173} & \ding{174} & \ding{175} & \ding{176}\\ \begin{block}{c(ccccc)} \ding{172} & 0 & 1 &...


1

I corrected the problem with this code: \renewcommand{\arraystretch}{1.4} %interlineado de las tablas


1

I believe I've found an alternative to pgffor that is simpler than the solutions given so far. It uses \forcsvlist from etoolbox, which appears not to suffer from the grouping problem in pgffor. \documentclass{minimal} \usepackage{amsmath} \usepackage{etoolbox} \newcommand*{\textmatrixline}[1]{\text{#1}\\} \newcommand*{\bigsqbr}[1]{% \(% \begin{...


2

I also added amsmath package but that didn't seem to help. What could be the problem? The instruction \usepackage{amsmath, xparse} has to earlier in the preamble. It should be executed immediately after \usepackage{booktabs} at the latest. Why? Because the preamble then redefines the macro \env@matrix and the environment bmatrix. Both are defined in the ...


0

The problem are the &; you can solve it by bracing the entries, but there's a possibly better way: \documentclass[letterpaper,12pt]{exam} \usepackage{amsmath} \usepackage{xparse} \ExplSyntaxOn \NewDocumentCommand{\docases}{mm} { \int_case:nn { #1 } { #2 } } \ExplSyntaxOff \begin{document} \newcommand{\caseexam}{1} We are interested in the ...


1

This way: \makeatletter \renewcommand*\env@matrix[1][*\c@MaxMatrixCols r]{% \hskip -\arraycolsep \let\@ifnextchar\new@ifnextchar \array{#1} } \makeatother All the columns will be of type r by default but we can still specify the preamble (eg. ccc).


5

If you put braces, it works. \documentclass[letterpaper,12pt]{article} \usepackage{amsmath} \usepackage{amsfonts} \usepackage{graphicx} \begin{document} We are interested in the following matrix: \begin{gather*} \ifcase 0 \relax { C = \begin{pmatrix} 1 & 2 \\ 1 & -2 \end{pmatrix} } \or { C = \begin{pmatrix} 3 & 4 \\ 1 &...


2

You can make TeX do the computations. \documentclass{article} \usepackage{amsmath} \DeclareFontShape{OMX}{cmex}{b}{n}{<->cmexb10}{} \SetSymbolFont{largesymbols}{bold}{OMX}{cmex}{b}{n} \begin{document} \[ \begin{bmatrix} \, \hbox{\boldmath\valign{% #\cr \hbox{$\!\Big[$}\vfill\cr\noalign{\quad} \vfill\hbox{$\!\Big[$}\vfill\cr\noalign{\quad} \...


12

Welcome! Just make the distance between the rows negative. \documentclass{article} \usepackage{amsmath} \begin{document} \[\begingroup\setlength\arraycolsep{2pt} \begin{bmatrix} [ & &]& & & \\[-1.4ex] & [&&] & & \\[-1.4ex] & &[& &] & \\ & & & & & \ddots\\ \end{...


1

I suggest a different way, without \prescript. \documentclass{article} \usepackage{amsmath} \usepackage{xparse} \NewDocumentEnvironment{fbmatrix}{mmb} {% #1 = left script, #2 = right script {\vphantom{\begin{bmatrix}#3\end{bmatrix}}}_{#1\!\!} \begin{bmatrix}#3\end{bmatrix}_{\!#2} }{} \begin{document} \[ \begin{fbmatrix}{n}{1} y_{11}\\ y_{12}\\ ...


3

You have empty lines which you need to remove. Your code works then, but the subscripts are at different vertical positions because in order to compute the prescript the heights of 1 are added. To fix this, you can use \smash for the 1 subscripts. \documentclass{article} \usepackage{mathtools} \begin{document} \[ \prescript{}{n}{\begin{bmatrix} y_{...


1

You can use the regular commands _ and ^ for right subscript and superscript respectively, and use the \prescript command from mathtools for the left subscript. \documentclass{article} \usepackage{mathtools} \begin{document} \[ \mathbf{A} = \prescript{}{a}{\begin{bmatrix} a_{11} & a_{12} & \cdots & a_{1n} \\ a_{21} & a_{22} & \...


2

Welcome! The nodes inside matrices get automatically names. For instance, the nodes in the matrix mB have names mB-<row>-<column>. This can be used as in \documentclass[margin=5mm]{standalone} \usepackage{tikz} \usetikzlibrary{matrix,calc} \begin{document} \begin{tikzpicture} \begin{scope}[every node/.style={anchor=north east,fill=white,...


3

You may use the option R (alias r) of {NiceMatrix}. I have added nullify-dots to have all the lines with the same height. \documentclass{article} \usepackage{nicematrix} \begin{document} \begin{equation} A =\begin{pNiceMatrix}[R,nullify-dots] 1 & 0 & \Cdots & & 0 \\ -1 & \Ddots & \Ddots & &...


2

If you add nullify dots, it looks much better IMHO. \documentclass{article} \usepackage{nicematrix} \begin{document} \begin{equation} A =\begin{pNiceMatrix}[nullify-dots] 1 & 0 & \Cdots & & 0 \\ -1 & \Ddots & \Ddots & & \Vdots \\ 0 & \Ddots & & & ...


2

The separating length is \BA@colsep, and by default, it is equal to tabcolsep. I defined a new command to change it: \documentclass[11pt]{article} \usepackage{amsmath} \usepackage{blkarray} \makeatletter \newcommand{\setBAcolsep}[1]{\BA@colsep=#1} \makeatother \begin{document} \[ \small\setBAcolsep{53.4pt} \begin{blockarray}{*{3}{c}} ...


5

With nicematrix you get the desired spacing by setting \arraycolsep. And a friendlier syntax, by the way. \documentclass{article} \usepackage{amsmath} \usepackage{nicematrix} \begin{document} \[ \setlength{\arraycolsep}{20pt} \begin{bNiceMatrix}[first-row,first-col] & a & b \\ a & 0 & 1 \\ b & 2 & 3 \end{bNiceMatrix} \] \end{...


4

No idea why, but it uses \BA@colsep so you need to access the command with @ in its name. \documentclass{article} \usepackage{blkarray} \begin{document} \[\makeatletter\setlength\BA@colsep{53.4pt}\makeatother \begin{blockarray}{c c c} & a & b \\ \begin{block}{c[c @{\hspace{50pt}} c]} a & 0 & 1 \\ b & 2 & ...


Top 50 recent answers are included