30

More or less: \documentclass[tikz,border=2mm]{standalone} \usetikzlibrary{positioning, matrix} \usepackage{amsmath} \newcommand{\arrayfilling}[2]{ \fill[#2!30, opacity=.5] ([shift={(1mm,1mm)}]#1.north west) coordinate(#1auxnw)--([shift={(1mm,1mm)}]#1.north east)coordinate(#1auxne) to[out=-75, in=75] ([shift={(1mm,-1mm)}]#1.south east)coordinate(#1auxse)--(...


19

You can use the /.list feature John Kormylo mentioned in his answer to repeat a style for different inputs. \documentclass{article} \usepackage{tikz} \usetikzlibrary{matrix} \begin{document} \tikzset{myset/.style={row 2 column #1/.style={nodes={text=red}}}} \begin{tikzpicture}[myset/.list={1,3,5}] \matrix [matrix of nodes] { 8 & 1 & 6 & 8 & ...


19

Using text depth and text height, you can control the total height for the nodes; text width gives you control over the width (there's also a minimum size key which could be used): \documentclass{article} \usepackage[svgnames]{xcolor} \usepackage{tikz} \begin{document} \begin{tikzpicture}[every node/.style={anchor=base,text depth=.5ex,text height=2ex,...


17

First of all, as you're using matrix of nodes, you don't need to specify nodes manually. each node is only as big as it needs to be, so one (far from elegent or automatic way) is to specify minimum heights and minimum widths: Code \documentclass{beamer} \usepackage{txfonts} \usepackage{tikz} \usetikzlibrary{matrix} \begin{document} \begin{frame}[fragile]{...


17

Here is a proposal. It is essentially quite straightforward in that you simply create a TikZ matrix in the usual way, and then draw the coloured lines using the coordinates of the nodes. To ensure the green line doesn't lie over of the red and blue lines, I've adjusted the coordinates it uses by 0.5mm, this is controlled by a variable I've saved as \offset. ...


16

Just arrays: \documentclass{article} \usepackage{amsmath,array} \begin{document} \[ \newcommand{\blocke}{ \begin{matrix} \hphantom{0} & \hphantom{0} & \hphantom{0} & \hphantom{0} \\ \\ \\ \end{matrix} } \newcommand{\blockr}{ \begin{matrix} \hphantom{0} & \hphantom{0} & \hphantom{0} & \hat{N}\smash[b]{\vphantom{\Big|}} ...


15

With your code you need either to use the fragile option for the frame or to use the ampersand replacement key: \documentclass{beamer} \usepackage{tikz} \usetikzlibrary{matrix} \begin{document} \begin{frame} \begin{center} \begin{tikzpicture}[ampersand replacement=\&] \matrix(m)[matrix of math nodes,row sep=2em,column sep=4em,minimum width=2em] { ...


15

One option using a matrix of math nodes (change the settings, colorts, according to your needs): \documentclass{article} \usepackage{tikz} \usetikzlibrary{matrix} \begin{document} \[ \begin{tikzpicture}[baseline,>=latex] \matrix[ matrix of math nodes, nodes in empty cells, left delimiter=(, right delimiter=), nodes={text height=8pt,text depth=...


14

Very recently, yesterday, I sent to CTAN a new package called aobs-tikz which is designed exactly for these jobs. It is based on Daniel's method illustrated in Mindmap tikzpicture in beamer (reveal step by step) and it extends the styles I defined in Highlighting in Beamer using TikZ nodes. A preview of its usage: \documentclass{beamer} \usepackage{lmodern,...


14

A later version of this package is now on CTAN - updated answer to reflect current usage etc. NEW ANSWER - UPDATED I finally got fed up with not having a better solution to offer people. Logic is not well served, particularly for teaching lower level classes. My solution is a new package. It certainly contains bugs and it is not altogether automatic. ...


14

For fun: that is easy with pstricks: \documentclass[11pt,x11names]{standalone} \usepackage{pst-node} \usepackage{auto-pst-pdf} \usepackage{amsmath} \usepackage{sansmath} \begin{document} \mathversion{sans}\setlength\fboxsep{0pt} \begin{postscript} $\begin{pmatrix} 0 & 0 & 0 & 0 & \dots & 0 \\ 0 & \pnode[0,1.5ex]{A} &...


12

align=center without any text width is the problem. Comment it out and all text will be centered (with or without space after it) or add a text width over which the text could be centered. \documentclass[tikz]{standalone} \usetikzlibrary{matrix} \begin{document} \begin{tikzpicture} \matrix [ matrix of nodes, row sep=-\...


11

Because all nodes are horizontally centered in the columns you can load the calc library and use \draw[blue]({$(M-1-1)!.5!(M-1-2)$} |- M.north) -- ({$(M-1-1)!.5!(M-1-2)$} |- M.south); to draw the blue line between the first and the second column. To get the green line you have to use all nodes of the second row inside the fit option: \node[fit=(M-2-1) (...


11

I will propose two solutions. The first one highlights the given elements by simply change the font colour, whilst the second will highlight elements by changing the background colour. Font Colour This is probably the easiest. You can just use the xcolor to change the colour of the font. Due to the way matrices are constructed, the colour only applies ...


11

You can use the points relative to the nodes to draw the sectors, even leaving space for the delimiters to be seen at different distances, you can uncomment line 30 to see the nodes that delimit the coordinates relative to the nodes. I do not know if it is the most practical but it is an adaptation that comes to resemble what you want. MWE: \documentclass[...


10

Another possibility would be to fill columns and rows once the matrix is finished. You can fill a region and place it on the background layer. As Tom's solution, this one is also far from elegant or automatic. It's even less automatic because you have to define all corners knowing the tallest and widest cells for the row and column. Next code shows two ...


10

Here's an alternative which wraps the contents of each of the nodes within the matrix in the variable-width \pbox defined by the pbox package using the execute at begin cell option. You could selectively apply the \pbox to the offending material, but this approach allows the syntax of the question to be used. The \linewidth is the maximum width for the node. ...


10

Since version 3.0.0 when you use a matrix of nodes it seems that \node is not allowed inside cells (I initially didn't like this feature (I hope it's a feature and not a bug), but after thinking about it, it kind of makes perfect sense); however, you can still use the |[<options>]| syntax to modify the nodes: \documentclass[12pt]{standalone} \...


10

TikZ changes the category code of & to be an active character to process the matrix. But the tikzpicture is used as argument for \savebox. When TeX parses an argument, then the text is tokenized with the current category code settings. Then, when TikZ changes the category code, it does not have an effect, because & is already tokenized. LaTeX ...


10

As far as I know, there is no empty cells style. But you can use a .list to declare a list of individual cells which has to use certain style. The code is taken form cjorssen answer to TikZ matrix, style for combination or rows and columns \documentclass{standalone} \usepackage{tikz} \usetikzlibrary{matrix} \begin{document} \begin{tikzpicture}[ ...


10

You need to use a fragile frame: \documentclass{beamer} \usepackage{tikz} \usetikzlibrary{matrix,decorations.pathreplacing} \pgfkeys{tikz/mymatrixenv/.style={decoration=brace,every left delimiter/.style={xshift=4pt},every right delimiter/.style={xshift=-4pt}}} \pgfkeys{tikz/mymatrix/.style={matrix of math nodes,left delimiter=[,right delimiter={]},inner ...


9

EDIT: Added LuaTeX version Probably not what is exactly wanted. Also somewhat crude, and slow. Using LuaTeX or PSTricks would be very good choice to speed this up. But I'm old fashioned and stuck in my ways, so... \documentclass[tikz]{standalone} \usepackage{tikz} % Each cell is stored globally as a macro % for example \csname cell-glider-1-7\endcsname \...


9

You can set the minimum height of the nodes to a value that is (at least) as large as the highest node. 16mm is sufficient for this example. If you want different heights for different rows, you can use the row n styles, similar to the column n styles you've used in your example. For example row 1/.style={ nodes={ minimum height=10mm ...


9

More a long comment than a real answer... Based on percusse's answer, this style allows to specify both row and column. \documentclass{standalone} \usepackage{tikz} \usetikzlibrary{matrix} \begin{document} \tikzset{myset/.style args = {(#1,#2)}{% row #1 column #2/.style={nodes={text=red}}}} \begin{tikzpicture}[myset/.list={(2,1),(3,3),(1,5)}] \matrix [...


9

The delimiters can be shifted through the styles every (left|right) delimiter: \documentclass[a5paper]{article}% (a5paper for smaller image width) \usepackage{amsmath,tikz} \usetikzlibrary{matrix} \begin{document} AMSMath: \[ \begin{pmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{pmatrix} \] TikZ: \[ \begin{tikzpicture}[ every left ...


Only top voted, non community-wiki answers of a minimum length are eligible