How to print equations in Mathematica

How to determine that the formula should not be calculated, but displayed in the traditional format? Here are two examples where the first is displayed as I want, but the second is simplified.

Print["5. ", Limit[f[x]/g[x], x -> a], "=", Limit[f[x], x -> a]/Limit[g[x], x -> a], ", where ", Limit[g[x], x -> a] != 0];
Print["7. ", Limit[c, x -> a], "=", c]
+3
source share
3 answers

Use HoldForm to print an expression without evaluating it.

Print["7. ", HoldForm[Limit[c, x -> a]], "=", c]
(* /*        ^^^^^^^^                      */ *)
+5
source

It depends a little on what you want to do, but if you're just writing text, don't use it Print. Instead, enter the text directly, making sure that you are using a cell Text, not a cell Input. In the menu, select:

Format -> Style -> Text

Then enter what you want, for example:

5. Limit[f[x]/g[x], x -> a] == Limit[f[x], x->a]/Limit[g[x], x -> a] where ...

, , TraditionalForm, , :

Cell -> ConvertTo -> TraditionalForm

... - :

: http://www.wolfram.com/broadcast/screencasts/howtoentermathematicaltypesetting/

SolidForm (, Print), Row TraditionalForm HoldForm:

Print[Row[{
   "5. ",
    TraditionalForm[HoldForm[
     Limit[f[x]/g[x], x -> a] == Limit[f[x], x -> a]/Limit[g[x], x -> a]]],
   " where ..."
   }]]
+5

If I understand you correctly, you do not want to evaluate Limit [c, x → a]. The standard way to stop something from evaluating is to use "Hold."

  Print["7. ", Hold[Limit[c, x -> a]], "=", c]

But the result is not very good:

  7. Hold[Limit[c, x -> a]] = c

The HoldForm command does the trick - it evaluates but does not display:

  Print["7. ", HoldForm[Limit[c, x -> a]], "=", c]
  7. Limit[c, x -> a] = c
0
source

Source: https://habr.com/ru/post/1769177/