1

I am trying to type the pictures below in latex but I didn't get it for weeks. I will be VERY glad if I can get help.

image 1: matrix with triangles, rectangle and square shapes

Please note that for the first image

  1. each shape is coloured in gray

  2. each shape is labelled such as a1, a2, a3, y etc

  3. beside variable y, we have two zeros (left and right) not letter 0 nor circle

Image 2: matrix with anvil shape

Image 2 has one shape which looks like two anvils join together, then partition with dotted lines.

0

1 Answer 1

3

Try to understand following code.

\documentclass{article} \usepackage{tikz} \usetikzlibrary{positioning, shapes.geometric, matrix} \begin{document} \[ A = \left[ \begin{tikzpicture}[% baseline, triangle/.style={% draw, fill=gray!50, minimum width=1.4142cm, inner sep=0pt, isosceles triangle, isosceles triangle apex angle=90, shape border uses incircle, shape border rotate=#1}, rect/.style={% draw, fill=gray!50} ] \matrix (A) [matrix, row sep=1mm, column sep=2mm] { \node[triangle=45, anchor=north] (a11) {$a_1$}; & \node[rect, minimum height=1cm, anchor=north] (a12) {$y_1$}; & \node[triangle=135, anchor=north] (a13) {$a_2$}; \\ \node[] {$o$}; & \node[rect, minimum height=1cm] (a22) {$y_1$}; & \node[] {$o$};\\ \node[triangle=-45, anchor=south] (a31) {$a_3$}; & \node[rect, minimum height=1cm, anchor=south] (a32) {$y_2$}; & \node[triangle=-135, anchor=south] (a33) {$a_4$}; \\ }; \end{tikzpicture} \right] \\ A = \left[ \begin{tikzpicture}[% baseline, triangle/.style={% % fill=gray!50, minimum width=1.4142cm, inner sep=0pt, isosceles triangle, isosceles triangle apex angle=90, shape border uses incircle, shape border rotate=#1}, rect/.style={% % fill=gray!50 } ] \matrix (A) [matrix, row sep=0pt, column sep=0pt] { \node[triangle=45, anchor=north] (a11) {$a_1$}; & \node[rect, minimum height=1cm, anchor=north] (a12) {$y_1$}; & \node[triangle=135, anchor=north] (a13) {$a_2$}; \\ \node[] {$o$}; & \node[rect, minimum height=1cm] (a22) {$y_1$}; & \node[] {$o$};\\ \node[triangle=-45, anchor=south] (a31) {$a_3$}; & \node[rect, minimum height=1cm, anchor=south] (a32) {$y_2$}; & \node[triangle=-135, anchor=south] (a33) {$a_4$}; \\ }; \draw (a11.left corner)--(a13.right corner)--(a22.north east)--(a22.south east)--(a33.left corner)--(a31.right corner)--(a22.south west)--(a22.north west)--cycle; \draw[dashed] (a11.left corner|-a22.north)--(a13.right corner|-a22.north); \draw[dashed] (a11.left corner|-a22.south)--(a13.right corner|-a22.south); \draw[dashed] (A.north-|a22.west)--(A.south-|a22.west); \draw[dashed] (A.south-|a22.east)--(A.north-|a22.east); \end{tikzpicture} \right] \] \end{document} 

![enter image description here

4
  • Thank you for the solution. Please, is there a way to join all the shapes form form an anvil (like the one in second picture)? Commented May 15, 2017 at 13:42
  • @dupsy is setting the matrix with row sep=0pt, column sep=0pt enough? or do you need to delete all "inner lines"? Commented May 15, 2017 at 15:36
  • Yes, I want to delete the inner lines after setting row sep=0pt, column sep=0pt. Commented May 15, 2017 at 17:23
  • @dupsy Look at updated answer. Commented May 16, 2017 at 7:31

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.