/usr/share/tmexpand/macros/mathsym.sl is in tmexpand 0.1.2.0-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | static variable Equation_Number = 0;
static define run_cmd (cmd)
{
if (-1 == system (cmd))
vmessage ("****WARNING: %s failed\n", cmd);
}
static define equation_function_env (esc_eq, env)
{
esc_eq = strtrim (esc_eq);
variable eq, len;
len = strlen (esc_eq);
if (0 == strncmp (esc_eq, "#v+", 3))
{
(esc_eq,) = strreplace (esc_eq, "#v+", "", len);
(esc_eq,) = strreplace (esc_eq, "#v-", "", len);
(esc_eq,) = strreplace (esc_eq, "#v", "", len);
esc_eq = strtrim (esc_eq);
eq = esc_eq;
}
else
{
(eq,) = strreplace (esc_eq, "\\\\", "\\", len);
(eq,) = strreplace (eq, "<", "<", len);
(eq,) = strreplace (eq, ">", ">", len);
(eq,) = strreplace (eq, "&", "&", len);
}
variable text = "\\documentclass[12pt]{article}\n";
text += "\\usepackage{amsmath}\n";
text += "\\begin{document}\n";
text += "\\pagestyle{empty}\n";
text += sprintf ("\\begin{%s}\n%s \\nonumber\n\\end{%s}", env, eq, env);
text += "\n\\end{document}\n";
Equation_Number++;
variable tmpdir = "tmp";
variable autopng = "autopng";
variable base = sprintf ("eq%d", Equation_Number);
() = mkdir (tmpdir, 0777);
() = mkdir (autopng, 0777);
variable tex = sprintf ("%s.tex", base);
variable dvi = base + ".dvi";
if (-1 == write_string_to_file (text, sprintf ("%s/%s", tmpdir, tex)))
verror ("Write to %s failed\n", tex);
run_cmd (sprintf ("cd %s; latex %s", tmpdir, tex));
run_cmd (sprintf ("cd %s; dvi2png %s", tmpdir, dvi));
variable png = sprintf ("%s/%s_eq%d.png", autopng, __TM_FILE__, Equation_Number);
run_cmd (sprintf ("mv %s/%s.png %s", tmpdir, dvi, png));
vinsert ("<img src=\"%s\" alt=\"%s\" border=0>\n", png, esc_eq);
}
public define equation_function (esc_eq)
{
equation_function_env (esc_eq, "equation*");
}
public define eqnarray_function (esc_eq)
{
equation_function_env (esc_eq, "eqnarray*");
}
tm_add_macro ("equation",&equation_function, 1, 1);
tm_add_macro ("eqnarray",&eqnarray_function, 1, 1);
|