dudebout / matrix.skeleton Goto Github PK
View Code? Open in Web Editor NEWA PGF/TikZ library that simplifies working with multiple matrix nodes.
Home Page: https://www.ctan.org/pkg/matrix-skeleton
License: ISC License
A PGF/TikZ library that simplifies working with multiple matrix nodes.
Home Page: https://www.ctan.org/pkg/matrix-skeleton
License: ISC License
Please see here for a detailed account of the issue.
I've included the code that causes the problem
\documentclass[leqno]{amsart}
\usepackage{tikz}
\usetikzlibrary{matrix,calc,positioning,tikzmark,patterns,fit,matrix.skeleton}
\begin{document}
\begin{tikzpicture}
\matrix (x) [matrix of math nodes,style contour = {draw, very thick},style grid = {draw, thin},label=above:\( X_e \),nodes in empty cells=true,ampersand replacement=\&] {
\& \\
\& \\
\& \\
\& \\
\& \\
};
\matrix (m) at (4,0) [matrix of math nodes,style contour = {draw, very thick},style grid = {draw, thin},label={above:\( A \)},nodes in empty cells=true,ampersand replacement=\&] {
\& \& \\
\& \& \\
\& \& \\
\& \& \\
\& \& \\
};
\node[black] (val-m-5-3) at (m-5-3) {1};
\node[black,circle,draw,minimum size=2.2mm] (circle-m-5-3) at (m-5-3) {};
\fitandstyle[background]{(m-cell-1-1) (m-cell-3-1)}{fill=Gray};
\fitandstyle[background]{(m-cell-1-2) (m-cell-3-3)}{pattern=crosshatch};
\end{tikzpicture}
\end{document}
This creates the following image (note how the label and drawing doesn't move with the matrix.
Note that if I just draw the matrix m by itself without moving it I get the desired result.
I am trying to depict more than one matrix with tikz with the tikz libraries matrix and matrix.skeleton because later I want to highlight some things and so on.
This would be my mwe:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix}
\usetikzlibrary{matrix.skeleton}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\matrix (X) [matrix of math nodes,
label skeleton,
left delimiter = (,
right delimiter = )] at (0,0)
{%
\vdots & \vdots & & \vdots \\
x & x & \cdots & x \\
\vdots & \vdots & & \vdots \\
x & x & \cdots & x\\
\vdots & \vdots & & \vdots \\
x & x & \cdots & x\\
\vdots & \vdots & & \vdots \\
x & x & \cdots & x\\
\vdots & \vdots & & \vdots \\
x & x & \cdots & x\\
};
\matrix (U) [matrix of math nodes,
label skeleton,
left delimiter = (,
right delimiter = )] at (4,0)
{
\vdots \\
u\\
\vdots \\
u\\
\vdots \\
u\\
\vdots \\
u\\
\vdots \\
u\\
};
\end{tikzpicture}
\end{document}
outcome from mwe:
which creates an extra white space to the right of the second matrix. I have notice that it happens when I make use of the matrix.skeleton library by means of label skeleton. However, I can not find the solution in the manual of the package from CTAN.
There is a significant issue with the style contour and style grid functions: any repositioning of the matrix screws up placement of the border.
Consider the following example:
\documentclass[a4paper,10pt]{report}
\usepackage{tikz}
\usetikzlibrary{matrix,matrix.skeleton}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
% create matrix `A'
\matrix [ampersand replacement=\&,
matrix of nodes,
style grid = {draw, thin},
style contour={draw, thick},
] (A) {
aa \& ba \& ca \& da \\
ab \& bb \& cb \& db \\
};
% create matrix `B'
% align both matrices at the top
\matrix [ampersand replacement=\&,
matrix of nodes,
style grid = {draw, thin},
style contour={draw, thick},
matrix anchor=north west,
right=0pt of A.north east,
] (B) {
aa \& ba \\
ab \& bb \\
ac \& bc \\
ad \& bd \\
};
% show that matrix `A' and `B' are aligned at the top
\fill [green] (A.north east) circle (3pt);
\fill [red] (B.north west) circle (2pt);
\end{tikzpicture}
\end{document}
(image added by @dudebout on 2021/02/09)
You will see that the contents of the matrix is aligned/anchored as it should, but the outline of the second matrix is off.
In general, any absolute positioning of the matrix also sends the outline flying, for example
\documentclass[a4paper,10pt]{report}
\usepackage{tikz}
\usetikzlibrary{matrix,matrix.skeleton}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[remember picture,overlay]
% create matrix `A'
\matrix [ampersand replacement=\&,
matrix of nodes,
style grid = {draw, thin},
style contour={draw, thick},
] at (current page.center) (A) {
aa \& ba \& ca \& da \\
ab \& bb \& cb \& db \\
};
% create matrix `B'
% align both matrices at the top
\matrix [ampersand replacement=\&,
matrix of nodes,
style grid = {draw, thin},
style contour={draw, thick},
matrix anchor=north west,
right=0pt of A.north east,
] (B) {
aa \& ba \\
ab \& bb \\
ac \& bc \\
ad \& bd \\
};
% show that matrix `A' and `B' are aligned at the top
\fill [green] (A.north east) circle (3pt);
\fill [red] (B.north west) circle (2pt);
\end{tikzpicture}
\end{document}
(image added by @dudebout on 2021/02/09)
I'm not sure what is happening, but somehow, the row and column coordinates aren't calculated correctly, while the cells are, see for example when you add
\path [draw, thick,red] (A-row-1.north west) -- (A-1-4.north east) -- (A-2-4.south east) -- (A-2-1.south west) -- cycle;
right before creating matrix B.
Most likely, moving ths matrix causes the row/col corrdinates to be computed twice: once with the right position, and then the shifting is applied again.
Perhaps it'd be useful to upload matrix.skeleton
to CTAN, making it available in various LaTeX distributions out of the box? From what I can see this would entail:
README.md
(this is required by CTAN; need not be added to the GitHub version, of course – just the one in the CTAN zipfile);matrix-skeleton
or the like (see below); and/graphics/pgf/contrib/matrix-skeleton
(dots are not permitted here) and the version either set to the release/commit date (2014-07-23
) or actually creating a versioned release here on GitHub first.If you'd rather not have the hassle, I'd be happy to register it for you.
When using label skeleton
on a matrix full of nodes, one receives the error:
! Undefined control sequence.\pgfmath@dimen@ ...men@@ #1=0.0pt\relax \pgfmath@
The following minimal reproducing example exhibits that behavior:
\documentclass[tikz]{standalone}
\usetikzlibrary{matrix.skeleton}
\begin{document}
\begin{tikzpicture}
\matrix (m) [matrix of nodes, nodes in empty cells, label skeleton] {
\node {}; & \node {}; \\
\node {}; & \node {}; \\
};
\end{tikzpicture}
\end{document}
If you remove any one node from the matrix, compilation works. Note that the node is in this case created by the nodes in empty cells
option.
Hi,
In the appended example, errors occur because matrix.skeleton is loaded and used on a one-column-matrix. Just using the matrix-library or adding an empty second column seems to be working. Maybe this is related to pgf-tikz/pgf#267.
I don't know if you actively work on this Repo but thank you for your help.
Kind regards
\documentclass[]{article}
\usepackage{tikz}
\usetikzlibrary{
matrix,
matrix.skeleton
}
\begin{document}
\begin{tikzpicture}[]
\matrix(m1)[matrix of nodes] at (0,0){
a \\
b \\
};
\end{tikzpicture}
\end{document}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.