Re: problems with typesetting in packages

*To*: mathgroup at smc.vnet.net*Subject*: [mg62496] Re: problems with typesetting in packages*From*: albert <awnl at arcor.de>*Date*: Sat, 26 Nov 2005 02:46:49 -0500 (EST)*References*: <dm49go$stf$1@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

Hi, > the following problem: Mathematica's typesetting capabilities are nice > in notebooks to improve the readability of equations (powers in > supscript-notation etc.). However, when one saves such a notebook as a > Mathematica-package, all the typesetting information is saved also. In > the package, which is essentially just an ASCII-file, the typesetting > information is useless and sometimes creates errors. At best, it makes > it very hard to read the package using a text editor. Here is an > example, how x^3 entered in supscript notation into the initialization > cell of a Mathematica notebook looks in the package: > > \!\(x\^3\) > > Upon creating larger packages, Mathematica apparently sometimes does > not balance the parentheses correctly: Reading such a package back to a > notebook, Mathematica complains on syntax errors. I had no choice than > to rewrite all nicely typesetted formulas in the original notebook in > plain Mathematica syntax without any typesetting and to save the > package again. > > Now my question: Is it possible to use typesetting in the Mathematica > notebook on one hand, and to save it to a package without any > typesetting information on the other hand? It is possible, but tedious. You could do the following by hand, as was suggested by others: - mark all cells that should go into the package as initialization cells - make a temporary copy of the notebook (or just the initialization cells) - convert these cells in the new notebook to InputForm (Cells -> Convert To -> InputForm) - save the new notebook (make sure that the AutoGeneratePackage Option is set to Automatic) - throw away the temporary notebook to make sure that you don't overwrite the package the AutoGeneratePackage Option for the original notebook should be set to None. Most probably you are going to change your source notebook a lot and you might want to automate the process using some FrontEnd programming, which in fact shouldn't be too difficult, I think. hth Albert