# Inlining calculations in a notebook

## Context

In $\LaTeX$, I can write something like:

  Thus, we have $x = \sqrt{2}$, ...

the $...$, as opposed to $$...$$, inline the LaTeX symbols.


Now, with Mathematica, I type a line of Input, I press ShiftEnter, and it produces the answer on a different line of output. However, I would like to type something like this:

  Thus, we get $c^2 - c = 1$, and solving it, we get $N[solve[c^2 - c = 1, c]]$, ...


The idea is that mathematica evaluates the command, takes the output, and inlines it into the sentence, rather than have it as a separate line.

I have no idea how to do this. From what I've read, this sounds like "cells", but from goofing around, it's not clear how to make this work.

## Question:

How do I inline a mathematica expression, such that its output is displayed inline?

-
Hi user1311390! Would you mind individualizing your user name a bit? It makes this site a much cozier place. –  Sjoerd C. de Vries Jun 29 '12 at 8:14
Yeah! you could pick a personalized user id. Something like 0931131resu –  belisarius Jun 29 '12 at 12:10
@Sjoerd : done. –  user1602 Jun 29 '12 at 19:56
Nice, thanks! I feel better already. ;-) –  Sjoerd C. de Vries Jun 29 '12 at 21:42
I do have to admit, mathematica.stackexchange.com does seem like the friendliest of all stackexchanges I've used. Perhaps people who use mathematica tend to be smarter, and the community, as a result, doesn't become jaded and burnt out. –  user1602 Jun 30 '12 at 9:25

Does the Evaluate in Place command, found in the Evaluation menu, do what you want or most of what you want? Starting with your example, correcting a couple of typos

Thus, we get $c^2 - c == 1$, and solving it, we get $N[Solve[c^2 - c == 1, c]]$, ...


select the portion

  N[Solve[c^2 - c == 1, c]]


with the mouse and either use the menu command Evaluate in Place or type Shift+Ctrl+Enter to get

Thus, we get $c^2 - c == 1$, and solving it, we get ${{c -> -0.6180339887498949}, {c -> 1.618033988749895}}$, ...


inline.

-
It's almost there. The following might be greedy. Is it possible that when I click on the evaluated result, it shows the original formula? A bit like cells in Microsoft Excel: when the cell is not in focus, show the result; when the cell is in focus, show original formula. –  user1602 Jun 29 '12 at 3:14
@user1311390 That would indeed be an interesting feature. Perhaps someone here will take up the challenge. –  Robert Miller Jun 29 '12 at 4:07
@term-rewritica I think that may require some Dynamic things and a self-defined function doing evaluation and formating together :) –  Silvia Jul 1 '12 at 13:11