CellPrint
Details
- If expr has head TextCell, ExpressionCell, or CellGroup, it is inserted unchanged into the notebook. »
- If expr is a string or Text object, a text cell is created to contain it. »
- If expr is any other type of expression, an expression cell is created to contain it. »
- With a text‐based front end, CellPrint[cell] does the same as applying Print to the contents of cell.
- Cells generated by CellPrint by default have GeneratedCell->True, so that they are overwritten if they are regenerated.
Examples
open all close allBasic Examples (3)
Create a text cell from a TextCell object:
CellPrint[TextCell["a", "Text"]]Create a sequence of text cells:
TextCell[#, "Text"]& /@ {"a", "b", "c"}CellPrint[%]Create a text cell from a string:
CellPrint["a"]Scope (4)
Strings are converted to TextCell objects with no specific style:
CellPrint["xxx"]CellPrint[TextCell["xxx"]]General expressions are converted to ExpressionCell objects with no specific style:
CellPrint[x ^ 2 + y ^ 2]CellPrint[ExpressionCell[x ^ 2 + y ^ 2]]Lists are converted to multiple cells:
CellPrint[{"xxx", x ^ 2 + y ^ 2}]Print cells with specific styles:
CellPrint[ExpressionCell[N[Pi, 20], "Output"]]CellPrint[ExpressionCell[N[Pi, 20], "Input"]]3.1415926535897932385CellPrint[TextCell["xxx", "Message"]]Properties & Relations (1)
Possible Issues (3)
Setting CellAutoOverwrite->False and repeatedly evaluating will not delete printed cells:
CellPrint[Cell["First", "Print", CellAutoOverwrite -> False]];
CellPrint[Cell["Last", "Print", CellAutoOverwrite -> False]];Setting CellAutoOverwrite and GeneratedCell can cause unexpected results:
CellPrint[Cell["First", "Print", CellAutoOverwrite -> False, GeneratedCell -> False]];
"Last"Evaluating input cells generated by CellPrint may put outputs in unexpected places, due to the CellAutoOverwrite and GeneratedCell settings in other cells generated by CellPrint:
CellPrint[{
ExpressionCell[Defer[2 + 2], "Input"],
TextCell["heading cell", "Subsubsubsection"],
TextCell["text cell", "Text"],
ExpressionCell[Defer[Plot[Sin[x], {x, 0, 10}]], "Input"]}]2 + 2heading cell
Plot[Sin[x], {x, 0, 10}]Tech Notes
Related Guides
Related Workflows
- Programmatically Insert a Cell in a Notebook
History
Introduced in 1996 (3.0) | Updated in 2007 (6.0)
Text
Wolfram Research (1996), CellPrint, Wolfram Language function, https://reference.wolfram.com/language/ref/CellPrint.html (updated 2007).
CMS
Wolfram Language. 1996. "CellPrint." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2007. https://reference.wolfram.com/language/ref/CellPrint.html.
APA
Wolfram Language. (1996). CellPrint. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/CellPrint.html
BibTeX
@misc{reference.wolfram_2026_cellprint, author="Wolfram Research", title="{CellPrint}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/CellPrint.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_cellprint, organization={Wolfram Research}, title={CellPrint}, year={2007}, url={https://reference.wolfram.com/language/ref/CellPrint.html}, note=[Accessed: 13-June-2026]}