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











up vote
3
down vote

favorite












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




























    up vote
    3
    down vote

    favorite












    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


























      up vote
      3
      down vote

      favorite









      up vote
      3
      down vote

      favorite











      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 1 hour ago









      PolyGeo

      52.9k1779237




      52.9k1779237










      asked 6 hours ago









      Andrew-63

      1288




      1288






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          2
          down vote













          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





















            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',
            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








            up vote
            2
            down vote













            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

























              up vote
              2
              down vote













              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























                up vote
                2
                down vote










                up vote
                2
                down vote









                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 2 hours ago









                ahmadhanb

                21.1k31850




                21.1k31850






























                    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

                    Accessing regular linux commands in Huawei's Dopra Linux

                    Can't connect RFCOMM socket: Host is down

                    Kernel panic - not syncing: Fatal Exception in Interrupt