Re: Create jpg image files of mathematical equations

*To*: mathgroup at smc.vnet.net*Subject*: [mg102549] Re: Create jpg image files of mathematical equations*From*: asdf qwerty <bradc355113 at yahoo.com>*Date*: Thu, 13 Aug 2009 03:21:43 -0400 (EDT)*References*: <h5okvi$sn$1@smc.vnet.net> <h5r8a5$l41$1@smc.vnet.net>

I think the following should be close to what you want. Note that png files will be both smaller and higher quality than jpg files -- it's an easy change (see comment in the code for what to change). makePicture[ op_, m_, n_, showAns : (True | False), font_String, fontSize_, bkcolor_ ] := Export[ FileNameJoin[{ (* construct filename *) NotebookDirectory[],(* output in same dir as current notebook *) StringJoin @@ Flatten[{ ToString[op], IntegerString[#, 10, 2] & /@ {m, n, op[m, n]}, ToString[showAns], ".jpg" (* ".png" *) }] }], Style[ (* format equation *) TraditionalForm[ HoldForm[op[m, n]] == If[showAns, op[m, n], Style[op[m, n], bkcolor]] ], fontSize, FontFamily -> font, Background -> bkcolor ] ] Do[makePicture[Plus, m, n, ans, "Arial", 72, LightGray], {m, 1, 3}, {n, 1, 3}, {ans, {True, False}}] Do[makePicture[Subtract, m, n, ans, "Arial", 72, LightGray], {m, 1, 4}, {n, 1, m}, {ans, {True, False}}] Do[makePicture[Times, m, n, ans, "Arial", 72, LightGray], {m, 1, 3}, {n, 1, 3}, {ans, {True, False}}] Do[makePicture[Divide, m, n, ans, "Arial", 72, LightGray], {m, 1, 4}, {n, Divisors[m]}, {ans, {True, False}}] -Brad On Aug 12, 1:32 am, Diana <diana.me... at gmail.com> wrote: > David, > > Thank you for explaining how to do the export with ExpressionCell. > > I have a two part followup: > > 1) I want to do hundreds of these files, and would like to use a table > and variables which change. Is it possible to use "m" and "n" within > the ExpressionCell[Defer[1 + 91}, for example, so that I don't have to > rewrite each export statement? > > 2) I would like to make the file names dynamic. For example, if I am > adding 1 + 91 = 92, I would like to name the file 01019192.jpg, where > the leading 01 stands for addition, and the remaining string 019192 > stand for 1, 91, and the sum, respectively. > > As an example, I would like to be able to write one statement to > create 14 jpg files for the "14's" times tables, 1 x 14 = 14, 2 x 14 = = 28, ..., 14 x 14 = 196. > > Thank you for your time, > > Diana M. > > On Aug 11, 12:57 am, David Reiss <dbre... at gmail.com> wrote: > > > Here are two examples to get you started (of course the paths to the > > files need to be changed for your system).... > > > Export["/Users/dreiss/Desktop/MyEquation.jpg", > > ExpressionCell[Defer[1 + 91], "Input", FontSize -> 30, > > Background -> LightGray]] > > > Export["/Users/dreiss/Desktop/MyEquation.jpg", > > ExpressionCell[Defer[1 + 91 == #] &[1 + 91], "Input", FontSize -= > 30, > > Background -> LightGray]] > > > Hope this helps, > > > Davidhttp://www.scientificarts.com/worklife/ > > > On Aug 10, 4:15 am, Diana <diana.me... at gmail.com> wrote: > > > > Hi all, > > > > I want to quickly create many jpg image files of math facts though 24= , > > > such as > > > > 12 + 12 = 24 > > > 30 - 15 = 15 > > > 3 x 4 = 12 > > > > I would like to create the files with and without answers, with very > > > large font, and with an option to choose font and background colors. > > > > Can someone explain how to export equations, with special characters > > > for +, - * and /? > > > > Thank you, > > > > Diana