7
$\begingroup$

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?

$\endgroup$
5
  • $\begingroup$ Hi user1311390! Would you mind individualizing your user name a bit? It makes this site a much cozier place. $\endgroup$ Commented Jun 29, 2012 at 8:14
  • $\begingroup$ Yeah! you could pick a personalized user id. Something like 0931131resu $\endgroup$ Commented Jun 29, 2012 at 12:10
  • $\begingroup$ @Sjoerd : done. $\endgroup$
    – user1602
    Commented Jun 29, 2012 at 19:56
  • $\begingroup$ Nice, thanks! I feel better already. ;-) $\endgroup$ Commented Jun 29, 2012 at 21:42
  • $\begingroup$ 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. $\endgroup$
    – user1602
    Commented Jun 30, 2012 at 9:25

1 Answer 1

9
$\begingroup$

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.

$\endgroup$
3
  • 1
    $\begingroup$ 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. $\endgroup$
    – user1602
    Commented Jun 29, 2012 at 3:14
  • 3
    $\begingroup$ @user1311390 That would indeed be an interesting feature. Perhaps someone here will take up the challenge. $\endgroup$ Commented Jun 29, 2012 at 4:07
  • $\begingroup$ @term-rewritica I think that may require some Dynamic things and a self-defined function doing evaluation and formating together :) $\endgroup$
    – Silvia
    Commented Jul 1, 2012 at 13:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.