#!/usr/bin/env python # -*- coding: utf8 -*- # :Copyright: © 2011 Günter Milde. # Released without warranties or conditions of any kind # under the terms of the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # :Id: $Id: $ # # :: """Unicode characters and corresponding LaTeX math mode commands""" # This script generates a LaTeX source file for compilation with the # `pdftex` engine. :: from symbols_xetex import * # Configuration # ------------- # I/O # outfile = file('../unimathsymbols-pdftex.tex', 'w') outfile = file('../mathpackages/wrisym-symbols.tex', 'w') # outfile = sys.stdout # Include entries for characters without (listed) LaTeX macro? # :: # include_unsupported_chars = True include_unsupported_chars = False # Include macros from the following packages:: packages = ['', # 'amssymb', # 'amsmath', # 'amsxtra', # 'arevmath', # 'bbold', # 'esint', # 'fourier', # 'gensymb', # 'isomath', # 'kmath', # 'lxfonts', # 'mathabx', # 'mathcomp', # 'mathdesign' # 'mathdots', # 'MnSymbol' # 'pzccal', # 'txfonts', # 'stmaryrd', # 'wasysym', 'wrisym', ] # Implementation # --------------- preamble = r"""\documentclass[a4paper,landscape]{article} \usepackage{fixltx2e} \usepackage{longtable,booktabs} \usepackage[tmargin=2cm,bmargin=2cm,lmargin=2cm,rmargin=2cm]{geometry} \usepackage{lmodern} \usepackage{xcolor} \setlength{\fboxsep}{0em} %% also for colorbox sep \newcommand{\spacebox}[1]{\colorbox{lightgray}{\rule{0pt}{1em}$#1$}} %% math packages %s \begin{document} \section*{%s} """ table_head = r""" \begin{longtable}{llllll} \toprule No. & Math & Macro & Category & Requirements & Comments\\ \midrule \endhead """ if __name__ == '__main__': outfile.write(preamble % (package_calls(packages), __doc__)) outfile.write(used_packages % ', '.join([pkg for pkg in packages if pkg])) outfile.write(table_head) # table lines for (key, entry) in parse_unimathsymbols.read_data(): cmd = macro_example(entry, packages) if not cmd: if not include_unsupported_chars: continue if (cmd == '[na]' and # not available with current package selection outfile.substr('wrisym') != -1): continue line = ' & '.join(['%05X' % entry.codepoint, '%s' % cmd, txt2tex(entry.cmd), entry.category, entry.requirements, txt2tex(entry.comment), ]) + r' \\' outfile.write(line + '\n') # the end outfile.write(table_foot) outfile.write(r'\end{document}') if outfile != sys.stdout: print "Output written to", outfile.name