3

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?

Taras
  • 32,823
  • 4
  • 66
  • 137
alea
  • 31
  • 2
  • 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 '21 at 09:28
  • This tutorial from Klas Karlsson (youtube video) may give you some idea on how to get there : https://www.youtube.com/watch?v=ySYmZv7HQiY&ab_channel=KlasKarlsson – J.R Jul 20 '21 at 09:45
  • 1
    You might look at this workaround: https://gis.stackexchange.com/questions/380964/qgis-labels-with-html-formating – John Jul 20 '21 at 13:14
  • For the rule based labeling, see this one .. though Johns' linked solution using SVG is much more robust – JGH Jul 20 '21 at 13:27

3 Answers3

6

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.

EFiore
  • 421
  • 2
  • 6
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.

jburkhart
  • 101
  • 7
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

MrXsquared
  • 34,292
  • 21
  • 67
  • 117
LauriK
  • 1,638
  • 1
  • 14
  • 16