MSPFormat[expr]
formats expr in the format style $MSPFormatType.
MSPFormat[expr,fmt]
formats expr in the format style fmt.
MSPFormat[expr,fmt,type]
formats expr in the format style fmt, using type as the content type.


MSPFormat
MSPFormat[expr]
formats expr in the format style $MSPFormatType.
MSPFormat[expr,fmt]
formats expr in the format style fmt.
MSPFormat[expr,fmt,type]
formats expr in the format style fmt, using type as the content type.
Details
- MSPFormat is the key function for formatting results from the Wolfram Language.
- The formatted result can appear in the different format types that the Wolfram Language provides for output, such as OutputForm, InputForm, StandardForm, TraditionalForm and MathMLForm.
- The results can be returned as HTML, as an image format or as MathML.
- The second argument of MSPFormat is a symbol that selects the Wolfram Language format type, and the third argument is a string that sets the actual content type of the result.
- The result is correctly escaped to be valid HTML that will work in a webpage.
- Note that the result must be displayed in a fixed-width font for correct alignment of multiline output.
- An alternative way to format expressions into HTML is provided by the HTML functions.
Examples
Basic Examples (1)
You can simulate how the functions work by loading the package.
The following demonstrates formatting output into HTML using the format OutputForm; it is formatted to a page width set by the variable $PageWidth:
An alternative to formatting into text is to format into an image. This is done for StandardForm and TraditionalForm, creating an image file and saving it on the server. An img tag, which can be used to retrieve the image, is then returned as the result:
By default, the images are in GIF format. This can be changed by specifying the format as a third argument. Here. the image is stored in JPEG format:
It is also possible, though rather strange, to get a text-based format type (for example OutputForm) rendered into an image:
The width that is used for typeset images is set by the variable $TypesetImageWidth.
An alternative way to generate images is with the function MSPExportImage. For information on image generation, see the section on displaying mathematics and graphics.
If the format is set to MathMLForm, the system will format the expression into MathML:
In addition, you can specify a content type of RawMathML. This can be useful to get the MathML for the StandardForm rendering of an expression. This output is raw in the sense that it does not use any reference to a plug-in, applet or special browser that would be necessary to activate the MathML:
More information on working with MathML is provided in the section on MathML.
Tech Notes
-
▪
- Wolfram Web Engine User Guide ▪
- Formatting in Wolfram Web Engine User Guide ▪
- Displaying Mathematics and Graphics in Wolfram Web Engine User Guide ▪
- HTML Formatting in Wolfram Web Engine User Guide ▪
- MathML in Wolfram Web Engine User Guide ▪
- Wolfram Language Web Functions in Wolfram Web Engine User Guide
Text
Wolfram Research (1996), MSPFormat, Wolfram Language function, https://reference.wolfram.com/language/WolframWebEngine/ref/MSPFormat.html.
CMS
Wolfram Language. 1996. "MSPFormat." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/WolframWebEngine/ref/MSPFormat.html.
APA
Wolfram Language. (1996). MSPFormat. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/WolframWebEngine/ref/MSPFormat.html
BibTeX
@misc{reference.wolfram_2025_mspformat, author="Wolfram Research", title="{MSPFormat}", year="1996", howpublished="\url{https://reference.wolfram.com/language/WolframWebEngine/ref/MSPFormat.html}", note=[Accessed: 25-August-2025]}
BibLaTeX
@online{reference.wolfram_2025_mspformat, organization={Wolfram Research}, title={MSPFormat}, year={1996}, url={https://reference.wolfram.com/language/WolframWebEngine/ref/MSPFormat.html}, note=[Accessed: 25-August-2025]}