Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have a collection of notes on my iPad, written using a markdown editor/viewer (trunk notes) that does not understand latex, but does display greek. Is there a simple way to convert the greek letters (e.g. convert the UTF-8 symbol 0xCEB1, α) to their latex equivalents (\alpha)? I am using pandoc for the conversion, which is pasting a LaTeX header onto the output before conversion to TeX or ConTeXt.

share|improve this question
    
Do you need them also in text or only in math? –  egreg Jun 21 '12 at 14:38
    
Both. I'm placing some short notes inline, and putting longer equations in center /center tags. The app doesn't understand latex, so I am displaying it as HTML on the iPad, but would like to translate the notes to LaTex on my computer. One path is markdown->html->pdf, but that is rather ugly. –  Bill Jun 25 '12 at 2:51
add comment

3 Answers

I use the following code to make unicode symbols work both as normal text and in mathmode. But then xelatex is needed to compile it:

\usepackage{fontspec}
\setmainfont[Ligatures=TeX]{STIXGeneral}

\def\textalpha{α} \catcode`\α=\active \defα{\relax\ifmmode \alpha \else \textalpha \fi}

Also you need some suitable font, STIX works for me.

If you want to actually replace the unicode characters in the source code, that is a different issue. I don't know what kind of tools are available in your environment. I would compile a list of replacements like α \alpha and then write a small script that executes those in order. E.g. there is the replace utility on linux which does one such replacement.

share|improve this answer
    
I'll take a look at xelatex. Thanks –  Bill Jun 21 '12 at 11:54
1  
\usepackage{newunicodechar} and then \newunicodechar{α}{\ifmmode\alpha\else α\fi} is easier. :) However, with unicode-math and XITS Math as math font (also with other fonts, I believe) it works out of the box. –  egreg Jun 21 '12 at 14:34
    
@egreg: Thanks for the hint. Of course as I only have to do this once in some custom package, it is not really an effort. Still having it work out of the box would be great. I actually did this when unicode-math didn't work properly yet. Also, pmav99 uses the xgreek package, is that necessary? –  canaaerus Jun 21 '12 at 14:42
    
No it is not. I just copy pasted...! I'll remove it. –  pmav99 Jun 21 '12 at 14:50
add comment

In ConTeXt (both MkIV and MkII with utf-8 encoding), Greek letters work out of the box in text and math mode. (You need a text font with Greek letters)

\starttext
α $α$
\stoptext

With MkIV, Unicode characters behave like ASCII characters, so $\hat α$ is same as $\hat {α}$. In MkII, you need to use the latter form.

share|improve this answer
add comment

Expanding Canaaerus answer In xelatex, package unicode-math allows you to use greek characters in math-mode. Check the following minimum example.

\documentclass{article}

% font selection for normal text
\usepackage{fontspec}

% Packages needed for mathematics
\usepackage{amsmath}
\usepackage{unicode-math}

% Fonts
\setmainfont[Mapping=tex-text]{Linux Libertine O}
\setmathfont{XITS Math}

\begin{document}

\begin{equation}
    a = α + b + β^2_i
\end{equation}

\end{document}

For more info (in greek) look here

Fonts

The fonts that you may use are the following ones (they must be installed in your OS' standard font folder)

  • Asana-Math. Free font created by Apostolos Syropoulos.
  • Stix
  • Xits, fork of Stix
  • Neo Euler
  • Latin Modern Math, OpenType version of the classic TeX font.
  • Cambria Math. Proprietary font, distributed with Microsoft software (e.g. MS Office)

Edit

Note though that a and \alpha are different symbols! If you want to convert α to athen the previous approach cannot be used. If that is what you need, then it shouldn't be too difficult to write a script (e.g. in perl or python) that would parse your notes and make the replacements.

share|improve this answer
    
Your links to Stix and Xits do not work. Maybe you mean ctan.org/pkg/stix and ctan.org/pkg/xits ? –  canaaerus Jun 21 '12 at 14:55
    
Thank you. I was copy-pasting that too. I will fix them. –  pmav99 Jun 21 '12 at 14:57
    
Do greek letters also work in text mode with lualatex/fontspec/unicode-math? –  Aditya Jun 21 '12 at 15:03
    
@Aditya I am not really sure. In principle, I believe they should but I am not a LuaLaTeX user. I am mostly interested in multilingual texts. Last time I tried, LuaLaTeX had some problems with greek, so I haven't spend time with it. –  pmav99 Jun 21 '12 at 15:57
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.