Labeling using 'wordwrap' and 'wrap on character' with mutiple fields in QGIS?












4














I'm having a problem with multi-field labeling both using the 'wordwrap' function and the 'wrap on character' mode. In fact I would need to use the multiline mode only on the second of the two fields (setting the wrap_lenght to optimize the number of lines) but I have not succeeded in any way.



enter image description here



enter image description here



in the first image, on the left the correct formatting, on the right the formatting that I would like to correct but avoiding too many lines as on the right in the second image. The "number" is the first field while the "name" the second field.



I tried to solve the problem using the expression:



"FIELD_1" || '' || wordwrap ("FIELD_2", 12)


without changes in formatting,
and also using a rule based labeling with:



"FIELD_1" || ''
'' || wordwrap ("FIELD_2", 12)


but completely losing the formatting.



Is it possible to solve this problem?










share|improve this question





























    4














    I'm having a problem with multi-field labeling both using the 'wordwrap' function and the 'wrap on character' mode. In fact I would need to use the multiline mode only on the second of the two fields (setting the wrap_lenght to optimize the number of lines) but I have not succeeded in any way.



    enter image description here



    enter image description here



    in the first image, on the left the correct formatting, on the right the formatting that I would like to correct but avoiding too many lines as on the right in the second image. The "number" is the first field while the "name" the second field.



    I tried to solve the problem using the expression:



    "FIELD_1" || '' || wordwrap ("FIELD_2", 12)


    without changes in formatting,
    and also using a rule based labeling with:



    "FIELD_1" || ''
    '' || wordwrap ("FIELD_2", 12)


    but completely losing the formatting.



    Is it possible to solve this problem?










    share|improve this question



























      4












      4








      4


      1





      I'm having a problem with multi-field labeling both using the 'wordwrap' function and the 'wrap on character' mode. In fact I would need to use the multiline mode only on the second of the two fields (setting the wrap_lenght to optimize the number of lines) but I have not succeeded in any way.



      enter image description here



      enter image description here



      in the first image, on the left the correct formatting, on the right the formatting that I would like to correct but avoiding too many lines as on the right in the second image. The "number" is the first field while the "name" the second field.



      I tried to solve the problem using the expression:



      "FIELD_1" || '' || wordwrap ("FIELD_2", 12)


      without changes in formatting,
      and also using a rule based labeling with:



      "FIELD_1" || ''
      '' || wordwrap ("FIELD_2", 12)


      but completely losing the formatting.



      Is it possible to solve this problem?










      share|improve this question















      I'm having a problem with multi-field labeling both using the 'wordwrap' function and the 'wrap on character' mode. In fact I would need to use the multiline mode only on the second of the two fields (setting the wrap_lenght to optimize the number of lines) but I have not succeeded in any way.



      enter image description here



      enter image description here



      in the first image, on the left the correct formatting, on the right the formatting that I would like to correct but avoiding too many lines as on the right in the second image. The "number" is the first field while the "name" the second field.



      I tried to solve the problem using the expression:



      "FIELD_1" || '' || wordwrap ("FIELD_2", 12)


      without changes in formatting,
      and also using a rule based labeling with:



      "FIELD_1" || ''
      '' || wordwrap ("FIELD_2", 12)


      but completely losing the formatting.



      Is it possible to solve this problem?







      qgis labeling






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 3 at 5:15









      PolyGeo

      53.1k1779238




      53.1k1779238










      asked Dec 2 at 23:41









      Andrew-63

      1478




      1478






















          1 Answer
          1






          active

          oldest

          votes


















          6














          You can apply a condition to have more control on the labels if the length of text exceeds certain number of characters as follows:



           case
          when length("Field_2") < 6 then "Field_1" || 'n' || wordwrap("Field_2",6)
          when length("Field_2") >= 6 then "Field_1" || 'n' || wordwrap("Field_2",12)
          end


          The numbers 6 and 10 are just an example, you need to adjust them based on your needs.



          The output should look like this:



          enter image description here



          In the above examples the length of Smith County and Bob County are different but they stacked onto two lines based on the conditions above.






          share|improve this answer





















          • Thanks a lot! It seems to work perfectly
            – Andrew-63
            Dec 3 at 12:38











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "79"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f304680%2flabeling-using-wordwrap-and-wrap-on-character-with-mutiple-fields-in-qgis%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          6














          You can apply a condition to have more control on the labels if the length of text exceeds certain number of characters as follows:



           case
          when length("Field_2") < 6 then "Field_1" || 'n' || wordwrap("Field_2",6)
          when length("Field_2") >= 6 then "Field_1" || 'n' || wordwrap("Field_2",12)
          end


          The numbers 6 and 10 are just an example, you need to adjust them based on your needs.



          The output should look like this:



          enter image description here



          In the above examples the length of Smith County and Bob County are different but they stacked onto two lines based on the conditions above.






          share|improve this answer





















          • Thanks a lot! It seems to work perfectly
            – Andrew-63
            Dec 3 at 12:38
















          6














          You can apply a condition to have more control on the labels if the length of text exceeds certain number of characters as follows:



           case
          when length("Field_2") < 6 then "Field_1" || 'n' || wordwrap("Field_2",6)
          when length("Field_2") >= 6 then "Field_1" || 'n' || wordwrap("Field_2",12)
          end


          The numbers 6 and 10 are just an example, you need to adjust them based on your needs.



          The output should look like this:



          enter image description here



          In the above examples the length of Smith County and Bob County are different but they stacked onto two lines based on the conditions above.






          share|improve this answer





















          • Thanks a lot! It seems to work perfectly
            – Andrew-63
            Dec 3 at 12:38














          6












          6








          6






          You can apply a condition to have more control on the labels if the length of text exceeds certain number of characters as follows:



           case
          when length("Field_2") < 6 then "Field_1" || 'n' || wordwrap("Field_2",6)
          when length("Field_2") >= 6 then "Field_1" || 'n' || wordwrap("Field_2",12)
          end


          The numbers 6 and 10 are just an example, you need to adjust them based on your needs.



          The output should look like this:



          enter image description here



          In the above examples the length of Smith County and Bob County are different but they stacked onto two lines based on the conditions above.






          share|improve this answer












          You can apply a condition to have more control on the labels if the length of text exceeds certain number of characters as follows:



           case
          when length("Field_2") < 6 then "Field_1" || 'n' || wordwrap("Field_2",6)
          when length("Field_2") >= 6 then "Field_1" || 'n' || wordwrap("Field_2",12)
          end


          The numbers 6 and 10 are just an example, you need to adjust them based on your needs.



          The output should look like this:



          enter image description here



          In the above examples the length of Smith County and Bob County are different but they stacked onto two lines based on the conditions above.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 3 at 4:10









          ahmadhanb

          21.6k31951




          21.6k31951












          • Thanks a lot! It seems to work perfectly
            – Andrew-63
            Dec 3 at 12:38


















          • Thanks a lot! It seems to work perfectly
            – Andrew-63
            Dec 3 at 12:38
















          Thanks a lot! It seems to work perfectly
          – Andrew-63
          Dec 3 at 12:38




          Thanks a lot! It seems to work perfectly
          – Andrew-63
          Dec 3 at 12:38


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Geographic Information Systems Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f304680%2flabeling-using-wordwrap-and-wrap-on-character-with-mutiple-fields-in-qgis%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Plaza Victoria

          In PowerPoint, is there a keyboard shortcut for bulleted / numbered list?

          How to put 3 figures in Latex with 2 figures side by side and 1 below these side by side images but in...