2

I am drawing arrows in a block diagram and using decorations.text to label them. Arrows going left to right are fine: the labels are upright. But arrows going right to left are appearing upside down.

For example:

\documentclass{article}
\usepackage{tikz}
\usepackage[graphics, active, tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\usetikzlibrary{positioning, arrows.meta, bending, decorations.text}
\begin{document}
\begin{tikzpicture}
\node (aa) at (0,0) {A};
\node (bb) [right= 5cm of aa] {B};
\draw [-latex] [postaction={
    decoration={text along path, text align=center, raise={1em},
        text={Hello World}}, decorate
        }]
    (aa) to [bend right=45] (bb);
\draw [-latex] [postaction={
    decoration={text along path, text align=center, raise={1em},
        text={Goodbye World}}, decorate}]
    (bb) to [bend right=45] (aa);
\end{tikzpicture}
\end{document}

How does one get "Goodbye World" to appear right side up? (I know I can use latex- to reverse the arrows, but in a complex drawing I'd prefer to draw the arrows the way flows actually happen in my model.)

  • 1
    You forgot the most important node: the document around this fragment of code ;-) – user31729 May 22 '15 at 16:35
2

You can add reverse path to the edge options. By the way, I suggest you start using the standalone class, which is very handy for typesetting single tikzpictures. It even has the options tikz (loads the package) and preview. See the link to the manual for more details (class is on page 7).

Edit: As A.Ellett rightfully pointed out, ex measurement is usually adopted for vertical shifting and em for horizontal shifting.

Output

enter image description here

Code

\documentclass[tikz,margin=15pt]{standalone}
\usetikzlibrary{positioning, arrows.meta, bending, decorations.text}

\begin{document}
\begin{tikzpicture}
\node (aa) at (0,0) {A};
\node (bb) [right= 5cm of aa] {B};
\draw [-latex] [postaction={
    decoration={text along path, text align=center, raise={1ex},
        text={Hello World}}, decorate
        }]
    (aa) to [bend right=45] (bb);
\draw [-latex] [postaction={
    decoration={text along path, text align=center, raise={-2.5ex},reverse path,
        text={Goodbye World}}, decorate}]
    (bb) to [bend right=45] (aa);
\end{tikzpicture}
\end{document}
  • We posted almost simultaneously. :-) – A.Ellett May 22 '15 at 17:08
  • @A.Ellett Ahah yes. I had finished the answer some minutes ago, I was just writing the stuff about the standalone class. I can delete my answer and post that part as a comment if you prefer. – Alenanno May 22 '15 at 17:08
  • Doesn't matter to me. I think the OP wanted the text under the curve. If you modify your solution to include that I'll delete mine. I think it's also important to point out the non-standard use of em to place things vertically. – A.Ellett May 22 '15 at 17:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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