5
$\begingroup$

I have a notebook in which a couple of partial derivatives are calculated.

At the time of publishing this notebook, I'd like to make the resulting equations look the way they would in standard scientific and mathematical writing. Converting the cells in question to TraditionalForm helps, but falls short of the desired result. The problem is that, in the notebook, what would be traditionally an equation's left- and right-hand sides get split over two ("input" and "output") lines:

enter image description here

(Also, the "input" is in boldface.)

Is there a way to make this look like this?:

Mathematica graphics

Of course, I know that I can get typesetting like the one shown immediately above from Mathematica. In fact I produced this image by cutting and pasting into a new input cell the TraditionalForm versions shown in the first image, sticking an equal sign in-between the LHSs and RHSs, and getting rid of the boldface. But the result is no longer evaluatable. What I want to know is if there is a way to keep the LHSs evaluatable, but have the output appear to the right of the input, after an equal sign.

(For those who are not very familiar with Mathematica, the question above my seem unreasonable. One has to keep in mind that one of the most consistent themes in Mathematica's history has been to make notebooks approximate as much as possible the literate programming ideal of an "executable essay". The question above is about how to make something that is both executable and has the appearance of a typical mathematical-formulae-containing scientific essay. Then again, the structure of vertically-arrayed cells has been a feature of Mathematica for as long as I can remember, so I realize that what I'm asking for here, however much it may conform with Mathematica's overarching design ideals, may be just too difficult to implement.)


EDIT: The originals of the cells shown above are the last two input-output pairs below. (The code immediately below is an image! I give text versions the input further below. The input shown in the image is as I typed it, and differs from the text versions of the input given later.)

Mathematica graphics

FWIW, here's some code that you can cut-and-paste (although it is not what I actually typed):

Subscript[f, H][k_, t_] := 1/(k t + 1)
Subscript[f, E][k_, t_] := E^(-k t)
D[Log[Subscript[f, H][k, t]], t]
D[Log[Subscript[f, E][k, t]], t]

Note: When converting to TraditionalForm the formulas where the function's subscript is E, I had to manually fix the subscript, since Convert To > TraditionalForm turns it into the special e symbol, the same that is visible on the RHS (e-k t) of the function's definition. (I understand why this happens, but I have not found a better workaround than manual editing; everything else I've tried messes up the appearance of the TraditionalForm in some other way. For example, if I replace Subscript[f, E] with Subscript[f, "E"], the double quotes turn up in the subscript of the TraditionalForm, à la "scare quotes".)

$\endgroup$
5
  • $\begingroup$ Do you mean to ask if the output cell can be positioned to the right of the input cell, so that the notebook is, in some sense, double column, with an 'equal' sign down the middle? $\endgroup$
    – QuantumDot
    May 2, 2016 at 14:26
  • $\begingroup$ @QuantumDot: to a first approximation, your formulation matches what I have in mind. The main difference is that, I don't see why this two-column formatting couldn't be limited to a few cells (rather than extending over the whole notebook). $\endgroup$
    – kjo
    May 2, 2016 at 14:28
  • $\begingroup$ Show us the input and output cells before using Convert To > Traditional Form. $\endgroup$ May 2, 2016 at 14:47
  • $\begingroup$ @JackLaVigne: OK, done. $\endgroup$
    – kjo
    May 2, 2016 at 14:51
  • 1
    $\begingroup$ maybe related: text columns / bilateral cells $\endgroup$
    – kglr
    May 2, 2016 at 23:24

1 Answer 1

4
$\begingroup$

You can use Row to accomplish your task. HoldForm needs to be wrapped around the first part.

Copy of your code:

Subscript[f, H][k_, t_] := 1/(k t + 1)

Now try:

Row[{
  TraditionalForm[HoldForm@D[Log[Subscript[f, H][k, t]], t]],
  " = ",
  TraditionalForm[D[Log[Subscript[f, H][k, t]], t]]
  }]

Mathematica graphics

You can style it as you like. Below is a silly example just to get the point across.

Row[{
  TraditionalForm[
    Style[HoldForm@D[Log[Subscript[f, H][k, t]], t], Blue, 18]
    ]
   " = ",
  Style[TraditionalForm[D[Log[Subscript[f, H][k, t]], t]], Red, 18]
  }]

Mathematica graphics

To get the E without it being interpreted as the natural log base try:

Row[{
  TraditionalForm[HoldForm@D[Log[Subscript[f, H][k, t]], t]] /. 
   H -> "E",
  " = ",
  TraditionalForm[D[Log[Subscript[f, H][k, t]], t]]
  }]

Mathematica graphics

Using Row gives you a lot of power. You can insert space (e.g., Spacer[20]) wherever you like and hide the input line by double clicking the output in a notebook.

$\endgroup$
1
  • $\begingroup$ I believe you can use "E" in place of E directly inside the Subscript with the same visual effect as your replacement. $\endgroup$
    – Mr.Wizard
    May 6, 2016 at 2:15

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.