Write subscript d to word table headers

I am trying to export parameter tables to word using the VIKTOR WordFileTag. The problem I am facing is that some of my parameters are design values and therefore I want to add a subscript d to the parameter symbol. I have however been unable to do so, for other subscripts I have used unicode characters but unfortunately subscript d does not exist in the unicode standard. One of the parameters I want to write is cd, I have tried the following:

  • c<sub>d</sub> ā†’ This causes word to crash when trying to open the file
  • c_d ā†’ This writes c_d in word
  • c{_d} ā†’ This writes c{_d} in word (LaTeX math mode)
  • c_{d} ā†’ This writes c_{d} in word (LaTeX math mode)
  • c_d ā†’ This writes c_d in word

Is there any way of writing a subscript d in word using the WordFileTag? As a sidenote I am also exporting the tables to Excel using the xlsxwriter package. Here c_d does work in order to add cd to the table headers

Hi Rutger,

I am looking into this, but unfortunately do not have an answer yet. Maybe you already know this, but the templater follows the rules as defined here:


Hopefully a better answer will follow later, either by myself, or someone from the community.

Hi Rutger,

It seems to be that there is another way of approaching your problem. You could consider using the package python-docx-template:


And then make use of the RichText functionality. Here is an example of a script that shows how to use RichText, with subscript one of the examples:

I hope this helps.


Normally you want all formatting done in Word. So what you can do is make a seperate tag voor de subscript in word. And put the complete tag in subscript.

Since the tag will be replaced by the value, the value will be in subscript.
Something like this:


@mweehuizen I have used your proposed solution and it works perfectly. In hindsight it makes sense that the formatting has to be done in Word and my code is now a lot cleaner since I can omit lots of unicode characters now.

@mslootweg I did not get the chance to look at the packages you suggested since I am on a tight schedule deadline wise. It looks interesting though and Iā€™d like to see if in the future I have some time to look at them.

Thank you both for your help!