# “Tape” environment in LaTeX

I have never defined an entirely new environment in a LaTeX document - I have only ever modified existing environments to suit my purposes. Now, however, I suddenly have a use for an obscure environment, and have no idea where to start in creating it.

I am looking to define an environment in LaTeX where I can type text and equations in small connected boxes, so that the end result looks like a "tape", with each block containing equations and/or text and/or images. It also needs the following three additional properties:

1. If the length of the sequence of blocks exceeds the width of the page (excluding margins), then the first block that would have exceeded that length is transferred to the next line, and the tape continues from there.

2. The height of each block in a given line is equal to the height of the of the tallest block in that line, which is determined by wrapping around the tallest equation or text block with a small amount of padding.

3. The final block has the option of not having a box drawn around it.

Here is a picture of the sort of thing I have in mind:

As I mentioned above, I am beyond my skills here. Does anyone know how to make such an environment? Anything ranging from general advice on how to figure this out to the completed code I need to make the environment would be very much appreciated.

Thanks very much.

-
What do you expect your input to be like? –  Manuel Jun 12 '14 at 18:50
Thanks for the reply. I'm not sure if this is what you mean, but for my input I will just be manually entering stuff - this won't be any kind of dynamic document, simply a pdf. Thanks. –  user3558855 Jun 18 '14 at 23:30
I meant if you wanted it to be something like \cell{…}\cell{…}\cell{…} or \blockparagraph{…, …, …, …, …, …}. But you like David's answer :D Don't forget to click on the green tick to accept the answer as correct (and to upvote, if you want). That's the way here to say thank you for the answer. –  Manuel Jun 19 '14 at 8:15
Will do, thanks for the advice! –  user3558855 Jun 20 '14 at 17:28

maybe this will get you started

\documentclass{article}
\usepackage{amsmath}
\newenvironment{tape}{%
\par\bigskip
\setlength\parindent{0pt}%
\setlength\parfillskip{0pt}%
\offinterlineskip
\hrule\vskip-.4pt\relax\par}{%
\par\bigskip
}
\newcommand{\cell}[1]{%\hfill
\vrule
\mbox{ $\displaystyle#1$ }\vrule\hfill
\ignorespaces}

\begin{document}

\begin{tape}%
\cell{x+y}\cell{\sum_0^n(x+y)^2 = x^8}
\cell{a}\cell{\frac{1}{1+\frac{1}{1+1}}}
\cell{1+2+3=£=2+1}\cell{A=\begin{pmatrix}1&2\\3&4\end{pmatrix}}
\cell{1+2+3}\cell{\sqrt{\frac{a}{b}}}
\cell{\sum_C(x+y)^2 = x^8}
\cell{a^{a^{a^a}}}\cell{1+2+3=£=2+1}
\cell{\frac{1}{1+\frac{1}{1+1}}}
\cell{1}\cell{2}\cell{4}
\cell{1}\cell{2}\cell{4}
\end{tape}

\begin{tape}
\cell{1}\cell{2}\cell{4}
\cell{1}\cell{2}\cell{4}
\cell{\sum_C(x+y)^2 = x^8}
\cell{a^{a^{a^a}}}\cell{1+2+3=£=2+1}
\cell{a}\cell{\frac{1}{1+\frac{1}{1+1}}}
\cell{x+y}\cell{\sum_0^n(x+y)^2 = x^8}
\cell{1+2+3=£=2+1}\cell{A=\begin{pmatrix}1&2\\3&4\end{pmatrix}}
\cell{1+2+3}\cell{\sqrt{\frac{a}{b}}}
\cell{\frac{1}{1+\frac{1}{1+1}}}
\end{tape}

\end{document}

-
Thanks very much! This will be great to get me started, from here I think I will be able to mess around with it until it works. Thanks again. –  user3558855 Jun 18 '14 at 23:28