# How to print superscript in vtkTextActor?

**URL:** https://discourse.vtk.org/t/how-to-print-superscript-in-vtktextactor/8284
**Category:** Support
**Created:** [April 12, 2022, 2:33pm UTC](https://discourse.vtk.org/t/how-to-print-superscript-in-vtktextactor/8284 "2022-04-12T14:33:21Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![zhang-qiang-github](https://discourse.vtk.org/user_avatar/discourse.vtk.org/zhang-qiang-github/32/2519_2.png) [@zhang-qiang-github](https://discourse.vtk.org/u/zhang-qiang-github)
#### Post date: [April 12, 2022, 2:33pm UTC](https://discourse.vtk.org/t/how-to-print-superscript-in-vtktextactor/8284/1 "2022-04-12T14:33:21Z")

</div>

How to print superscript in vtkTextActor?

For example: for `text.SetInput('mm^2')`, I hope it show:

![image](https://discourse.vtk.org/uploads/default/original/2X/7/7328f3169a96fb7be064657794ac8b78a37514fb.png)

```auto
import vtkmodules.all as vtk

text = vtk.vtkTextActor()
text.SetInput('mm^2')
text.SetDisplayPosition(100, 100)
property = text.GetTextProperty()
property.SetFontSize(20)

render = vtk.vtkRenderer()
render.AddActor(text)
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(render)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
iren.Initialize()
iren.Start()

```

I can not find a solution in network.

---

<div class="post-metadata">

### Author: ![danlipsa](https://discourse.vtk.org/user_avatar/discourse.vtk.org/danlipsa/32/390_2.png) [@danlipsa](https://discourse.vtk.org/u/danlipsa)
#### Post date: [April 12, 2022, 2:47pm UTC](https://discourse.vtk.org/t/how-to-print-superscript-in-vtktextactor/8284/2 "2022-04-12T14:47:09Z")

</div>

This document should help. I would look for tests that exercise the math text feature.

[https://www.paraview.org/Wiki/ParaView/Equation\_Rendering](https://www.paraview.org/Wiki/ParaView/Equation_Rendering)

---

<div class="post-metadata">

### Author: ![zhang-qiang-github](https://discourse.vtk.org/user_avatar/discourse.vtk.org/zhang-qiang-github/32/2519_2.png) [@zhang-qiang-github](https://discourse.vtk.org/u/zhang-qiang-github)
#### Post date: [April 12, 2022, 3:01pm UTC](https://discourse.vtk.org/t/how-to-print-superscript-in-vtktextactor/8284/3 "2022-04-12T15:01:56Z")

</div>

@danlipsa Thank you for the kindly reply. The document said `ParaView will check text for a pair of "$" symbols surrounding a MathText expression.`.

So, the code is modified as `text.SetInput('$mm^2$')`. The `vtkTextActor` can show the superscript.

However, it also report some bugs:

 ![image](https://discourse.vtk.org/uploads/default/original/2X/9/991372ad5ee7b222b45b0f5ef23ec4462e8407fb.png)

It require `matplotlib` is installed. And it do not support multiple lines.

Hope vtk provide native method to render superscript.

---

<div class="post-metadata">

### Author: ![danlipsa](https://discourse.vtk.org/user_avatar/discourse.vtk.org/danlipsa/32/390_2.png) [@danlipsa](https://discourse.vtk.org/u/danlipsa)
#### Post date: [April 12, 2022, 3:32pm UTC](https://discourse.vtk.org/t/how-to-print-superscript-in-vtktextactor/8284/4 "2022-04-12T15:32:06Z")

</div>

Multiline support has been fixed recently:  
[https://gitlab.kitware.com/vtk/vtk/-/merge\_requests/7458](https://gitlab.kitware.com/vtk/vtk/-/merge_requests/7458)

I don’t know about the warning you see. Please file a bug report if it is not there alread.

Thanks!

---

<div class="post-metadata">

### Author: ![zhang-qiang-github](https://discourse.vtk.org/user_avatar/discourse.vtk.org/zhang-qiang-github/32/2519_2.png) [@zhang-qiang-github](https://discourse.vtk.org/u/zhang-qiang-github)
#### Post date: [April 13, 2022, 2:08am UTC](https://discourse.vtk.org/t/how-to-print-superscript-in-vtktextactor/8284/5 "2022-04-13T02:08:37Z")

</div>

@danlipsa I have [posted](https://discourse.vtk.org/t/matplotlibdeprecationwarning-when-render-math-equation/8288) a question about this warning. Please have a look about more details.
