2

In QGIS 3.16 I have a 3 lined label

"Projekt" || '\n' || "Art" || '\n' || "Bearb"

How can I make only the text of the first line ("Projekt") bold or a bigger size?

4
  • You can't. But you can use rule based labeling to create two different labels, forcing them to be above each other using the placement rules.
    – Erik
    Jul 20, 2021 at 9:28
  • This tutorial from Klas Karlsson (youtube video) may give you some idea on how to get there : youtube.com/watch?v=ySYmZv7HQiY&ab_channel=KlasKarlsson
    – J.R
    Jul 20, 2021 at 9:45
  • 1
    You might look at this workaround: gis.stackexchange.com/questions/380964/…
    – John
    Jul 20, 2021 at 13:14
  • For the rule based labeling, see this one .. though Johns' linked solution using SVG is much more robust
    – JGH
    Jul 20, 2021 at 13:27

3 Answers 3

5

In QGIS 3.16, in label properties, you can check 'render as HTML', so that Labels can be interpreted as HTML code. Than your label can be writed as:

'<b>'||"Projekt"||'</b>' || '<br>' || "Art" || '<br>' || "Bearb"

you use <b></b> to write bold style and <br> to change line. In my solution I have supposed that Projekt,Art and Bearb are attribute name.

1

HTML Styling in labels is currently limited to colors, but you can work around that by using John's dynamic SVG solutions (see here and here), or by exporting to SVG (keep text as text objects) and edit the labels manually in Inkscape or Illustrator. Also, this feature may be coming soon, as katagena helpfully pointed out here.

Edit: katagena's answer has been removed. See Babel's answer instead.

1

In 3.16 this is not possible with a single label but in the following QGIS 3.28 (will be released October 2022) this will be implemented. See more at blog post by North Road .

You might use a workaround in 3.16 by using Rule-based labeling and adding each line as own label and defining the vertical offset for each: screenshot of rule based labels screenshot of setting the offset

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.