0

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 !

2

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} 
  • 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? – Adrien Laurent Oct 31 '16 at 13:37
  • 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. – Bernard Oct 31 '16 at 13:56
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

  • I should have done that from the beginning. epsfbox just brought problems. Thanks! – Adrien Laurent Oct 31 '16 at 13:33

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.