## LaTeX forum ⇒ Graphics, Figures & Tables ⇒ Greek Symbols in Title of Plot Topic is solved

Information and discussion about graphics, figures & tables in LaTeX documents.
eljee
Posts: 4
Joined: Tue May 11, 2010 1:11 pm

### Greek Symbols in Title of Plot

Hi,

a week or so ago I started using gnuplottex and fell head over heels for it. Now however, we entered a lover's spat.

I'm trying to insert a Greek symbol/letter in my plots but can't seem to get it to work. Is there someone here who has the experience to help me out? I have an example of the code I used below.

Regards,

Eljee

P.S. Not sure whether to mention it or not. I'm using TeX-Live on a Linux Mint 13 system. Using the compiler with a --shell-escape, dvips and ps2pdf to create my files.

\documentclass{article}\usepackage{gnuplottex}\usepackage{graphicx} \begin{document}   \begin{figure}[!ht]     \begin{gnuplot}[scale=0.7, terminal=epslatex]       set title "My title with a $\pi$ or {/Symbol p} symbol."       plot sin(x)     \end{gnuplot}     \caption{Insert a caption for good measure. Symbols work just fine here $\lambda$.}   \end{figure}\end{document}
Last edited by localghost on Tue May 07, 2013 5:23 pm, edited 2 times in total.
Reason: changed code markup from inline to block

Tags:

Johannes_B
Site Moderator
Posts: 4165
Joined: Thu Nov 01, 2012 4:08 pm
A quick search led me to the solution:

\documentclass{article}\usepackage{gnuplottex}\usepackage{graphicx} \begin{document}   \begin{figure}[!ht]     \begin{gnuplot}[scale=0.7, terminal=epslatex]       set title "My title with a $\\pi{}$ or {/Symbol p} symbol."       plot sin(x)     \end{gnuplot}     \caption{Insert a cation for good measure. Symbols work just fine here $\lambda{}$.}   \end{figure}\end{document}

The backslash needs to be escaped in Gnuplot.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

eljee
Posts: 4
Joined: Tue May 11, 2010 1:11 pm
Thanks a lot Johannes,

Of course I did search for a solution online. I must have used the wrong search query. I can imagine that if I ever find another problem with the mixing of either Gnuplot code in LaTeX or the other way around these escapes will work like a charm!

localghost
Site Moderator
Posts: 9204
Joined: Fri Feb 02, 2007 12:06 pm
You can evade such problems by using pgfplots instead. The output of the below code sample is attached.
\documentclass[11pt]{standalone}\usepackage[T1]{fontenc}\usepackage{pgfplots} \pgfplotsset{   compat=newest,   xlabel near ticks,   ylabel near ticks} \begin{document}   \begin{tikzpicture}     \begin{axis}[       title={My title with a $\pi$ symbol},       tick label style={font=\scriptsize}     ]       \addplot[domain=0:2*pi,samples=100] {sin(deg(x))};       \addlegendentry{Sine curve};     \end{axis}   \end{tikzpicture}\end{document}

The package can use Gnuplot as back-end if necessary. For details please refer to the package manual.

Thorsten
Attachments
wtmp.png (5.34 KiB) Viewed 7416 times
LaTeX Community Moderator

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1

Posts: 140
Joined: Thu Jul 16, 2009 12:39 am
eljee wrote:I'm trying to insert a Greek symbol/letter in my plots but can't seem to get it to work.

Actually, all you had to do was change the double-quotes to single-quotes when you set the title:
\documentclass{article}\usepackage{gnuplottex}\usepackage{graphicx} \begin{document}   \begin{figure}[!ht]     \begin{gnuplot}[scale=0.7, terminal=epslatex]       set title 'My title with a $\pi$ symbol.'       plot sin(x)     \end{gnuplot}     \caption{Insert a caption for good measure. Symbols work just fine here $\lambda$.}   \end{figure}\end{document}
System: TeX Live 2012, Fedora 18 x86_64, GNU Emacs 24.2