1

I have a tile.tex (a separate file) that I call in my main document.

I want to do two things

  1. Create a pattern of 3x5 by stitching together tile.tex. This means I will be calling tile.tex 15 times.
  2. I need to control rotation of each tile. Since my tile is a square therefore I will be rotating it at only four angels 0,90,180,270.

what do I need to do in following code

\begin{document}
%-----------------------------
\begin{frame}
\frametitle{\color{blue}{Tile}}
\begin{figure}
\input{tile}
\end{figure}
\end{frame}
%-----------------------------
\end{document}
NAASI
  • 2,809
  • compile the tile.tex inside an standalone class. This way you have a cropped pdf file with your tile. Then you can use \includegraphics to input and rotate it like you want. – Ignasi Feb 21 '18 at 18:32
  • but how do I create a grid of tiles? – NAASI Feb 21 '18 at 18:37

1 Answers1

2

Declare your tile into an standalone.cls document:

\documentclass[tikz]{standalone}
\begin{document}
\tikz \node[draw=red, thick, minimum size=2cm] {A};
\end{document}

Which produces and adjusted/cropped figure:

Tile

And include this graphic file as an image wherever you need. A tabular can be used to organize them into a grid with or without separation between columns and rows.

\documentclass{beamer}

\begin{document}
\begin{frame}{My title}

{\renewcommand{\arraystretch}{0}
\begin{tabular}{*{5}{@{}c}}
\includegraphics[origin=c,angle=0]{mytile} &
\includegraphics[origin=c,angle=90]{mytile} &
\includegraphics[origin=c,angle=180]{mytile} &
\includegraphics[origin=c,angle=270]{mytile} &
\includegraphics[origin=c,angle=0]{mytile} \\
\includegraphics[origin=c,angle=0]{mytile} &
\includegraphics[origin=c,angle=90]{mytile} &
\includegraphics[origin=c,angle=180]{mytile} &
\includegraphics[origin=c,angle=270]{mytile} &
\includegraphics[origin=c,angle=0]{mytile} \\
\includegraphics[origin=c,angle=0]{mytile} &
\includegraphics[origin=c,angle=90]{mytile} &
\includegraphics[origin=c,angle=180]{mytile} &
\includegraphics[origin=c,angle=270]{mytile} &
\includegraphics[origin=c,angle=0]{mytile} \\
\end{tabular}}

\end{frame}
\end{document}

slide

In case you use TikZ to define your figure it's possible to use other solutions to build an array of rotated images. One of them could be to define the main image as a pic and repeat it inside a matrix with no columns and row separation. Some examples are following. The original figure has been taken from looking for Efficient alternative to my tikzpic code.

\documentclass[tikz, border=2mm]{standalone} 
\usetikzlibrary{positioning}

\tikzset{
    myfigure/.pic={
        \fill[black] (0,0) rectangle ++(-1,-1);
        \fill[blue] (-1,0) rectangle ++(-3,-1);
        \fill[green] (-4,0)-- ++(-1,0)--++(1,-1)--cycle;
        \fill[blue] (0,-1) rectangle ++(-1,-3);
        \fill[green] (0,-4)-- ++(-1,0)--++(1,-1)--cycle;
        \fill[red] (-4,-1)-- ++(0,-3)--++(3,0)--cycle;
    }
}

\begin{document}
\begin{tikzpicture}
\matrix[column sep=0pt, row sep=0pt] (A) {
    \pic[rotate around={-90:(-2.5,-2.5)}]{myfigure}; & 
    \pic[rotate around={180:(-2.5,-2.5)}]{myfigure}; \\
    \pic{myfigure}; &   
    \pic[rotate around={90:(-2.5,-2.5)}]{myfigure}; \\}; 

\matrix[column sep=0pt, row sep=0pt, right=of A] (B){
    \pic[rotate around={90:(-2.5,-2.5)}]{myfigure}; &   
    \pic{myfigure}; \\ 
    \pic[rotate around={180:(-2.5,-2.5)}]{myfigure}; &  
    \pic[rotate around={-90:(-2.5,-2.5)}]{myfigure}; \\}; 

\matrix[column sep=0pt, row sep=0pt, below=of A]{
    \pic[rotate around={180:(-2.5,-2.5)}]{myfigure}; &  
    \pic[rotate around={90:(-2.5,-2.5)}]{myfigure}; \\ 
    \pic[rotate around={270:(-2.5,-2.5)}]{myfigure}; &  
    \pic[rotate around={0:(-2.5,-2.5)}]{myfigure}; \\}; 

\begin{scope}[shift={(10.5cm,-10.5cm)}]
    \pic at (0,0) {myfigure};
    \pic[rotate=90] at (0,-1) {myfigure};
    \pic[rotate=180] at (1,-1) {myfigure};
    \pic[rotate=270] at (1,0) {myfigure};
\end{scope}
\end{tikzpicture}
\end{document}

enter image description here

Ignasi
  • 136,588
  • I am unable to compile your code. I get error "unknown file mytile". I have not worked with standalone before and I am unable to get an output from it that I can save as "myfile.pdf" – NAASI Feb 21 '18 at 20:07
  • I am using overleaf.com for my work. It is because of the online editor. I cant get an output from my standalone doc that I can save as mytile.pdf – NAASI Feb 21 '18 at 20:26
  • I need these tiles to be side by side with no space between them. how can we do this – NAASI Feb 21 '18 at 23:45
  • Does my answer in https://tex.stackexchange.com/a/416582/1952 solve the question? – Ignasi Feb 22 '18 at 09:39
  • I've updated the answer with an adjusted tabular and matrices of pics. – Ignasi Feb 22 '18 at 11:02
  • using "pic" is interesting and makes more sense to me. Thanks for your help. I might post additional comments here as I apply this to my ongoing "tile" project. – NAASI Feb 22 '18 at 16:03
  • One question regarding "pic" solution. Is it possible to have a separate pic.tex (\tikzset{myfigure/.pic={ ...}} part of your code) in our directory which we can call in grid.tex (\begin{document} \begin{tikzpicture}\matrix[column sep=0pt, row sep=0pt] (A) {...};\end{tikzpicture}\end{document} ) – NAASI Feb 22 '18 at 16:09
  • You can include in the preamble with \input{pic}. – Ignasi Feb 22 '18 at 16:34