# [Tex/LaTex] How to make a full equation with tikz

matricestikz-matrixtikz-styles

I am using this solution here to make long dashes within a matrix, and it is working well. The code is:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}

% possible to customize here the dash aspect
\newcommand{\mydash}{
\draw(0.3,0.5ex)--(-0.3,0.5ex);
}

\begin{document}
$P= \begin{tikzpicture}[baseline=-0.5ex] \matrix(m)[matrix of math nodes,left delimiter=(,right delimiter=),ampersand replacement=\&] { \mydash \& y_1 \& \mydash \\ \mydash \& y_2+z_2 \& \mydash \\ \mydash \& y_3 \& \mydash \\ }; \end{tikzpicture}$

\end{document}


However, I am now sure how to start writing full blown equations with it. I have not had much luck. The above makes a nice matrix with lines along the rows.

1) What I want is something like P = X Y Z, where X, Y , and Z, are all shown with the lines along its rows as in the prior example given. I cannot seem to concatenate them for whatever reason though…

2) I would like the matrix brackets to also be square, and not curvy.

1) The point to realise is that: everything is happening in a math mode. And, tikzpicture is is simply a new environment in the math mode. So, you are not writing equations in Tikz. You're using Tikz only to get the dashes right. An example will hopefully set this right for you:

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{matrix}

% possible to customize here the dash aspect
\newcommand{\mydash}{
\draw(0.3,0.5ex)--(-0.3,0.5ex);
}

\begin{document}
$X= \begin{tikzpicture}[baseline=-0.5ex] \matrix(m)[matrix of math nodes,left delimiter={[},right delimiter={]},ampersand replacement=\&] { \mydash \& u_1 \& \mydash \\ \mydash \& u_2 \& \mydash \\ \mydash \& u_3 \& \mydash \\ }; \end{tikzpicture} \begin{tikzpicture}[baseline=-0.5ex] \matrix(m)[matrix of math nodes,left delimiter={[},right delimiter={]},ampersand replacement=\&] { \mydash \& b_1 \& \mydash \\ \mydash \& b_2 \& \mydash \\ \mydash \& b_3 \& \mydash \\ \mydash \& b_4 \& \mydash \\ }; \end{tikzpicture} \begin{bmatrix} \biggl| \\ c_1 \\ \biggl| \end{bmatrix}$

\end{document}


Output.

2) For the second question about the shape of the enclosing braces, we need to appropriately modify the options: left delimiter and right delimiter. In this case, we set it to: {[} and {]} respectively.

Hope that helps.