16

How can I apply Multiline label option in the label property.Name field contains a lengthy name. I want to wrap it. How can I do it? please help me.

My QGIS version is 1.8

18

Since QGIS 2.4 there is very handy new expression builder function called wordwrap that will allow one to automatically wrap a lengthy string using as argument the ideal number of characters that a lime should have and ,optionally, a string delimiter (the default is space).

In the below example the field "sintaxon" is my lengthy values field.

enter image description here

Also notice that I can nest wordwrap several times if I want to use more than one string delimiter. In the example below it uses '-' and the default space.

enter image description here

  • This is not the best answer, but it was helpful to me as I wanted to split the label on different characters (space or dash). I had one case of dashes so used IF("name"='Chester-le-Street', 'Chester-\nle-Street', name). It's a hack, but it's good for my use. – Gregory Jan 4 '16 at 14:07
  • You could also nest the expression twice to have both a max & min number of characters per line... – raphael Jul 8 '16 at 18:38
  • This is a great tip for lengthy labels. Thanks a lot ! – gisnside Aug 23 '16 at 8:28
  • how do i get into the expression dialog? – newGIS Sep 11 '16 at 19:53
  • Click the Expression builder icon next to the column field. It looks like a Epsilon, a E. – Alexandre Neto Sep 11 '16 at 20:20
16

If you labels contain a new line character (\n) they will be automatically wrapped. If not you can apply a wrapping character in the Advanced section of the labeling tools

enter image description here

The label will be wrapped on the character supplied. If you want to wrap on space just insert a space.

  • Nathn W, where i add the "\n" sign? – newGIS Sep 11 '16 at 19:48

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.