       Re: Inline Formulas and Answers

• To: mathgroup at smc.vnet.net
• Subject: [mg50739] Re: [mg50678] Inline Formulas and Answers
• From: "David Park" <djmp at earthlink.net>
• Date: Sat, 18 Sep 2004 05:49:05 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```Gregory,

I would be interested in the answers you get, but I don't think you can make
inline cells automatiacally evaluate or update. Mathematica is not like a
spreadsheet.

If what you are looking for is a commented derivation or calculation with
various input parameters you probably can do something that will be
suitable. Here is an extremely trivial example...

Needs["Graphics`Colors`"]

solveequation[aa_, bb_] :=
Module[
{eqn = a x == b,
outputcolor = Black,
textcolor = IndianRed},
Print[
StyleForm[
SequenceForm["We want to solve the equation ", eqn, " with ",
a == aa, " and ", b == bb], FontColor -> textcolor]];
StylePrint[eqn, "Output", FontSize -> 16, FontColor -> outputcolor];
Print[StyleForm["Substitute the values", FontColor -> textcolor]];
eqn = eqn /. {a -> aa, b -> bb};
StylePrint[eqn, "Output", FontSize -> 16, FontColor -> outputcolor];
Print[
StyleForm[SequenceForm["Divide each side by ", aa, " for the
solution"],
FontColor -> textcolor]];
eqn = #/aa & /@ eqn;
StylePrint[eqn, "Output", FontSize -> 16, FontColor -> outputcolor];
]

solveequation[5, 16]

Or we may prefer to have everything in one text cell. Then we could
precalculate the various quantities and display them together in one cell.

solveequation2[aa_, bb_] :=
Module[{eqn0 = a x == b, eqn1, eqn2},
eqn1 = eqn0 /. {a -> aa, b -> bb};
eqn2 = #/aa & /@ eqn1;
Print["We want to solve the equation ", eqn0, " with ", a == aa, " and
",
b == bb, ". Substituting the values we obtain: ", eqn1,
" Dividing each side by ", aa, " we obtain the answer: ", eqn2]]

solveequation2[3, 5]

The definition cells could be in a Routines section, out of sight of the
reader of the notebook, or they could be combined with the call cell and
closed up so the reader didn't see them. But the closed cells would have to
be evaluated by the reader.

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/

From: Gregory Lypny [mailto:gregory.lypny at videotron.ca]
To: mathgroup at smc.vnet.net

Hello Everyone,

I've inserted a formula inside a text cell using the CRTL-( and CRTL-)
key combinations.  Is it possible to display the results of the
formula's calculation in the text as well and have it update
automatically if the variables are changed?

Gregory Lypny
__________________________
Associate Professor of Finance
John Molson School of Business
Concordia University
Montreal, Quebec
Canada

```

• Prev by Date: Re: Re: Log==2*Log
• Next by Date: IMS 2005: First announcement and call for submissions
• Previous by thread: Inline Formulas and Answers
• Next by thread: Re: Inline Formulas and Answers