X
123 Rate this article:
No rating

How to include mathematical symbols or Greek letters in a text string using IDLgrPDF

Anonym

This help article is about how to generate mathematical symbols or Greek letters such as „less than or equal“ and „greater than or equal“ while using IDLgrPDF and any font.

Although it seems fairly easy to use these symbols, it is somewhat tricky to use them with any other font than “symbols”.

In this example we want to use the symbols “≤” and “≥” as well as the Greek letters for "lambda" and "alpha" and write them to a PDF using the font HELVETICA.

A list of all possible symbols and their corresponding TeX-like syntax can be found here (scroll down to the section entitled "Adding Mathematical Symbols and Greek Letters to the Text String"):

http://www.exelisvis.com/docs/TEXT.html 

To use a symbol of this list, it has to be surrounded by “$”. To include this functionality in a text string you have to use the internal function Tex2IDL:

  oTxt = IDLgrText(Tex2IDL('$\geq  \leq  \lambda  \alpha$'), $

 /ENABLE_FORMATTING)

Display the result:

  xobjview, oTxt

Using the font HELVETICA and setting the output to PDF:

 oPDF = OBJ_NEW('IDLgrPDF')

 oPDF->SetProperty, UNITS=2, RESOLUTION=[1.0,1.0]

 oPDF->AddPage, DIMENSIONS=[21.029.7]

 oPDF->SetProperty, LOCATION=[1,1], DIMENSIONS=[19.028]

 

 oView  = OBJ_NEW('IDLgrView', UNITS=2, $

 VIEWPLANE_RECT=[0.0,0.0,19.0,28])

 oModel = OBJ_NEW('IDLgrModel')

 oView->Add, oModel

 

 oFont = OBJ_NEW('IDLgrFont', SIZE=12.0, 'Helvetica')

 oText = IDLgrText(Tex2IDL('$\geq    \leq    \lambda    \alpha$'), $ 

 FONT=oFont, LOCATION=[0.0,27.0,0.0], /ENABLE_FORMATTING)

 oModel->Add, oText

 oPDF->Draw, oView

 oPDF->Save, 'C:\Users\User\Output\ShowFontPdftest.pdf'

 ONLINE_HELP, BOOK='C:\Users\User\Output\ShowFontPdftest.pdf'

 

The result looks as follows:

 

NoteThis is not about including any of these symbols in a graphic/plot but about using them in a text string.

 

Reviewed by ZN 6/24/2015