Hi, I'm trying to create a diagram/graph that depicts consumer surplus. Is there any way to do this in LateX?
If you don't know what I mean, here's an example:
http://en.wikipedia.org/wiki/Consumer_surplus
I don't need anything as fancy as that, I only need some linear lines and don't need color. What I basically need is something that makes a diagram with two axes, a couple of lines and I need to fill a part of the graph.
Thanks
General ⇒ Create a Consumer-Surplus-kind of diagram
Re: Create a Consumer-Surplus-kind of diagram
PSTricks can do about any kind of graphic. It's an interface between LaTeX and PostScript. Just be aware that you must take the 'LaTeX-> .dvi-> .ps' (actually .eps, as pdfLaTeX doesn't understand .eps files) way. Just a look at the documentation: you have commands such as \psaxes, \psline, \psplot and so on.
Regards,
B.A.
Regards,
B.A.
Create a Consumer-Surplus-kind of diagram
You could use the package pstricks, but then you can't process your document using pdflatex directly (pstricks uses some commands that pdflatex does not recognize). (Edit: balfonsi already suggested this). You could also use the package pgf which unlike pstricks can produce either PostScript or PDF output.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Re: Create a Consumer-Surplus-kind of diagram
Actually, the method I recommend (but it depends on each individual case, of course) is to have separate (short) files for each figure you want. Then compile it to .dvi and convert it to .eps via the command:
dvips -E -o"mygraphicfile.eps"
(under some editors such as WinEdt under windows) this can be automated with a macro).
Finally, I convert the .eps file to a .pdf via eps2pdf (a special interface to ghostscript, which allows to easily convert several files at a time).
To have your figures in the main document, you just have to add the lines:
\beginfigure[!h]
\centering %% if you want to center, of course!
\includegraphics{mygraphicfile}%% no extension!
\end{figure}
This way: 1) you can re-use your file in other documents if necessary; 2) you can either compile with latex (the .eps file will be automatically chosen) or with pdflatex (the .pdf file will be) 3) pstricks has an advantage: there is a command '\psset{unit=...}'; using it, you can scale your figure, without scaling the text contained in it.
To obtain eventually an .eps figure, you must load the extensions pstricks.sty and pst-eps.sty; the description of you figure must be between the following commands:
\TeXtoEPS and \endTeXtoEPS. Here's a simple example, which draws two coordinates axes Ox,Oy:
\TeXtoEPS
\pspicture(-3,-3)(3,3)
\psaxes(0,0)(-3,-3)(3,3)%%the two axes intersect at (0,0), x and y go from -3 to 3
\uput[dl](0,0){$O}\uput[dl](3,0){$x$}\uput[dl](0,3){$y$}
\endpspicture
\endTeXtoEPS
dvips -E -o"mygraphicfile.eps"
(under some editors such as WinEdt under windows) this can be automated with a macro).
Finally, I convert the .eps file to a .pdf via eps2pdf (a special interface to ghostscript, which allows to easily convert several files at a time).
To have your figures in the main document, you just have to add the lines:
\beginfigure[!h]
\centering %% if you want to center, of course!
\includegraphics{mygraphicfile}%% no extension!
\end{figure}
This way: 1) you can re-use your file in other documents if necessary; 2) you can either compile with latex (the .eps file will be automatically chosen) or with pdflatex (the .pdf file will be) 3) pstricks has an advantage: there is a command '\psset{unit=...}'; using it, you can scale your figure, without scaling the text contained in it.
To obtain eventually an .eps figure, you must load the extensions pstricks.sty and pst-eps.sty; the description of you figure must be between the following commands:
\TeXtoEPS and \endTeXtoEPS. Here's a simple example, which draws two coordinates axes Ox,Oy:
\TeXtoEPS
\pspicture(-3,-3)(3,3)
\psaxes(0,0)(-3,-3)(3,3)%%the two axes intersect at (0,0), x and y go from -3 to 3
\uput[dl](0,0){$O}\uput[dl](3,0){$x$}\uput[dl](0,3){$y$}
\endpspicture
\endTeXtoEPS