I want to draw a diagram, composed of boxes and text, using the longtable package. (Perhaps this is a bad idea in the first place, but unless it's really impossible, I'd like to stick with this approach.)
Here is my package, called 'ribbonprooftest.sty', that I have written to do this:
Code: Select all
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{ribbonproof}[2011/02/26 Presenting ribbon proofs.]
\RequirePackage{array}
\newcolumntype{L}{>{$}l<{$}}
\newcolumntype{C}{>{$}c<{$}}
\newcolumntype{R}{>{$}r<{$}}
\RequirePackage{longtable}
\newlength\thickness
\setlength\thickness{1mm}
\newlength\tickheight
\setlength\tickheight{2mm}
\newlength{\tmplength}
\newcommand{\openribbon}[1]{%
\vrule height0mm depth\tickheight width\thickness%
\hspace{-\thickness}%
\vrule height\thickness depth0mm width#1%
\hspace{-\thickness}%
\vrule height0mm depth\tickheight width\thickness%
}
\newcommand{\closeribbon}[1]{%
\raisebox{\thickness}{\vrule height\tickheight depth0mm width\thickness}%
\hspace{-\thickness}%
\vrule height\thickness depth0mm width#1%
\hspace{-\thickness}%
\raisebox{\thickness}{\vrule height\tickheight depth0mm width\thickness}%
}
\newcommand{\retractribbon}[3]{%
\setlength\tmplength{#1}\addtolength\tmplength{\thickness}%
\raisebox{\thickness}{\vrule height\tickheight depth0mm width\thickness}%
\hspace{-\thickness}%
\vrule height\thickness width\tmplength depth0mm%
\hspace{-\thickness}%
\vrule height0mm depth\tickheight width\thickness%
\hspace{-\thickness}%
\hspace{#3}%
\hspace{-\thickness}%
\vrule height0mm depth\tickheight width\thickness%
\hspace{-\thickness}%
\setlength\tmplength{#2}\addtolength\tmplength{\thickness}%
\vrule height\thickness width\tmplength depth0mm%
\hspace{-\thickness}%
\raisebox{\thickness}{\vrule height\tickheight depth0mm width\thickness}%
}
\newcommand{\ribbon}[2]{%
\setlength{\tmplength}{#1}%
\addtolength{\tmplength}{-2\thickness}%
\vrule width\thickness%
\hbox to \tmplength{\hspace{1mm}{#2}}%
\vrule width\thickness%
}
\newenvironment{ribbonproof}{%
\begin{longtable}[l]{L}
}{\end{longtable}}
Code: Select all
\documentclass[12pt,a4paper]{article}
\usepackage{ribbonprooftest}
\title{Test document}
\date{\today}
\begin{document}
\maketitle
\begin{ribbonproof}
\hspace{50mm} \hspace{4mm} \openribbon{30mm} \\
\openribbon{50mm} \hspace{4mm} \ribbon{30mm}{\parbox[t]{23mm}{Hello, this is a long piece of text.}}\\
\ribbon{50mm}{\parbox[t]{42mm}{Some more text, still rather long.}} \hspace{4mm} \ribbon{30mm}{} \\
\retractribbon{28mm}{0mm}{22mm} \hspace{4mm} \ribbon{30mm}{\parbox[t]{20mm}{And even more text!}}\\
\hspace{28mm}\ribbon{22mm}{\mbox{Text.}} \hspace{4mm} \closeribbon{30mm}\\
\openribbon{24mm}\hspace{4mm}\closeribbon{22mm} \\
\ribbon{24mm}{\mbox{Bye bye.}} \\
\end{ribbonproof}
\end{document}
Any help or advice would be much appreciated. Many thanks.
John