Drawing graphs with IPE

8,872

Solution 1

You should use \includegraphics[width=…]{Tree1.eps} or \includegraphics[scale=…]{Tree1.eps}. The epsfig package is obsolete and should be replaced with graphicx.

That said, it is rather simple to obtain the above graph with pstricks, and more specifically with pst-node. Further, you can compile the code with pdflatex, loading auto-pst-pdf and compiling with the --enable-write18 switch under MiKTeX, or -shell-escape under TeX Live and MacTeX. This way your image is in pdf format.

Here is a code with the .png image posted in the question, and with the .pdf image compiled as standalone:

\documentclass[12pt]{article}
\usepackage{graphicx}

\begin{document}
    \[ a = b + c \quad\includegraphics[width=15pt]{Tree1.png} \]%
    \[ a = b + c \quad\includegraphics[width=15pt]{Tree1.pdf} \]%
\end{document}

Graphics with width in math mode

The pstricks code:

\documentclass[ x11names]{standalone}
\usepackage{pstricks-add,auto-pst-pdf}%

\begin{document}

\psset{yunit=0.8, dotsize=8pt}

\begin{postscript}
\dotnodes(0,0){O}(2.5,0){A0}(2.5,1){A1}(2.5,2){A2}(1.7,3){B}(3.3,3){C}
\psline(A0)(A2)(B)\psline(A2)(B)\psline(A2)(C)
\nccircle[angle = 180]{O}{0.4}
\psset{linestyle=dashed, dash=6pt 5pt}
\nccircle{B}{0.4}
\ncarc[arcangleA=-20, arcangleB=-30]{A1}{C}
\ncarc[arcangleA=40, arcangleB=60]{O}{B}
\end{postscript}

\end{document} 

Solution 2

The general way of using Ipe seems to be that you enter any LaTeX elements directly into the editor where they are rendered. You can position the rendered elements in the same way as text nodes (using the 'translate' mode).

enter image description here

If you need any packages for the inline LaTeX you can list them in Edit-Document properties under Latex preamble.

Then, in your main LaTeX document, you can use \includegraphics from the graphicx package to add the eps figure you exported from Ipe (instead of epsfbox). The scale can be set in \includegraphics. You can find many examples of this on TeX.SE and elsewhere. MWE:

\documentclass{article}
\usepackage{graphicx}
\begin{document}
No scaling:

\includegraphics{ipegraph.eps}

Scale by factor 0.5:

\includegraphics[scale=0.5]{ipegraph.eps}

Scale by absolute width:

\includegraphics[width=5cm]{ipegraph.eps}
\end{document}

Result:

enter image description here

Share:
8,872

Related videos on Youtube

Adrien Laurent
Author by

Adrien Laurent

PhD student at the University of Geneva. I work on stochastic numerical analysis and am also interested in other fields of mathematics.

Updated on February 27, 2020

Comments

  • Adrien Laurent
    Adrien Laurent over 3 years

    I am trying to draw certain types of graphs in latex, and want to use them in mathematical expressions. I already used a lot the software IPE (found here http://ipe.otfried.org/). It allows me to draw perfectly what i want. Here is an example :

    A graph

    I include these pictures in Latex using epsfbox :

    \usepackage{epsfig} \begin{document} \epsfxsize=X ex \epsfbox{Tree1.eps} \end{document}

    X is the size of my item.

    Now, here are my problems : First, i can't master the size of the item in Latex. Is there a way to obtain the size in any unity of the object i create in IPE?

    Then i can't choose how to position the item in formulas. For the example i drew earlier, i would like the bottom nodes to be on the same height as the mathematical symbols.

    I have tried to draw directly those graphs using Latex, but drawing curves is terribly hard! And I do not have the time to draw my dozens of graphs using this method...

    Any help would be greatly appreciated !

    • Martin Schröder
      Martin Schröder about 7 years
      Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format.
  • Adrien Laurent
    Adrien Laurent about 7 years
    I should have done that from the beginning. epsfbox just brought problems. Thanks!
  • Adrien Laurent
    Adrien Laurent about 7 years
    Thanks for your answer. There is much more than I need but it really helps! Two more questions maybe : what does \documentclass[ x11names]{standalone} means. I do not know this document class. And why do i need to change Miktex to run the package auto-pst-pdf?
  • Bernard
    Bernard about 7 years
    The standalone class produces graphic files with a bounding box. The x11names should have been deleted (I started from an old code). For you information, pstricks loads the xcolor package, without option. If I load it with this option, there well be an option clash message. Declaring the option with the class is a way to avoid this option clash. For the last question, you have to change the way pdflatex is launched from your editor. This parameter is not set by default for security reasons. It allows to delegate a task to an external application, then resume compilation.
  • Struggler
    Struggler over 3 years
    @Marijin: I am drawing some figure in IPE and I want to draw a dashed line. How I can draw it. Also, I want to text bold letters in IPE but I did not saw the options of bold alphabets in IPE.
  • Marijn
    Marijn over 3 years
    @Struggler it would be best if you ask a new question about this (using the Ask Question button on the top of the screen).
  • MariyaKav
    MariyaKav almost 3 years
    Do you know how can I use \overbrace commant in IPE?
  • Marijn
    Marijn almost 3 years
    @MariyaKav in the 'Edit text object' window you can type something like \overbrace{a+b}. If you can't make it work then it is better to ask a new question however, instead of posting a comment in another question.
  • Turing101
    Turing101 over 2 years
    Hi @Marijn, I am new to IPE, and sometimes I have to draw a large image that does not fit in a single page of IPE, but I am not able to increase the size of page. Any idea how can I do so? I have asked my question here tex.stackexchange.com/questions/599418/…