I use Mac, OSX 10.11.5. When I paste text from pdf files to emacs (tex mode), I get characters like "∈", "Ω". I need to convert them to LaTex equivalents "\in" "\Omega". Any hint?

  • 2
    In case you are willing to change: In TeXstudio there is a function Convert to LaTeX which does exactly this. – user36296 Jun 27 '16 at 9:35
  • Do you want to know how to convert into \in or if/how you could directly use in your .tex file? – ebosi Jun 27 '16 at 9:36
  • I use plain latex. I need to convert unicode characters to their latex equivalents, in order to have a collection of ASCII tex files. I should like to use emacs or python – Flavio Sartoretto Jun 27 '16 at 9:44
  • Then I think you could write a python script with a home-made lexicon as described here on stackexchange. I am not aware of a special characters -> LaTeX command lexicon, except this one... but I think you would prefer to make your own that you complete when needed! – ebosi Jun 27 '16 at 9:57
  • Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers. – user36296 Jul 25 '16 at 16:55

Using suggestions form various editors (thanks a lot!) I implemented this solution, which is ok for me

# -*- coding: utf-8 -*-

import sys
import re

# NOTE: literals enclosing backckslash are forced to raw using prefix r'...'
repldict = {'Ω':r'\Omega','?<8A><86>':r'\subseteq','?<8A><82>':r'\subset',
def replfunc(match):
return repldict[match.group(0)]

def main():
 regex = re.compile('|'.join(re.escape(x) for x in repldict))

 inFile = sys.argv[1]
 fin = open(inFile,'r')
 outFile = 'pdf2latexChars' + '.tex'
 fout = open(outFile, 'w')
 print 'inFile=' + inFile + '; outFile=' + outFile 

 for line in fin:

if __name__ == '__main__':

I just did this in PHP. You should be able to do something like this in Python:

$string = "I want the Latex equivalent of Ω, Δ, etc.";
$string = str_replace(
array("$\Omega$", "$\Delta$"),

string variable will now be: "I want the Latex equivalent of $\Omega$, $\Delta$, etc."

  • This doesn't solve the problem, in my opinion. – Werner Jul 3 '16 at 16:36
  • Well, he mentioned that he would like to use Python to solve the problem. Using this as reference should be sufficient? – SwCharlie Jul 4 '16 at 16:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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