Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to take text and wrap it around as the border of a figure. That is, text on the top, wrapping to sideways text running down the right, wrapping to upside down text on the bottom, wrapping to sideways text on the left. This isn't just a request for text-wrap, but instead a custom border.

This may be an odd request, but I'm curious if it is possible (or relatively easy since it's possible to hack together something). I have a feeling, if I actually want to do this, it will have to be through manually setting each side up.

share|improve this question
Welcome to TeX.SX! –  Heiko Oberdiek Apr 18 '14 at 21:07
@HeikoOberdiek Thank you! Long time searcher, first time asker. This community is very helpful. –  Poik Apr 18 '14 at 21:16

1 Answer 1

up vote 8 down vote accepted

One option using the text along path decoration from TikZ:



\node[inner sep=0pt,text width=4cm,minimum height=3cm]
  decoration={text along path,raise=2pt,
  text={This is a some text that will be typeset around an image. More text to complete the path.}}
  (image.north west) --
  (image.north east) --
  (image.south east) --
  (image.south west) --


enter image description here

Some restrictions apply, though, as can be read in section 48.6 Text Decorations of the PGF manual:

pgf "does its best" to typeset the text, however you should note the following points:

• Each character in the text is typeset in a separate \hbox. This means that if you want fancy things like kerning or ligatures you will have to manually annotate the characters in the decoration text within a group, for example, W{\kern-1ptA}TER.

• Each character is positioned using the center of its baseline. To move the text vertically (relative to the path), the additional transform key should be used.

• No attempt is made to ensure characters do not overlap when the angle between segments is considerably less than 180◦ (this is tricky to do in TEX without a huge processing overhead). In general this should not be too much of a problem, but, once again, kerning can be used in most cases to overcome any undesirable effects.

• It is only possible to typeset text in math mode under considerable restrictions. Math mode is entered and exited using any character of category code 3 (e.g., in plain TeX this is $). Math subscripts and superscripts need to be contained within braces (e.g., {^y_i}) as do commands like \times or \cdot. However, even modestly complex mathematical typesetting is unlikely to be successful along a path (or even desirable).

• Some inaccuracies in positioning may be particularly apparent at input segment boundaries. This can (unfortunately) only be solved on a case-by-case basis by individually kerning the offending characters within a group.

share|improve this answer
I was looking at TikZ, and I may end up using this, but I'd rather have the text bordering a figure environment. I'll probably save the figure to an image and use it with this if I can't find better. Thank you! –  Poik Apr 18 '14 at 21:24
@Poik Why do you want the figure to float but not its border? Won't that look a bit odd? –  cfr Apr 19 '14 at 0:47
@Poik in the same line as cfr's comment, it woudn't make much sense to place the border around the figure environment (since it is a floating object); you, however, can place the frame around its contents, and since a TikZ node can contain pretty much anything you want (except for some exceptions such as floats), then you can apply the approach in the answer. Perhaps if you tell us specifically what are you trying to frame, we could suggest you alternatives. –  Gonzalo Medina Apr 19 '14 at 1:02
Whoop. Yes, not the figure environment. You're right, that is silly. I have a well formatted page worth of text and the like that I would like to surround with that. I misunderstood and thought the format you had required a picture, until I looked again. This indeed is exactly what I'm looking for. –  Poik Apr 20 '14 at 0:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.