TextClipboardType
更多信息
- TextClipboardType 通常用于样式表中,自定义不同单元样式的默认剪贴板行为.
- 选择 编辑 ▶ 复制为 而非 TextClipboardType 以改变单次复制操作的剪贴板类型.
- 可以使用如下设置:
-
"PlainText" 保留单元的纯文本形式,并且等价于 编辑 ▶ 复制为 ▶ 纯文本 "InputText" 保留 Wolfram 系统对单元重新计算的能力,并且等价于 编辑 ▶ 复制为 ▶ 输入文本 "Package" 返回的内容恰好是如果把单元作为一个程序包保存所得的内容 - 默认情况下,对于输入和输出单元,TextClipboardType 的值是 "InputText";对于文本、打印、消息单元,它的值是"PlainText";对于代码单元,它的值是 "Package".
- "InputText" 和 "Package" 都保存计算语义. "InputText" 将调整空格和换行符使得结果可读性更强,而 "Package" 使得空格与它刚输入单元恰好相同.
- "PlainText" 创建一个高度模仿视觉效果的文本格式,即使这种出现在 Wolfram 语言中不计算.
范例
打开所有单元 关闭所有单元基本范例 (3)
选择下面显示的输入单元,选择 编辑 ▶ 复制,并且粘贴到一个文本编辑器:
Cell[BoxData[GridBox[{{RowBox[{"2", "+", "2"}], "a"}, {"b", "c"}}]], "Output", TextClipboardType -> "PlainText"]//CellPrint2+2 a
b c
选择下面显示的输入单元,选择 编辑 ▶ 复制,并且粘贴到一个文本编辑器:
Cell[BoxData[GridBox[{{RowBox[{"2", "+", "2"}], "a"}, {"b", "c"}}]], "Output", TextClipboardType -> "InputText"]//CellPrint{
{2 + 2, a},
{b, c}
}
选择下面显示的输入单元,选择 编辑 ▶ 复制,并且粘贴到一个文本编辑器:
Cell[BoxData[GridBox[{{RowBox[{"2", "+", "2"}], "a"}, {"b", "c"}}]], "Output", TextClipboardType -> "Package"]//CellPrint{
{2+2, a},
{b, c}
}
属性和关系 (4)
Cell[BoxData[TagBox["abc", "tag"]], "Output", TextClipboardType -> "PlainText"]//CellPrintabc
Cell[BoxData[TagBox["abc", "tag"]], "Output", TextClipboardType -> "InputText"]//CellPrint\!\(
TagBox["abc",
"tag"]\)
"PlainText" 在拷贝字符串中不包含引号,如果它们没有出现在单元中:
Cell[BoxData[RowBox[{"2", "+", "\"string\""}]], "Output", TextClipboardType -> "PlainText"]//CellPrint2+string
InterpretationBox (1)
InterpretationBox 拷贝 "PlainText" 的出现:
Cell[BoxData[InterpretationBox["fish", "fowl"]], "Output", TextClipboardType -> "PlainText"]//CellPrintfish
Cell[BoxData[InterpretationBox["fish", "fowl"]], "Output", TextClipboardType -> "InputText"]//CellPrint"fowl"
TemplateBox (1)
TemplateBox 对 "PlainText" 拷贝 DisplayFunction 中的框符:
Cell[BoxData[TemplateBox[{"2"}, "template", DisplayFunction :> (RowBox[{#, " millions"}]&), InterpretationFunction :> (RowBox[{#, "*", "10^6"}]&)]], "Output", TextClipboardType -> "PlainText"]//CellPrint2 millions
其他数字将拷贝 InterpretationFunction:
Cell[BoxData[TemplateBox[{"2"}, "template", DisplayFunction :> (RowBox[{#, "millions"}]&), InterpretationFunction :> (RowBox[{#, "*", "10^6"}]&)]], "Output", TextClipboardType -> "InputText"]//CellPrint2*10^6
可能存在的问题 (1)
MakeExpression[SuperscriptBox["super", val_], StandardForm] := MakeExpression[RowBox[{"super", "[", val, "]"}], StandardForm];
super^5TextClipboardType 将不考虑内核格式化规则来解决这些常见情况:
Cell[BoxData[SuperscriptBox["super", "5"]], "Output", TextClipboardType -> "InputText"]//CellPrintsuper^5
更好的方法是创建使用 TagBox 或者 TemplateBox 的格式化规则:
MakeExpression[TagBox[SuperscriptBox[_, val_], super], StandardForm] := MakeExpression[RowBox[{"super", "[", val, "]"}], StandardForm];
CellPrint[Cell[BoxData[TagBox[SuperscriptBox["super", "5"], super]], "Output", TextClipboardType -> "InputText"]]\!\(
TagBox[
SuperscriptBox["super", "5"],
$CellContext`super]\)
文本
Wolfram Research (2008),TextClipboardType,Wolfram 语言函数,https://reference.wolfram.com/language/ref/TextClipboardType.html.
CMS
Wolfram 语言. 2008. "TextClipboardType." Wolfram 语言与系统参考资料中心. Wolfram Research. https://reference.wolfram.com/language/ref/TextClipboardType.html.
APA
Wolfram 语言. (2008). TextClipboardType. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/TextClipboardType.html 年
BibTeX
@misc{reference.wolfram_2026_textclipboardtype, author="Wolfram Research", title="{TextClipboardType}", year="2008", howpublished="\url{https://reference.wolfram.com/language/ref/TextClipboardType.html}", note=[Accessed: 03-November-2026]}
BibLaTeX
@online{reference.wolfram_2026_textclipboardtype, organization={Wolfram Research}, title={TextClipboardType}, year={2008}, url={https://reference.wolfram.com/language/ref/TextClipboardType.html}, note=[Accessed: 03-November-2026]}