Sign up ×
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 am currently writing the practical part of my bachelors thesis which will be about on-line recognition of handwritten mathematical symbols (and eventually also formuae).

One problem I currently have with this is that I need to have the symbols in my database. I basically need

  • The latex code for the symbol (e.g. A, $\alpha$, $\rightarrow$, $\mathbb{R}$, ...)
  • The package name if I need one (e.g. \usepackage{amsmath})
  • SVG

I can create the SVG with the other two pieces of information (although the SVGs I can create are far from optimal), but I currently don't see a better way than manually entering those symbols. This seems like a tremendous waste of time, hearing from the developer of detexify that he has about 2000 symbols (but he can't give me the database - I don't know why).

So: How can I get a list of all symbols LaTeX / TeX has?

(By the way, the site is - but it still is a very early alpha release and I might truncate the database in the next few days, so please don't waste your time and generate data. The symbol recognition part doesn't exist at the moment.)

share|improve this question
Symbol lists available in plaintext, LaTeX source, or PDF output: – Paul Gessler May 8 '14 at 18:04
possible duplicate of How to look up a symbol or identify a math alphabet? – Henri Menke May 8 '14 at 18:08
@HenriMenke I don't want to look up one symbol. I want to have a processable list of all symbols. My question is not a duplicate of the question you've linked. – moose May 8 '14 at 18:11
@moose There's no 'fixed' list, and probably the Detexify database contains what you want. I'd be minded to ask the developer of that tool. – Joseph Wright May 8 '14 at 18:43
@moose along with the ruby file, you can find his database at This contains the packages required as well as which mode is required. – Paul Gessler May 8 '14 at 18:49

1 Answer 1

up vote 4 down vote accepted

As mentioned in the comments, the source for detexify is available on GitHub at

The symbols database is provided at lib/latex/symbols.yaml in a YAML format (sample below) which is easily extensible and satisfies your requirements for information about the required package(s) and mode (text or math).

# Table 212: wasysym Biological Symbols
- package: wasysym
    - \female 
    - \male
- package: skull
    - \skull
# Table 254: wasysym General Symbols
- package: wasysym
    - \LEFTarrow
    # <...>
    - \recorder
    - \checked #
    # <...>
    - \invdiameter #

SVG output can be created by adapting a rake task provided in lib/rake/symbol_task.rb. I present my initial adaptation of this code below. Disclaimer: I am a newbie to Ruby, and there are likely better ways to do this since I'm stripping away most of Daniel's code here. Take this as a starting point rather than the standard. :-)

require 'rake/tasklib'
require 'erb'
require 'latex/symbol'

class SymbolTask < Rake::TaskLib

  TEMPLATE = <<-LATEX #open('template.tex.erb').read

    <%= @packages %>


    <%= @command %>


  TMP = 'tmp'
  OUT = 'images/latex'

  attr_accessor :name, :tmp, :out

  # initialize sets the name and calls a block to get
  #   the rest of the options
  def initialize(name = :symbols)
      @name = name
      yield self if block_given?

  # define creates the new task(s)
  def define
    #desc "prepare necessary directories"
    #task :prepare do
      directory TMP
      directory OUT

    all_image_tasks = do |symbol|
      define_single_tex_task symbol
      define_single_dvi_task symbol      
      define_single_image_task symbol

    desc "create svg images from all symbols"
    task :gen_svg => all_image_tasks

  def define_single_image_task symbol
    file "#{File.join(OUT, symbol.filename)}.svg" => [OUT, "#{File.join(TMP, symbol.filename)}.dvi"] do |t|
      # Now convert to image
      puts "Creating image... #{}"
      sh %|dvisvgm -n #{File.join(TMP, symbol.filename)}.dvi #{}| do |ok, res|
        if ! ok
          puts "Major Failure creating image! (status = #{res.exitstatus})"

    "#{File.join(OUT, symbol.filename)}.svg" # need the names

  def define_single_dvi_task symbol
    file "#{File.join(TMP, symbol.filename)}.dvi" => [TMP, "#{File.join(TMP, symbol.filename)}.tex"] do
      puts "Generating dvi for #{symbol}..."
      sh %|latex -interaction=batchmode -output-directory=#{TMP} #{File.join(TMP, symbol.filename)}.tex| do |ok, res|
        if ! ok
          puts "Major Failure creating dvi! (status = #{res.exitstatus})"

  def define_single_tex_task symbol
    file "#{File.join(TMP, symbol.filename)}.tex" => TMP do |t|
      open(, 'w+') do |texfile|
        # setup variables
        @packages = ''
        @packages << "\\usepackage{#{symbol[:package]}}\n" if symbol[:package]
        @packages << "\\usepackage[#{symbol[:fontenc]}]{fontenc}\n" if symbol[:fontenc]
        @command = symbol.mathmode ? "$#{symbol.command}$" : symbol.command
        # write symbol to tempfile
        puts "Generating latex for #{symbol}..."
        texfile.puts TEMPLATE.result(binding)


I made these modifications on a clone of the detexify repository, but the only files required are lib/rake/symbol_task.rb, lib/latex/symbol.rb, and lib/latex/symbols.yaml.

To build all SVG outputs, execute rake gen_svg at a Ruby command prompt. dvisvgm is required; alternatively, the Ruby code could be modified to use pdflatex with pdf2svg (untested) or Inkscape (on the command line) to perform the conversion to SVG.

share|improve this answer

Your Answer


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.