6

I was looking for a macros simplifying pipe dreams drawing (these are specific tilings used in combinatorics). However I haven’t found one. So I wrote it myself and I am providing the possible solution down below in the answer.

2
  • 1
    Is this supposed to be a question where you give an answer by yourself (which would be totally fine)? If yes, could you somehow better divide the question part and the answer part? I have the feeling that the last two sentences of your question rather belong to the answer ... Or do you need help with the code you posted? Then please rephrase your question to make clear where you need help and place the code part into your question as well. (You can use the "Edit" link to edit your question/answer.) Commented May 15, 2023 at 0:23
  • 1
    Yeah thank you! I am editing it. Commented May 15, 2023 at 2:48

2 Answers 2

5

This is code I wrote a while ago for making knot mosaics. It probably needs updating, but works fine for your purpose.

enter image description here

% mosaic         New environment for classical (unlabeled) knot mosaics. Usage is as follows:
%                   \begin{mosaic}[<tikz options>]{<tile size in cm>} 
%                      <entry> \& <entry> \& ... \& <entry> \\
%                      <entry> \& <entry> \& ... \& <entry> \\
%                        ...
%                      <entry> \& <entry> \& ... \& <entry> \\
%                   \end{mosaic}
%                Final \\ in last line is required.
%                Optional <size> has default 1. Unit is cm. Determines size of each tile.
%                Each <entry> is typically a tilename but can be anything or empty. Note that
%                <entries> must be separated by \& not just with & (as for a typical table).

\documentclass{article}

\usepackage{mathtools}
\usepackage{tikz,environ}

\NewEnviron{mosaic}[2][]{\begin{tikzpicture}[baseline]\def\tilesize{#2}\matrix[mosai,ampersand replacement=\&, #1]{\BODY};\end{tikzpicture}}

\newcommand{\cspace}{.1} % spacing for crossings
\newcommand{\tileedge}{.05pt} % thickness of tile edge. Does not scale.
\newcommand{\knotthickness}{1.5pt} % thickness of knot for 1cm tile. Scales with tile size.

\newcommand{\tileo}{\tikz \draw[tilestyle] (0,0) rectangle (\tilesize,\tilesize);}
\newcommand{\tilei}[1][{}]{\tikz {\draw[tilestyle] (0,0) rectangle (\tilesize,\tilesize); \draw[#1,knotstyle={\tilesize*\knotthickness}] (0,.5*\tilesize) to[out=0, in=90] (.5*\tilesize,0);}}
\newcommand{\tileii}[1][{}]{\tikz {\draw[tilestyle] (0,0) rectangle (\tilesize,\tilesize); \draw[#1,knotstyle={\tilesize*\knotthickness}] (\tilesize,.5*\tilesize) to[out=180, in=90] (.5*\tilesize,0);}}
\newcommand{\tileiii}[1][{}]{\tikz {\draw[tilestyle] (0,0) rectangle (\tilesize,\tilesize); \draw[#1,knotstyle={\tilesize*\knotthickness}] (\tilesize,.5*\tilesize) to[out=180, in=-90] (.5*\tilesize,\tilesize);}}
\newcommand{\tileiv}[1][{}]{\tikz {\draw[tilestyle] (0,0) rectangle (\tilesize,\tilesize); \draw[#1,knotstyle={\tilesize*\knotthickness}] (0,.5*\tilesize) to[out=0, in=-90] (.5*\tilesize,\tilesize);}}
\newcommand{\tilev}[1][{}]{\tikz {\draw[tilestyle] (0,0) rectangle (\tilesize,\tilesize); \draw[#1,knotstyle={\tilesize*\knotthickness}] (0,.5*\tilesize) to (\tilesize,.5*\tilesize);}}
\newcommand{\tilevi}[1][{}]{\tikz {\draw[tilestyle] (0,0) rectangle (\tilesize,\tilesize); \draw[#1,knotstyle={\tilesize*\knotthickness}] (.5*\tilesize,0) to (.5*\tilesize,\tilesize);}}
\newcommand{\tilevii}[1][{}]{\tikz {\draw[tilestyle] (0,0) rectangle (\tilesize,\tilesize); \draw[#1,knotstyle={\tilesize*\knotthickness}] (0,.5*\tilesize) to[out=0, in=90] (.5*\tilesize,0); \draw[#1,knotstyle={\tilesize*\knotthickness}] (\tilesize,.5*\tilesize) to[out=180, in=-90] (.5*\tilesize,\tilesize);}}
\newcommand{\tileviii}[1][{}]{\tikz {\draw[tilestyle] (0,0) rectangle (\tilesize,\tilesize); \draw[#1,knotstyle={\tilesize*\knotthickness}] (\tilesize,.5*\tilesize) to[out=180, in=90] (.5*\tilesize,0); \draw[#1,knotstyle={\tilesize*\knotthickness}] (0,.5*\tilesize) to[out=0, in=-90] (.5*\tilesize,\tilesize);}}
\newcommand{\tileix}[1][{}]{\tikz {\draw[tilestyle] (0,0) rectangle (\tilesize,\tilesize); \draw[#1,knotstyle={\tilesize*\knotthickness}] (0,.5*\tilesize) to (\tilesize,.5*\tilesize); \draw[#1,knotstyle={\tilesize*\knotthickness}] (.5*\tilesize,0) to (.5*\tilesize,.5*\tilesize-\tilesize*\cspace); \draw[#1,knotstyle={\tilesize*\knotthickness}] (.5*\tilesize,.5*\tilesize+\tilesize*\cspace) to (.5*\tilesize,\tilesize);}}
\newcommand{\tilex}[1][{}]{\tikz {\draw[tilestyle] (0,0) rectangle (\tilesize,\tilesize); \draw[#1,knotstyle={\tilesize*\knotthickness}] (.5*\tilesize,0) to (.5*\tilesize,\tilesize); \draw[#1,knotstyle={\tilesize*\knotthickness}] (0,.5*\tilesize) to (.5*\tilesize-\tilesize*\cspace,.5*\tilesize); \draw[#1,knotstyle={\tilesize*\knotthickness}] (.5*\tilesize+\tilesize*\cspace,.5*\tilesize) to (\tilesize,.5*\tilesize);}}

\tikzset{tilestyle/.style={use as bounding box, line width=\tileedge}} % Add colors/styles here for tile edge and fill. Example: fill=gray!30 for light gray background
\tikzset{knotstyle/.style={line width=#1}} % Add colors and other line styles here
\tikzset{mosai/.style={execute at begin cell=\node\bgroup, execute at end cell=\egroup;, column sep={\tilesize cm,between origins}, row sep={\tilesize cm,between origins}, inner sep=0}}


\begin{document}

This is a displayed classical mosaic with tiles $T_0$--$T_{10}$ running across the rows. Classical mosaics need not be square. Empty entries leave empty mosaic tiles, i.e., no border square.

\[
\begin{mosaic}{1}
    \tileo \& \tilei \& \tileii \& \tileiii\\
    \tileiv \& \tilev \& \tilevi \& \tilevii\\
    \tileviii \& \tileix \& \tilex \\
\end{mosaic}
\]
\vspace{2cm}

\[
\begin{mosaic}[font=\Large\sffamily]{1}
  \& 1 \& 2\& 3 \& 4 \&5 \& 6\\
1 \& \tilex \& \tilex \& \tileviii \& \tileviii \& \tileviii \& \tileiv\\
2 \& \tileviii \& \tileviii \& \tileviii \& \tileviii \& \tileiv\\
3 \& \tilex \& \tilex \& \tilex \& \tileiv\\
4 \& \tilex \& \tileviii \& \tileiv\\
5 \& \tileviii \& \tileiv\\
6 \& \tileiv\\
\end{mosaic}
\]

\end{document}
0
5

Here is a simple solution. (It is not the most efficient, but I’m still working on it).


\documentclass{minimal}
\usepackage{tikz}
\usepackage{xcolor}
\usepackage{bm}
\newcommand{\cross}[2]{
\begin{scope}[xshift=#1cm,yshift=-#2cm]
\draw[very thick] (0,-0.5) -- (0.45,-0.5);
\draw[very thick] (0.55,-0.5) -- (1,-0.5);
    \draw[very thick] (0.5,0) -- (0.5,-1);
\end{scope}
}%draws a cross
\newcommand{\arcs}[2]{
\begin{scope}[xshift=#1cm,yshift=-#2cm]
    \draw[very thick] (0,-0.5) arc (-90:0:0.5cm);
    \draw[very thick] (0.5,-1) arc (180:90:0.5cm);
\end{scope}
}%draws elbows (arcs)
\newcommand{\GRID}[1]{
\begin{scope}
\draw[black!25!white] (0,-#1cm) |- (#1cm,0);
\foreach \n in {0,...,{#1}} \draw[black!25!white] (\n+1,0) -- (\n+1,\n-#1);
\foreach \n in {0,...,{#1}} \draw[black!25!white] (0,-\n-1) -- (#1-\n,-\n-1);
\foreach \n in {1,...,{#1}} \draw[very thick] (\n-1,-#1+\n-0.5) arc (-90:0:0.5cm);
\end{scope}
}%draws a grid and the outer elbows

\newcommand{\GRIDwitnum}[1]{
\begin{scope}
\foreach \n in {1,...,#1} \node at (\n-0.5,0.5){$\bm{\mathsf{\n}}$};
\foreach \n in {1,...,#1} \node at (-0.5,-\n+0.5){$\bm{\mathsf{\n}}$};
\draw[black!25!white] (0,-#1cm) |- (#1cm,0);
\foreach \n in {0,...,{#1}} \draw[black!25!white] (\n+1,0) -- (\n+1,\n-#1);
\foreach \n in {0,...,{#1}} \draw[black!25!white] (0,-\n-1) -- (#1-\n,-\n-1);
\foreach \n in {1,...,{#1}} \draw[very thick] (\n-1,-#1+\n-0.5) arc (-90:0:0.5cm);
\end{scope}
} %draws a grid and the outer elbows and numerates the pipe’ ends 
\begin{document}

\begin{tikzpicture}[scale=0.6]
    \GRIDwitnum{6}
    \cross{0}{0}
    \cross{1}{0}
    \arcs{2}{0}
    \arcs{3}{0}
    \arcs{4}{0}
    \arcs{0}{1}
    \arcs{1}{1}
    \arcs{2}{1}
    \arcs{3}{1}
    \cross{0}{2}
    \cross{1}{2}
    \cross{2}{2}
    \cross{0}{3}
    \arcs{1}{3}
    \arcs{0}{4}
\end{tikzpicture}

\end{document}

Looks like this!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .