From: Jason Alexander on
A better solution would be the following: create a text cell and enter something like "Previously we calculated the value of X1 to be ", then insert an inline cell (ctrl+9, I believe). In the inline cell, enter "Dynamic[X1]", select and evaluate in place.

The inline cell, although it appears inside of a text cell, will automatically update to reflect the current value of X1. The previous solution only captures the value of X1 at the time of evaluation.

Jason

On 7 Apr 2010, at 08:19, Geico Caveman wrote:

> On 2010-04-06 04:24:51 -0700, dh <dh(a)metrohm.com> said:
>
>> On 05.04.2010 14:00, Geico Caveman wrote:
>>> I am doing a calculation. Let us say that the result of the calculation
>>> is in variable X1 (which was extracted from a list using [[]] type
>>> constructs - unimportant, but it is a result).
>>>
>>> I want to add text cells later in the notebook that refer to the value
>>> of X1 (not the string "X1"). I have tried doing this with the use of
>>> inline cells crtl + ( and ctrl + ), but whenI evaluate the notebook, I
>>> just get something like :
>>>
>>> "We calculated X1 earlier to be X1." instead of the expected "We
>>> calculated X1 earlier to be<<value of X1>>".
>>>
>>> I am trying to use Mathematica as a tool to create a handout for a class.
>>>
>>> I am not a Mathematica newbie, though I am new to using it for any
>>> purpose other than as a calculation program.
>>>
>>> Any ideas if this is possible ?
>>>
>>
>> Hi geico,
>> you could e.g. assuming x already has a value, first write your text like:
>> x=x
>> then select the second x and choose "Evaluate in Place" (from the menu
>> "Evaluation" or by right click)
>> Daniel
>
> Perfect. Thanks :)
>


Please access the attached hyperlink for an important electronic communications disclaimer: http://www.lse.ac.uk/collections/planningAndCorporatePolicy/legalandComplianceTeam/legal/disclaimer.htm

From: Geico Caveman on
On 2010-04-07 04:24:40 -0700, Jason Alexander <jalex(a)lse.ac.uk> said:

> A better solution would be the following: create a text cell and enter
> something like "Previously we calculated the value of X1 to be ", then
> insert an inline cell (ctrl+9, I believe). In the inline cell, enter
> "Dynamic[X1]", select and evaluate in place.
>
> The inline cell, although it appears inside of a text cell, will
> automatically update to reflect the current value of X1. The previous
> solution only captures the value of X1 at the time of evaluation.
>
> Jason

That is what I ultimately did. Thanks.

From: Murray Eisenberg on
I cannot get this to work: I created two new Input cells:

Dynamic[x]
x = 5

Then I created a Text cell:

the value is as you can see

and into it, between "is " and " as" pasted the Dynamic[x] expression
copied from the first of the two Input cells -- even using Ctrl-( to
create explicitly an Inline cell there.

Still, selecting that pasted expression and using the menu item
Evaluation > Evaluate in place seems to do nothing.

What am I doing wrong?

Also, if somehow this can be made to work, would the value of Dynamic[x]
in the Inline cell then automatically update when the value of x
changes? (My understanding of Dynamic tells me it should.)


On 4/14/2010 11:13 PM, Geico Caveman wrote:
> On 2010-04-07 04:24:40 -0700, Jason Alexander<jalex(a)lse.ac.uk> said:
>
>> A better solution would be the following: create a text cell and enter
>> something like "Previously we calculated the value of X1 to be ", then
>> insert an inline cell (ctrl+9, I believe). In the inline cell, enter
>> "Dynamic[X1]", select and evaluate in place.
>>
>> The inline cell, although it appears inside of a text cell, will
>> automatically update to reflect the current value of X1. The previous
>> solution only captures the value of X1 at the time of evaluation.
>>
>> Jason
>
> That is what I ultimately did. Thanks.
>

--
Murray Eisenberg murray(a)math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 549-1020 (H)
University of Massachusetts 413 545-2859 (W)
710 North Pleasant Street fax 413 545-1801
Amherst, MA 01003-9305

From: AES on
> A better solution would be the following: create a text cell and enter
> > something like "Previously we calculated the value of X1 to be ", then
> > insert an inline cell (ctrl+9, I believe). In the inline cell, enter
> > "Dynamic[X1]", select and evaluate in place.
> >
> > The inline cell, although it appears inside of a text cell, will
> > automatically update to reflect the current value of X1. The previous
> > solution only captures the value of X1 at the time of evaluation.

Are there any side effects that one has to watch out for with this
approach?

As one (probably unrealistic) concern, suppose one did this with a
sizable number of variables X1 . . . X100, or did it with a moderately
complex Plot (can this be done with a Plot, inside a text cell?).

Might doing this seriously slow down (or otherwise mess up) other
calculations involving or using the X_n values?

From: David Park on
Put the Dynamic[x] in an Inline Cell within the Text cell. Select it and
Evaluate it in place.

Then when you evaluate x=5, or Clear[x] elsewhere in the notebook the value
in the Text cell should change. Anyway, it works for me.


David Park
djmpark(a)comcast.net
http://home.comcast.net/~djmpark/



From: Murray Eisenberg [mailto:murray(a)math.umass.edu]


I cannot get this to work: I created two new Input cells:

Dynamic[x]
x = 5

Then I created a Text cell:

the value is as you can see

and into it, between "is " and " as" pasted the Dynamic[x] expression
copied from the first of the two Input cells -- even using Ctrl-( to
create explicitly an Inline cell there.

Still, selecting that pasted expression and using the menu item
Evaluation > Evaluate in place seems to do nothing.

What am I doing wrong?

Also, if somehow this can be made to work, would the value of Dynamic[x]
in the Inline cell then automatically update when the value of x
changes? (My understanding of Dynamic tells me it should.)


On 4/14/2010 11:13 PM, Geico Caveman wrote:
> On 2010-04-07 04:24:40 -0700, Jason Alexander<jalex(a)lse.ac.uk> said:
>
>> A better solution would be the following: create a text cell and enter
>> something like "Previously we calculated the value of X1 to be ", then
>> insert an inline cell (ctrl+9, I believe). In the inline cell, enter
>> "Dynamic[X1]", select and evaluate in place.
>>
>> The inline cell, although it appears inside of a text cell, will
>> automatically update to reflect the current value of X1. The previous
>> solution only captures the value of X1 at the time of evaluation.
>>
>> Jason
>
> That is what I ultimately did. Thanks.
>

--
Murray Eisenberg murray(a)math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 549-1020 (H)
University of Massachusetts 413 545-2859 (W)
710 North Pleasant Street fax 413 545-1801
Amherst, MA 01003-9305