Greek alphabet and latex commands [not a question]

583 views (last 30 days)
Capital letters are obtained by capitalizing the LaTeX command for the lowercase version. Capital letters in grey are exceptions which have no LaTeX commands. For example, to produce a capital chi simply type X (this also applies for the lowercase omicron).
When two versions of the lowercase letter are available, a var prefix can be added to obtain the second version. For example, the two versions of epsilon are \epsilon and \varepsilon.
The code used to generate the table:
greeks = ...
{'ALPHA' 'A' '\alpha'
'BETA' 'B' '\beta'
'GAMMA' '\Gamma' '\gamma'
'DELTA' '\Delta' '\delta'
'EPSILON' 'E' {'\epsilon','\varepsilon'}
'ZETA' 'Z' '\zeta'
'ETA' 'H' '\eta'
'THETA' '\Theta' {'\theta','\vartheta'}
'IOTA' 'I' '\iota'
'KAPPA' 'K' '\kappa'
'LAMBDA' '\Lambda' '\lambda'
'MU' 'M' '\mu'
'NU' 'N' '\nu'
'XI' '\Xi' '\xi'
'OMICRON' 'O' 'o'
'PI' '\Pi' {'\pi','\varpi'}
'RHO' 'P' {'\rho','\varrho'}
'SIGMA' '\Sigma' {'\sigma','\varsigma'}
'TAU' 'T' '\tau'
'UPSILON' '\Upsilon' '\upsilon'
'PHI' '\Phi' {'\phi','\varphi'}
'CHI' 'X' '\chi'
'PSI' '\Psi' '\psi'
'OMEGA' '\Omega' '\omega'};
h = figure('units','pixels','pos',[300,100,620,620],'Color','w');
'Xtick',[],'Ytick',[],'Xlim',[0 6],'Ylim',[0,4]);
% Loop by column and row
for r = 1:4
for c = 1:6
el = (r-1)*6 + c;
% Title
% Color cap latter in grey or black
if strcmp(greeks{el,2}(1),'\')
clr = [0, 0, 0];
clr = [0.65, 0.65, 0.65];
% Cap letter
text(c-0.5,4.87-r,['$\rm{' greeks{el,2} '}$'],'Fonts',40,...
% Lowercase letter/s (if two variants)
if iscell(greeks{el,3})
text(c-0.75,4.48-r,['$' greeks{el,3}{1} '$'],'Fonts',20,...
text(c-0.25,4.48-r,['$' greeks{el,3}{2} '$'],'Fonts',20,...
% Latex command
text(c-0.5,4.3-r,['\' greeks{el,3}{1}],'Fonts',12,'FontN','FixedWidth',...
text(c-0.5,4.48-r,['$' greeks{el,3} '$'],'Fonts',20,...
text(c-0.5,4.3-r,['\' greeks{el,3}],'Fonts',12,'FontN','FixedWidth',...
% Print to pdf
export_fig greeks.pdf
The link to export_fig.
And here is the link to the pdf on scribd:

Sign in to comment.

Accepted Answer

Rolfe Dlugy-Hegwer
Rolfe Dlugy-Hegwer on 15 Jun 2012
Marking this as answered.

More Answers (3)

Walter Roberson
Walter Roberson on 27 Sep 2013
Edited: Walter Roberson on 16 Jun 2016
There is a hack you can use for some uicontrol styles, and for uitable entries. This hack relies upon the fact that MATLAB uses HTML underneath some items.
The below works for styles pushbutton, togglebutton, radiobutton, checkbox, listbox, and popupmenu, but does not work for style 'edit' or 'text' or 'slider' or 'frame'.
1) To create a string with Greek characters in a uicontrol, create the uicontrol with one of the noted styles, and set the String properly specially.
  • At the very beginning of the String property, put '<HTML>' (or '<html>'). There must not be anything before that in the String property, not even a space.
  • Then have the normal string until you need the Greek character.
  • At that point, put in the HTML Character Entity equivalent of the character you want, starting with ampersand and ending with semi-colon. Each Greek character must have its own leading ampersand and trailing semi-colon; you cannot combine multiple entities.
  • If you code the entity name in all lower-case or all upper-case, the result will be the lower-case version of the character. If, however, you code with a leading capital letter and the rest lowercase, then the capital letter version will be used.
  • Then continue with the other elements of the string.
  • At the end of the string you want presented, you can just stop, but if you like to be complete, you could add '</HTML>' at the end.
uicontrol('Style', 'push', 'String', '<HTML>&omega;&Alpha;&tau;&Epsilon;&rho;&epsilon;&Rho;' )
You might have noticed that all of the uicontrol styles that support this character encoding normally have callbacks. (uicontrols of style 'text' and 'edit' are allowed to have callbacks, but in practice 'text' style uicontrols would not have a callback specified.)
Unfortunately, setting 'hittest' to 'off' on uicontrol elements has no effect, so one cannot take the simple route.
You can get rid of the action of the callback by setting the 'enable' property of the uicontrol to 'off'. If you do that, then any color will be removed from the text, and the text will be dimmed, making it harder to read. Setting the uicontrol 'fontweight' to 'bold' helps a bit.
If you are looking to emulate a uicontrol static text but with greek characters, then possibly the most effective way is to use style 'pushbutton' instead, leave 'enable' 'on', but ensure there is no (useful) callback. Unfortunately this will "frame" the text with a rounded rectangle.
If you want to be more perfectionist, then you should probably be reading Undocumented MATLAB.
2) To create an entry in a uitable with Greek characters:
  • ensure that the column format is String. As every entry in a column in a uitable must be the same format, then if you want to present numbers anywhere in the same column, you will need to convert the numbers to strings -- and conversely, if you want the user to be able to edit such an entry, you will later need to convert the cell array entry from string to number to get the new value the user entered.
  • encode the string for the cell array in the same manner as shown above, with '<HTML>' leading and ampersand encoding of the Greek characters.

Lisheng Su
Lisheng Su on 8 Aug 2013

Kirsten on 15 Jun 2016
This is useful. I'm trying to add a text box with \rho in it, but for some reason it looks like \varrho (pi looks normal, sigma also looks like varsigma), which I don't like. If I actually use \varrho, it doesn't see that as a character. Any ideas?
  1 Comment
Walter Roberson
Walter Roberson on 16 Jun 2016
Testing, I find HTML rho and varrho can display the same in some of the fonts. Font names Arial and Symbol and Times New Roman (and probably others) distinguish them. I suggest you experiment with a font change.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!