LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   which terminal to use with gnuplot to work with pdf latex (https://www.linuxquestions.org/questions/linux-general-1/which-terminal-to-use-with-gnuplot-to-work-with-pdf-latex-767608/)

sycamorex 11-07-2009 08:24 PM

which terminal to use with gnuplot to work with pdf latex
 
I'm trying to embed some gnuplot graphs into pdflatex documents. I've had no luck so far. Which terminal is best for pdflatex?

Thank you

b0uncer 11-08-2009 04:15 AM

There are more than one way I recall, depending on if you are OK with the plain Gnuplot result, or if you want some "extra" like LaTeX symbols into the graphs. If you run
Code:

set terminal
in Gnuplot, you'll see what it can do (probably you knew this already), if you want to try out some of them. It would be nice to have it output .pdf as these you could embed in a (pdf)LaTeX document, but it won't, without a "get-around".

Personally I need to have some symbols in the plots that Gnuplot doesn't know how to do. For this I use a little "trick" I read from someone's website long time ago: I set the output terminal to be "epslatex" and write the symbols in the Gnuplot file as in LaTeX (for example \Delta into a title). This produces two files: a .tex file and a .eps file, the other containing the symbols and the other the plot, without symbols. Then I use a minimal (pdf)LaTeX document to combine these two by inputting the .tex file, which results in a .pdf file containing both the plot and the symbols. I'm not doing anything fancy here, so the resulting file is sized A4, whereas the plot itself is typically smaller, so then I still need to use pdfcrop to "cut" the plot out to form a .pdf that contains only the plot (with symbols) and is properly sized, which I can them put in a (pdf)LaTeX document like any other .pdf image.

This sounds like awfully lot of work, but it didn't take long for me to write a script that automates most of the work. Now I only need to make the Gnuplot work in a .gp file as I usually do and setting the output terminal to 'epslatex'. Then I run the script and give it the .gp file as an argument (and the output .tex/.eps filename as well, though I usually do this so that it's the same as the .gp filename without suffix -- less writing, less work), and the script runs it through Gnuplot, makes a temporary (pdf)LaTeX file to combine the resulting files, crops the produced .pdf and removes temporary files before exiting, so that the overall result is just the .pdf file (.gp preserved), nothing else. Pretty neat (though the script is a little ugly as of now..but it works).

sycamorex 11-08-2009 07:39 AM

Thanks, I managed to get it work with 'epslatex'. Could you possibly post your script, please? I'm sure I'll benefit from it.

btw, this is how I embed it in a .tex file:
Code:

\documentclass[11pt,twoside,a4paper]{article}
\usepackage{graphicx}
\begin{document}
\begin{figure}
  \begin{center}
    \scalebox{1.0}{\input{plot.tex}}
  \caption{My caption}
  \end{center}
\end{figure}
\end{document}


mtrummer 02-15-2011 06:25 AM

gnuplot and latex
 
Hello,

I embedd many gnuplot figures in my latex files. The way I do this is by first using the postscript terminal, and then by converting the eps files to pdf, in order to be able to use them with pdflatex. This works just fine. The problem I have now is that I use the gnuplot symbols 24, 25 and 27 of the postscript pointtypes (half-filled circle, ...). Since I do not like having these symbols with an explanation in the key of the figure, I use latex captions to describe them instead. How do I produce these symbols with pdflatex?

Thanks for your help.


All times are GMT -5. The time now is 10:37 PM.