16

I would like to place the elevation-number of a point in a different front size and centred under its name:

enter image description here

Is that possible?

(That is my actual labeling: label || '\n' || elevation)

12

Ignoring font size for the minute, you could achieve your first option by centering the label above the point, in QGIS 1.9 you have the option to center the text under the multiple lines section. If you have included a newline character in your expression you can leave the 'Wrap on character' box empty (or I put a slash in my expression instead of the '\n' and set that as the wrap-character - the wrap-character isn't shown). This will set your text centered as in your second option. For something like your first option, you could set the line height option to 2 or 3.

However, QGIS advanced labeling only has a single option for font size. So, to achieve the different font sizes, I think you will have to add your layer a second time and set the elevation font and position in there.

  • 1
    Are there any current or future plans to implement the use of HTML-based font tags for QGIS labels, much like ArcGIS text formatting tags? – RyanDalton Jan 18 '13 at 16:01
  • 1
    @RyanDalton hub.qgis.org/issues/4080 It's a good idea, but may slow the label rendering down, and may be difficult to figure the appropriate size of the label (since that's based off of QFontMetricsF now), but have to try to implement it first to know for sure. No plans for 2.0, but might be doable for 2.1. – dakcarto Jan 18 '13 at 17:32
  • 1
    Any news on that? – MAP Nov 9 '16 at 8:18
4

You can achieve what you want using Rule-Based Labeling, but you need to separate the labels located in one field into two fields. Rule-Based Labeling option enables you to add labels from different fields and customize them as you like by changing font name, color, size and use offset to place them above each other.

As you can see in the example below, I put the Japanese labels and English Labels into two fields and then controlled the appearance of each label as I wanted to be:

enter image description here

To do this:

  • Go to Layer properties -> Labels
  • Select Rule-Based Labeling

enter image description here

  • Define the fields that you want to use in the labeling, each one separately. In this example, I used Name_JP and Name_EN.
  • Use the style for each one independently and customize each one as you like.
  • The most important is to use Offset under Placement for the one of the labels so that they can be above each other. For the first label field I used the following placement settings:

enter image description here

For the second label field I used the following settings:

enter image description here

Tested on QGIS 3.0.1, But it can also applied in QGIS 2.18 because Rule-Based Labeling option is available.

2

Unfortunately, this is not possible yet. For a related recent discussion check http://osgeo-org.1560.x6.nabble.com/HTML-tags-in-label-expresion-on-QGIS-2-0-1-td5084946.html.

There is also an existing feature request.

1

I used a duplicate of the same layer and labelled both with placements above and under respectively after checking 'show all labels and features for all layers'as attached and it works!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.