# Arrow-shaped text boxes (for use in ipe vector graphics editor)?

## Ipe vector graphics editor

I am currently evaluating the ipe vector graphics editor. A very attractive feature is that one can use LaTeX-commands inside its text objects as long as these are legal inside a \makebox (for labels) or inside a minipage (for minipages). However, one cannot use commands that involve a non-linear translation into PDF, such as commands to generate hyperlinks or to include external images. Nonetheless, LaTeX-commands that are defined in additional LaTeX packages can be included with a \usepackage command in the LaTeX preamble, which can be set in Document properties under the Edit menu.

## Question

What I am looking for is a way to enclose text inside a left or right arrow-shaped box with LaTeX-commands in ipe? A simple LaTeX package that would create text boxes much like rarrow and larrow of the BoxStyle class in matplotlib (see below specimen) would do just fine. Other techniques are welcome too. LibreOffice Impress and PowerPoint also offer such arrow shapes with text, even curved ones.

## Attempts

1. Drawing an \fbox around a text object in ipe works flawlessly. Even a rotated \ovalbox with math constitutes no problem with \usepackage{rotating, fancybox} in the preamble. There are no arrows in fancybox, though.
2. I looked for a LaTeX package providing arrow-shaped boxes among the packages listed among "boxing" on CTAN. Perhaps I am looking over it, but no such package appears to be listed.
3. Everybody here seems to use TikZ arrows, so I tried this example and this example inside ipe. The result of these failed TikZ experiments is shown in the bottom image. It fails because of the ipe LaTeX text object limitations mentioned earlier.

## TikZ arrows do not work in ipe

• There is a TikZ library shapes.arrows. Then \node[single arrow, draw] (a) {Arrow}; typesets the word Arrow in an arrow shaped box, but I'm pretty sure this won't work in ipe. – Henri Menke May 8 '14 at 12:43
• @HenriMenke TikZ is what I tried, but indeed it does not work in ipe. I am just amazed that there seems to be nothing else but TikZ to place text in an arrow... – Serge Stroobandt May 8 '14 at 12:47
• I'm pretty sure there is also something for pstricks, but this won't work in ipe either ;) – Henri Menke May 8 '14 at 12:51

Here's an "arrow box" macro based on LaTeX picture mode. Maybe this will work for you?

\documentclass{article}

\makeatletter
\newdimen\ab@texttotalheight
\newdimen\ab@arrowstemwidth
\newdimen\ab@arrowwidth
\newdimen\ab@arrowstemheight
\newdimen\ab@arrowheight
\newcommand\rightarrowbox{\@arrowbox+}
\newcommand\leftarrowbox{\@arrowbox-}
\newcommand\@arrowbox[2]
{%
\begingroup
\setbox\@tempboxa=\hbox{#2}%
\ab@texttotalheight\dimexpr\ht\@tempboxa+\dp\@tempboxa\relax
\ab@arrowstemwidth\dimexpr\wd\@tempboxa\relax
\ab@arrowstemheight\dimexpr2\fboxsep+\ab@texttotalheight\relax
\ab@arrowheight\dimexpr4\fboxsep+\ab@texttotalheight\relax
\thicklines
\unitlength\p@
\edef\@temp{{picture}(\strip@pt\ab@arrowwidth,\strip@pt\ab@arrowheight)\if#1-(-\strip@pt\ab@arrowwidth,0)\fi}%
\expandafter\raisebox\expandafter{\the\dimexpr-\dp\@tempboxa-2\fboxsep\relax}
{%
\expandafter\begin\@temp
\put(#1\strip@pt\@halfwidth,\strip@pt\fboxsep){\line(0,1){\strip@pt\ab@arrowstemheight}}
\@tempdima\dimexpr2\fboxsep+\dp\@tempboxa\relax
\@tempdimb\if#1-\dimexpr\fboxsep+\wd\@tempboxa\relax\else\fboxsep\fi\relax
\put(#1\strip@pt\@tempdimb,\strip@pt\@tempdima){\box\@tempboxa}
\@tempdima\dimexpr3\fboxsep+\ab@texttotalheight\relax
\@tempdimb\dimexpr\ab@arrowstemwidth+\@halfwidth\relax
\put(0,\strip@pt\@tempdima){\line(#11,0){\strip@pt\@tempdimb}}
\put(0,\strip@pt\fboxsep){\line(#11,0){\strip@pt\@tempdimb}}
\put(#1\strip@pt\ab@arrowstemwidth,\strip@pt\@tempdima){\line(0,1){\strip@pt\fboxsep}}
\put(#1\strip@pt\ab@arrowstemwidth,0){\line(0,1){\strip@pt\fboxsep}}
\end{picture}%
}%
\endgroup
}
\begin{document}

\leftarrowbox{\Large\textsf{foo}} \rightarrowbox{\Large\textsf{foo}}
\fbox{\Large\textsf{foo}}

\bigskip

\leftarrowbox{\Large\textsf{goo}} \rightarrowbox{\Large\textsf{goo}}
\fbox{\Large\textsf{goo}}

\bigskip
\leftarrowbox{\Large\textsf{\strut foo}} \rightarrowbox{\Large\textsf{\strut goo}}

\bigskip

\leftarrowbox{\Large\textsf{\begin{tabular}{l}foo\\goo\end{tabular}}}
\rightarrowbox{\Large\textsf{\begin{tabular}{l}foo\\goo\end{tabular}}}
\fbox{\Large\textsf{\begin{tabular}{l}foo\\goo\end{tabular}}}

\end{document}


Output:

EDIT

As OP, I have added above preamble to ipe, together with an additional \usepackage{rotating}. The ipe text object only contains the following in order to generate the tilted text arrow:

\begin{turn}{56}
\rightarrowbox{\Large\textbf{yahoo!}}
\end{turn}


• As for myself and me uses, this is exactly why I'm glad technologies like TikZ, PSTricks, and Metapost actually exist. +1 for extreme effort! You might want to add a strut though to account for the 'varying' baseline between foo and goo. – Sean Allred May 8 '14 at 15:26
• @SeanAllred The idea was to make it similar to \fbox which also behaves like this. Also, if you use it with a table or \parbox, the \strut might get in the way. Speaking of which, maybe I should lower the picture so the text sits on the baseline, to make it even more like \fbox. But first I'll need some evidence someone would use it :-) – Stephan Lehmke May 8 '14 at 15:40
• Haha! Well, I'm fine with the computer putting forth a reasonable effort :) And I imagine trying to make this solution more and more robust is just going to end in sadness. – Sean Allred May 8 '14 at 15:46
• @SergeStroobandt I have edited the code to remove the glitches. However, I think from a LaTeX consistency perspective it's really better to be as near to \fbox as possible. I don't understand your spacing argument. The space above "f" and below "g" are equal, aren't they? – Stephan Lehmke May 8 '14 at 16:46
• @SergeStroobandt I see you have already acted on what I was going to suggest: As everything posted here is published under CC license, you're free to contribute the code yourself (which I hereby explicitly give permission to :-) – Stephan Lehmke May 8 '14 at 21:17