7

Could anybody help me to find out the solution: how is possible to create labels with subscript and superscript, based on the attribute table (polygon shape)? The example that I need to create is

enter image description here

This type of labeling is common in any kind of geological maps. I'm using QGIS v.2.18.2

I will be extremaly glad to get answer, I hope it's possible.

3

3 Answers 3

2

Superscript and subscript characters can be added manually using the copy and paste approach described in @ahmadhanb 's answer, but this question and answer details a pair of python functions that will allow such characters to be generated as part of an expression. The functions will operate on one to many digits in a string passed to them.

Example (QGIS expression):

subscr_num( 'P1')  || supscr_num( 'ub2') || subscr_num( '1')

Output:

demo

The simultaneous sub and superscript shown at the end of the example in the question can't be generated using this approach, they would have to be offset as shown above.

1

enter image description here

According to the attached screenshot, you can see labels and label codes in the attribute table.

Below is a link to help you through the codes. https://unicode.org/charts/PDF/U2070.pdf

enter image description here

enter image description here

1
  • 2
    As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Mar 9, 2023 at 16:56
0

If you are planning to add the subscript and superscript in the legend, then you can refer to this answer: Subscript labels in QGIS legends which add details on how to do that. However, If you want to do that in the attribute table as you stated in your question, I am afraid you can only add superscript in the attribute table, but I couldn't find a way to do the same for subscript using the same method in the answer above. The strange thing that it is only allowed to add superscript up to number 3 (from 1 to 3) but if you have values above 3 it will be converted to normal size, although it is shown in the attribute table as superscript:

enter image description here

My guess is that the System font does not have superscript above the value 3 and the subscript does not exist at all.

enter image description here

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .