({{, (RefLink[TeXForm, paclet:ref/TeXForm])[expr]
prints as a TeX version of expr. }})

OpenersNotesSection(Spacer1)Details

(RefLink[TeXForm, paclet:ref/TeXForm]) produces AMS-LaTeX-compatible TeX output.

(RefLink[TeXForm, paclet:ref/TeXForm]) acts as a "wrapper", which affects printing, but not evaluation.

(RefLink[TeXForm, paclet:ref/TeXForm]) translates standard mathematical functions and operations.

(RefLink[TeXForm, paclet:ref/TeXForm])[expr] is equivalent to (RefLink[TeXForm, paclet:ref/TeXForm])[(RefLink[TraditionalForm, paclet:ref/TraditionalForm])[expr]]. (RefLink[TeXForm, paclet:ref/TeXForm])[(RefLink[StandardForm, paclet:ref/StandardForm])[expr]] can be used to get (RefLink[StandardForm, paclet:ref/StandardForm]) TeX output. »

Symbols with names like alpha and ALPHA that correspond to TeX symbols are translated into their corresponding TeX symbols. »

Following standard mathematical conventions, single-character symbol names are given in italic font, while multiple character names are given in roman font.

Wolfram Language special characters are translated whenever possible to their TeX equivalents.

OpenersPrimaryExamplesSection(Spacer1)Examples  (17)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

A polynomial:

TeXForm[a+b^2]

A typeset expression:

TeXForm[(x/(Sqrt[5]))]

A special character:

TeXForm[α]

OpenersExampleSection1(Spacer1)Scope  (9)

Subscripts and superscripts:

TeXForm/@{(Subscript[x, a]),(x^a),(Subscript[x, a]^b)}

TeXForm/@{(Subscript[x, 2k+1]),(x^(2k+1))}

Overscripts and underscripts:

TeXForm/@{(Overscript[x, a]),(Underscript[x, a])}

List structures:

TeXForm[{a,b,c}]

TeXForm[{{a,b},{c}}]

A matrix:

TeXForm[{{a,b,c},{d,e,f}}]

Algebra and logic operations:

TeXForm[Expand[(x+y)^3]]

TeXForm[LogicalExpand[Xor[x,y]]]

TeXForm[ForAll[x,a∈Reals,x^2+a x+1>0]]

Calculus operations:

TeXForm[Integrate[f[x],x]]

TeXForm[Sum[f[n],{n,1,m}]]

TeXForm[Limit[f[x],x->∞]]

Elementary functions:

TeXForm/@{Sqrt[x],x^(1/3),Sin[x],ArcSin[x]}

Special functions:

TeXForm/@{Zeta[s],Erf[x],HypergeometricPFQ[{(Subscript[a, 1]),(Subscript[a, 2])},{(Subscript[b, 1])},x]}

Named symbols are translated:

TeXForm/@{gamma,GAMMA,Pi,E,I}

OpenersExampleSection2(Spacer1)Generalizations & Extensions  (1)

(RefLink[TeXForm, paclet:ref/TeXForm]) gives the TeX representation of the (RefLink[TraditionalForm, paclet:ref/TraditionalForm]) expression:

TeXForm[Sin[x]]

TeXForm[TraditionalForm[Sin[x]]]

Obtain the TeX representation of the expression in (RefLink[StandardForm, paclet:ref/StandardForm]):

TeXForm[StandardForm[Sin[x]]]

OpenersExampleSection3(Spacer1)Properties & Relations  (5)

Convert an expression to TeX:

t=TeXForm[1.2 x+Exp[y]]

Use (RefLink[ToExpression, paclet:ref/ToExpression]) to convert TeX back to Wolfram Language syntax:

ToExpression[ToString[t],TeXForm]

Use (RefLink[ToExpression, paclet:ref/ToExpression]) to convert from TeX to the Wolfram Language:

ToExpression["$\\sin^{-1}(x)$",TeXForm]

The following expression will evaluate:

Sum[n^2,{n,1,m}]

TeXForm[Sum[n^2,{n,1,m}]]

Use (RefLink[HoldForm, paclet:ref/HoldForm]) to convert unevaluated expressions:

TeXForm[HoldForm[Sum[n^2,{n,1,m}]]]

Add formatting via (RefLink[Format, paclet:ref/Format]):

bin[x,y]//TeXForm

Format[bin[x_,y_],TeXForm]:=MatrixForm[{{x},{y}}]

bin[x,y]//TeXForm

Use (RefLink[Export, paclet:ref/Export]) to generate a compilable TeX document:

ExportString[TraditionalForm[Sin[x]],"TeX"]

(RefLink[Splice, paclet:ref/Splice]) can be used to convert expressions in a file:

TeXForm[Integrate[Sin[x]^5, x]]

The following TeX file contains the unevaluated integral:

ifile=FileNameJoin[{"ExampleData","splicefile.mtex"}];

FilePrint[ifile]

(RefLink[Splice, paclet:ref/Splice]) inserts the result of the integral:

ofile=FileNameJoin[{$TemporaryDirectory,"spliceoutput.tex"}];

Splice[ifile,ofile]

This is the resulting output file:

FilePrint[ofile]

OpenersExampleSection4(Spacer1)Neat Examples  (1)

A continued fraction:

Nest[1+1/#&,x,5]

TeXForm[%]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[Export, paclet:ref/Export])  ▪  (RefLink[StandardForm, paclet:ref/StandardForm])  ▪  (RefLink[TraditionalForm, paclet:ref/TraditionalForm])  ▪  (RefLink[MathMLForm, paclet:ref/MathMLForm])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Generating and Importing TeX, paclet:tutorial/GeneratingAndImportingTeX])}, {▪(RefLinkPlain[Forms of Input and Output, paclet:tutorial/FormsOfInputAndOutput])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Converting between Expressions & Strings, paclet:guide/ConvertingBetweenExpressionsAndStrings])}})}})