LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux > Linux - General
User Name
Password
Linux - General This forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Thread Tools
Old 11-07-2009, 09:24 PM   #1
sycamorex
Senior Member
 
Registered: Nov 2005
Location: London
Distribution: Slackware 13 32/64
Posts: 1,654
Thanked: 75
which terminal to use with gnuplot to work with pdf latex


[Log in to get rid of this advertisement]
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
linuxslackware sycamorex is offline     Reply With Quote
Old 11-08-2009, 05:15 AM   #2
b0uncer
Senior Member
 
Registered: Aug 2003
Location: fin
Distribution: (B)LFS, Ubuntu, Slackware
Posts: 4,853
Thanked: 27
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).

Last edited by b0uncer; 11-08-2009 at 05:20 AM..
b0uncer is offline     Reply With Quote
Thanked by:
Old 11-08-2009, 08:39 AM   #3
sycamorex
Senior Member
 
Registered: Nov 2005
Location: London
Distribution: Slackware 13 32/64
Posts: 1,654
Thanked: 75

Original Poster
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}
linuxslackware sycamorex is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
gnuplot svg terminal problem sreejithpk Linux - Software 6 03-18-2009 12:24 PM
no x11 terminal in gnuplot 4.0.0 polzbert Linux - Software 1 01-10-2006 05:54 AM
gnuplot cant detect terminal trylinux Linux - Software 3 02-17-2005 05:02 AM
pdf--->> latex, graphics possible? realos Linux - General 2 05-31-2004 05:50 AM
LaTeX to pdf kwigibo Linux - General 2 01-04-2003 08:44 PM


All times are GMT -5. The time now is 08:46 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration