LaTeX forum ⇒ Graphics, Figures & TablesGreek Symbols in Title of Plot Topic is solved

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

Greek Symbols in Title of Plot

Postby eljee » Tue May 07, 2013 12:24 am

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.

  1. \documentclass{article}
  2. \usepackage{gnuplottex}
  3. \usepackage{graphicx}
  4.  
  5. \begin{document}
  6. \begin{figure}[!ht]
  7. \begin{gnuplot}[scale=0.7, terminal=epslatex]
  8. set title "My title with a $\pi$ or {/Symbol p} symbol."
  9. plot sin(x)
  10. \end{gnuplot}
  11. \caption{Insert a caption for good measure. Symbols work just fine here $\lambda$.}
  12. \end{figure}
  13. \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:

User avatar
Johannes_B
Site Moderator
Posts: 4165
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Tue May 07, 2013 7:10 am

A quick search led me to the solution:

  1. \documentclass{article}
  2. \usepackage{gnuplottex}
  3. \usepackage{graphicx}
  4.  
  5. \begin{document}
  6. \begin{figure}[!ht]
  7. \begin{gnuplot}[scale=0.7, terminal=epslatex]
  8. set title "My title with a $\\pi{}$ or {/Symbol p} symbol."
  9. plot sin(x)
  10. \end{gnuplot}
  11. \caption{Insert a cation for good measure. Symbols work just fine here $\lambda{}$.}
  12. \end{figure}
  13. \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.

User avatar
eljee
Posts: 4
Joined: Tue May 11, 2010 1:11 pm

Postby eljee » Tue May 07, 2013 11:31 am

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!

User avatar
localghost
Site Moderator
Posts: 9204
Joined: Fri Feb 02, 2007 12:06 pm

Postby localghost » Tue May 07, 2013 4:56 pm

You can evade such problems by using pgfplots instead. The output of the below code sample is attached.
  1. \documentclass[11pt]{standalone}
  2. \usepackage[T1]{fontenc}
  3. \usepackage{pgfplots}
  4.  
  5. \pgfplotsset{
  6. compat=newest,
  7. xlabel near ticks,
  8. ylabel near ticks
  9. }
  10.  
  11. \begin{document}
  12. \begin{tikzpicture}
  13. \begin{axis}[
  14. title={My title with a $\pi$ symbol},
  15. tick label style={font=\scriptsize}
  16. ]
  17. \addplot[domain=0:2*pi,samples=100] {sin(deg(x))};
  18. \addlegendentry{Sine curve};
  19. \end{axis}
  20. \end{tikzpicture}
  21. \end{document}

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


Thorsten
Attachments
wtmp.png
wtmp.png (5.34 KiB) Viewed 7416 times
LaTeX Community Moderator
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


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

User avatar
shadgrind
Posts: 140
Joined: Thu Jul 16, 2009 12:39 am

Postby shadgrind » Tue May 14, 2013 11:49 pm

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:
  1. \documentclass{article}
  2. \usepackage{gnuplottex}
  3. \usepackage{graphicx}
  4.  
  5. \begin{document}
  6. \begin{figure}[!ht]
  7. \begin{gnuplot}[scale=0.7, terminal=epslatex]
  8. set title 'My title with a $\pi$ symbol.'
  9. plot sin(x)
  10. \end{gnuplot}
  11. \caption{Insert a caption for good measure. Symbols work just fine here $\lambda$.}
  12. \end{figure}
  13. \end{document}
System: TeX Live 2012, Fedora 18 x86_64, GNU Emacs 24.2


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 3 guests