3

如何定义不应计算公式,而应以传统格式显示?这里有 2 个示例,其中第一个显示为我想要的,但第二个被简化了。

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]
4

3 回答 3

5

Use HoldForm to print an expression without evaluating it.

Print["7. ", HoldForm[Limit[c, x -> a]], "=", c]
(* /*        ^^^^^^^^                      */ *)
于 2010-10-12T15:47:54.373 回答
5

这在一定程度上取决于您想要做什么,但如果您只是在编写文本,请不要使用Print. 相反,直接输入文本,确保您使用的是Text单元格而不是Input单元格。在菜单中,选择:

Format -> Style -> Text

然后输入你想要的,比如:

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/

如果您实际上是在尝试以编程方式生成 TraditionalForm 输出(例如, with Print),您可以考虑使用Rowand TraditionalFormwith HoldForm

Print[Row[{
   "5. ",
    TraditionalForm[HoldForm[
     Limit[f[x]/g[x], x -> a] == Limit[f[x], x -> a]/Limit[g[x], x -> a]]],
   " where ..."
   }]]
于 2010-10-12T15:57:52.433 回答
0

如果我理解正确 - 你不希望 Limit[c, x -> a] 被评估。阻止评估的标准方法是使用“保持”。

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

但结果并不好:

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

HoldForm 命令可以解决问题——它保存评估但不显示:

  Print["7. ", HoldForm[Limit[c, x -> a]], "=", c]
  7. Limit[c, x -> a] = c
于 2010-10-12T15:57:09.440 回答