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 create a sort of text box, path you maybe want to call it, using TikZ, which has the shape of a triangle. I then want the text follows the hypotenuse of the triangle.

    /
   / The text follows the
  / the Path of the
 / hypotenuse 
/    

How do I make this possible, using TikZ? At the moment I'm just defining three nodes and using xshift I align every line with the the hypotenuse.

UPDATE

I had to be a bit more clear about defining the text, but the text should be defined in one instance so \text{The text follows the \\ the path of the \\ hypotenuse}

This just came up with me but the text in the 'textbox' should also have justification. So the image would maybe look more like...

    /                  |
   / This is some text |
  / this    is    also | <-- line is justified
 / hypotenuse          |
/                      |
share|improve this question
    
Sort of vaguely relevant: tex.stackexchange.com/a/28982/86 –  Andrew Stacey Jun 14 '12 at 10:55
add comment

1 Answer

up vote 11 down vote accepted

If the text is not long, then, you can get away without defining a paragraph shape via decoration.

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\begin{document}

\begin{tikzpicture}[mystyle/.style args={#1 at #2}{
            decoration={
                  markings,
                  mark=at position #2 with {
                      \node[anchor=west,xshift=5pt]{#1};}
                  },
            postaction={decorate}
            }
    ]
    \draw[%
          mystyle=Some Text  at 0.2,
          mystyle={some text with \textit{at} in it} at 0.4
         ] (0,0) -- (3,3);
\end{tikzpicture}

\end{document}

enter image description here

EDIT If the text is not short and requires some effort with the above method then we have to define a paragraph shape. I defined a simple shape and put the resulting paragraph into a node on the line by anchoring it from its left side. Here is the result:

\documentclass{article}
\usepackage{tikz,shapepar}
\newcommand{\myparshape}{
{5}
{0}b{5}\\ 
{0}t{5}{5}\\ 
{5}t{0}{10}\\ 
{5}e{0}
}

\begin{document}
\begin{tikzpicture}

  \draw (0,0) -- (5,5);
  \node[anchor=west,xshift=-1cm] at (2.5,2.5) {\begin{minipage}{0.5\textwidth}
        \Shapepar{\myparshape} Some ridiculous text to fill 
        up this space. I could have used lipsum or kantlipsum packages to generate 
        this but I thought those would give me longer paragraphs then I would need. 
        Then again I wouldn't worry too much.
        \end{minipage}
    };

\end{tikzpicture}
\end{document}

enter image description here

share|improve this answer
    
Hmmm not quiet the solution I was looking for because I now implemented it in a similar fashion. Maybe I had to be a bit more clear about the text, but I want the text to be able to be defined in a single instance. Let me clarify that -- The code has to output the same way as your picture but going to a newline should just be easy as using \\ \draw[mystyle={Some text with \textit{at} in it \\ Some Text}. It would also be nice if the text in the textbox would have full justification in it. I will explain this in my question. –  WG- Jun 14 '12 at 10:58
    
@Wouter Is it better now? –  percusse Jun 14 '12 at 12:11
    
awesome! That was exactly what I was looking for! I will try to implement your result now :-) –  WG- Jun 14 '12 at 12:36
add comment

Your Answer

 
discard

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.