Graphics, Figures & TablesReversing Arrows

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
jomike
Posts: 5
Joined: Wed Nov 14, 2012 10:42 pm

Reversing Arrows

Post by jomike »

Dear all,

preparing a presentation, I have a small problem in practice, but not for my nerves. :(

I constructed a graph. It consists of two circles, A and B, connected by two arrows. One points from circle A to B, the other should point the other way round, from B to A. How can I reverse it?

Here the code:

Code: Select all

\begin{pgfpicture}{0cm}{0cm}{5cm}{0.1cm}
\pgfputat{\pgfxy(3,1.5)}{\pgfbox[center,center]{A}}
\pgfcircle[stroke]{\pgfxy(3,1.5)}{1cm}
\pgfsetendarrow{\pgfarrowto}
\pgfxycurve(3.75,2.5)(4.5, 3)(5.5,3)(6.25,2.5)
\pgfputat{\pgfxy(7,1.5)}{\pgfbox[center,center]{B}}
\pgfcircle[stroke]{\pgfxy(7,1.5)}{1cm}
\pgfsetendarrow{\pgfarrowto}
\pgfxycurve(3.75,0.5)(4.5, 0)(5.5,0)(6.25,0.5)
\end{pgfpicture}
I would appreciate a lot to get your help!


Greetings,
jomike
Last edited by localghost on Wed Feb 27, 2013 12:40 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Reversing Arrows

Post by localghost »

Seems to be much easier if you use tikZ as a front-end to pgf.

Code: Select all

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}
  \begin{tikzpicture}[
    >=stealth,
    shorten >=6pt,
    shorten <=6pt
  ]
    \node[draw,circle,minimum size=6em] (A) at (0,0) {A};
    \node[draw,circle,minimum size=6em,right=3 of A] (B) {B};

    \path[->] (A) edge[bend left=30] (B)
              (B) edge[bend left=30] (A);
  \end{tikzpicture}
\end{document}
For details see the manual.


Thorsten
jomike
Posts: 5
Joined: Wed Nov 14, 2012 10:42 pm

Re: Reversing Arrows

Post by jomike »

Thanks, Thorsten, for your reply and the solution!

But isn't there a simple solution to this problem if I stayed within the pgf package?
I already added some other details to the picture, so that I'm not keen on learning the tikz package to build everything from the beginning onwards.

A simple change in the command to reverse this arrow?

Would be of huge help to me!

Greetings,

jomike
jomike
Posts: 5
Joined: Wed Nov 14, 2012 10:42 pm

Reversing Arrows

Post by jomike »

Now, I've got it.

One has to place \pgfclearendarrow after having entered \pgfsetendarrow{\pgfarrowto} in order to "close" the command.

I didn't understand why I couldn't determine the direction of the arrow by changing "start" and "end" in the command.

Code: Select all

\pgfsetstartarrow{\pgfarrowto}
\pgfsetendarrow{\pgfarrowto}
Solution:
Just use \pgfsetstartarrow{\pgfarrowto}, followed by the further specification of the arrow shape, for example:

Code: Select all

\pgfxycurve(3.5,0.5)(4.5, -0.25)(5.5,-0.25)(6.5,0.5)
Then finish the arrow by using \pgfclearendarrow.

Thanks for your help anyway, Thorsten. This post now might help people dealing with both, the tikz and the pgf package.

*jomike
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Reversing Arrows

Post by localghost »

jomike wrote:[…] But isn't there a simple solution to this problem if I stayed within the pgf package? […] A simple change in the command to reverse this arrow? […]
No idea. At the moment I neither have the time nor do I see the necessity for me to read up on the basic layer if I can comfortably use a front-end. But as I can see you have found a solution on your own. Thanks for sharing.
Post Reply