Text
更多信息和选项
- 缺省情况下,以 StandardForm 形式显示文本,采用常见的文字字体,如 Arial 或 Helvetica.
- Text 可用于二维和三维图.
- 在图形中,Text[expr] 等价于 Text[expr,{0,0}] 或 Text[expr,{0,0,0}].
- Text[expr,coords] 执行类似 Inset[expr,coords].
- 坐标可以用例如 {x,y,…} 或 Scaled[{x,y,…}] 来指定. »
- 在二维情况下,坐标也可由 Offset 指定. »
- Text[expr,coords,offset] 指定文本块相对于给定坐标的偏移量. 给出偏移量 {sdx,sdy} 指明在包围文字的矩形区域内,点 {x,y} 位于相对坐标 {sdx,sdy}. 矩形区域的每个相对坐标范围从 -1 到 +1.
- 指定的偏移量不需要限制在 -1 到 +1 的范围内.
- 二维图形中使用的偏移量可以包括:
-
{0,0} 文本以 {x,y} 为中心 {-1,0} 在 {x,y} 的左侧 {1,0} 在 {x,y} 的右侧 {0,-1} 中心位于 {x,y} 之上 {0,1} 中心位于 {x,y} 之下 - Text[expr,coords,offset,dir] 指定文本的方向,并且由给定向量 dir 确定. dir 的可能值有:
-
{1,0} 普通的水平方向文本 {0,1} 从下至上的垂直方向文本 {0,-1} 从上至下的垂直方向文本 {-1,0} 上下颠倒的水平文本 - 三维图像中的文本位置与给定点 {x,y,z}的投影相对应. 文本显示在所有对象的最前端.
- 以下为可选项:
-
Background None 背景色 ContentSelectable Automatic 是否允许内容选项 BaseStyle {} 内容的基本样式规范 FormatType Automatic 格式类型 - 图像之外, Text[expr] 有效生成一个 TextCell.
范例
打开所有单元 关闭所有单元基本范例 (3)
范围 (10)
位置 (6)
在默认情况下, Center 用于指定二维图像中文本的位置:
{Graphics[{Text["ABCDEF"], Circle[]}, Axes -> True, Ticks -> None],
Graphics[{Text["ABCDEF", Center], Circle[]}, Axes -> True, Ticks -> None]}Graphics[{Text["ABCDEF", Automatic], Circle[]}, Axes -> True, Ticks -> None]Graphics[{Text[2Pi r, {.5, .5}], Circle[]}, Frame -> True]Graphics3D[{Text[4Pi r ^ 2, {0, .5, .5}], Sphere[]}, Axes -> True]使用 Scaled 坐标:
Graphics[{Text[Pi r ^ 2, Scaled[{.5, .5}]], Circle[]}]Graphics3D[{Text[a ^ 3, Scaled[{.5, .5, 1}]], Cuboid[]}]ImageScaled 在整个图像中指定坐标,包括填充区域:
Framed@Graphics[{Text[x ^ 2 + y ^ 2 == 1, ImageScaled[{.5, .5}]], Circle[]}, ImagePadding -> {{0, 50}, {0, 0}}]在二维图像中使用 Offset 坐标:
Graphics[{Text[Pi r ^ 2, Offset[{10, 20}, {0, 0}]], Circle[]}]Table[Graphics[{Text["ABCDEF", {s, Center}], Circle[]}], {s, {Left, Center, Right}}]Table[Graphics[{Text["ABCDEF", {Center, s}], Circle[]}], {s, {Top, Center, Bottom}}]偏移量和方向 (4)
在默认情况下, Center 指定排列对齐位置:
{Graphics[{Text["ABCDEF", {0, .5}], Circle[]}, Axes -> True, Ticks -> None],
Graphics[{Text["ABCDEF", {0, .5}, Center], Circle[]}, Axes -> True, Ticks -> None]}Graphics[{Text["ABCDEF", {0, .5}, Automatic], Circle[]}, Axes -> True, Ticks -> None]Table[Graphics[{Text["ABCDEF", {0, 0}, {p, Center}], Circle[]}, Axes -> {False, True}, Ticks -> None], {p, {Right, Center, Left}}]Table[Graphics[{Text["ABCDEF", {0, 0}, {Center, p}], Circle[]}, Axes -> {True, False}, Ticks -> None], {p, {Top, Center, Bottom}}]Table[Graphics[{Text["ABCDEF", {0, 0}, a], Circle[]}, Axes -> True, Ticks -> None], {a, {{1, 1}, {-1, 1}, {-1, -1}, {1, -1}}}]Table[Graphics3D[{Text["ABCDEF", {0, 0, 0}, a], Sphere[]}], {a, {{1, 1}, {-1, 1}, {-1, -1}, {1, -1}}}]Table[Graphics[{Text[Style[x ^ 2 + y ^ 2 < 1, Medium], {0, 0}, Automatic, d], Circle[]}], {d, {{1, 0}, {1, 1}, {0, 1}, {-1, -1}}}]选项 (3)
Background (1)
FormatType (2)
在默认情况下,用 TraditionalForm 显示表达式:
Graphics[{Text[Style[x ^ 2 + y ^ 2 < 1, Medium]], Circle[]}]使用 StandardForm 显示表达式:
Graphics[{Text[Style[x ^ 2 + y ^ 2 < 1, Medium], FormatType -> StandardForm], Circle[]}]属性和关系 (2)
相对于 ImageScaled 坐标的符号位置:
Table[Framed@Graphics[{Text["ABCDEF", {s, Center}], Circle[]}, ImagePadding -> {{10, 40}, {0, 0}}], {s, {Left, Center, Right}}]Table[Framed@Graphics[{Text["ABCDEF", {Center, s}], Circle[]}, ImagePadding -> {{0, 0}, {10, 20}}], {s, {Top, Center, Bottom}}]样式类型可由 Style 指定:
Graphics[{Text[Style["ABCDEF", Large, Bold, Red], {0, 0}, Automatic, {2, 1}], Circle[]}]相关指南
-
▪
- 笔记本中的文本元素 ▪
- 数学排版 ▪
- 地图和制图 ▪
- 交互操作的选项和样式 ▪
- 笔记本文档生成 ▪
- 图表标签、图例和注解 ▪
- 标签 ▪
- Graphics Primitives Gallery ▪
- 图形注解和外观 ▪
- 创建表单界面和应用程序 ▪
- 独立界面 ▪
- 符号图形语言
相关链接
历史
1988年引入 (1.0) | 在以下年份被更新:1996 (3.0) ▪ 2007 (6.0) ▪ 2008 (7.0) ▪ 2016 (11.0)
文本
Wolfram Research (1988),Text,Wolfram 语言函数,https://reference.wolfram.com/language/ref/Text.html (更新于 2016 年).
CMS
Wolfram 语言. 1988. "Text." Wolfram 语言与系统参考资料中心. Wolfram Research. 最新版本 2016. https://reference.wolfram.com/language/ref/Text.html.
APA
Wolfram 语言. (1988). Text. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/Text.html 年
BibTeX
@misc{reference.wolfram_2026_text, author="Wolfram Research", title="{Text}", year="2016", howpublished="\url{https://reference.wolfram.com/language/ref/Text.html}", note=[Accessed: 07-August-2026]}
BibLaTeX
@online{reference.wolfram_2026_text, organization={Wolfram Research}, title={Text}, year={2016}, url={https://reference.wolfram.com/language/ref/Text.html}, note=[Accessed: 07-August-2026]}