Auto line break with very long word within table

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












4















I am trying to break a very very long number, 128 in length, to fit into a table cell so it won't go over the page.



I've looked up methods using longtabu, tabular with p5cm commend, makecell, parbox, multicolumn with p5cm, but non of those works. It seems like they only line break at "space" but does not line break one whole word, in my case is number.



I know it is possible to manually break line with \ or newline, but this doesn't seem practical in the long-run as I need to manually change this as the format of my document may change depending on the requirements given to me.



The only way I have in mind now, is to screenshot the long numbers into a figure, and insert it into the table. But if there is a better solution, I would like to use it.



Code that I use to longtabu attempt



beginlongtabu to textwidth X[1,c]

hline
textbfHead 1 &
textbfHead 2
\ hline
12:18:52 & this is a description for the event \hline
12:18:52 & this is a description for the event \hline
12:18:52 & this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event \hline
12:18:52 & 11111111111111111111111111111111111111222222222222222222222222222222222222222223333333333333333333333333333333333344444444444444444444455555555555555555555555555555555666666666666666666666666666777777777777777777777778888888888888888\hline
endlongtabu




Using p



begintabular
This text will be wrapped & Some more text \hline
this & 11111111111111111111111111111111111111222222222222222222222222222222222222222223333333333333333333333333333333333344444444444444444444455555555555555555555555555555555666666666666666666666666666777777777777777777777778888888888888888\hline
endtabular



Herbert solution at Break long word in tabular










share|improve this question
























  • thanks for all of your answers, tried Mico and Bernard's they worked!

    – Zachary Liu
    Feb 11 at 21:45















4















I am trying to break a very very long number, 128 in length, to fit into a table cell so it won't go over the page.



I've looked up methods using longtabu, tabular with p5cm commend, makecell, parbox, multicolumn with p5cm, but non of those works. It seems like they only line break at "space" but does not line break one whole word, in my case is number.



I know it is possible to manually break line with \ or newline, but this doesn't seem practical in the long-run as I need to manually change this as the format of my document may change depending on the requirements given to me.



The only way I have in mind now, is to screenshot the long numbers into a figure, and insert it into the table. But if there is a better solution, I would like to use it.



Code that I use to longtabu attempt



beginlongtabu to textwidth X[1,c]

hline
textbfHead 1 &
textbfHead 2
\ hline
12:18:52 & this is a description for the event \hline
12:18:52 & this is a description for the event \hline
12:18:52 & this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event \hline
12:18:52 & 11111111111111111111111111111111111111222222222222222222222222222222222222222223333333333333333333333333333333333344444444444444444444455555555555555555555555555555555666666666666666666666666666777777777777777777777778888888888888888\hline
endlongtabu




Using p



begintabular
This text will be wrapped & Some more text \hline
this & 11111111111111111111111111111111111111222222222222222222222222222222222222222223333333333333333333333333333333333344444444444444444444455555555555555555555555555555555666666666666666666666666666777777777777777777777778888888888888888\hline
endtabular



Herbert solution at Break long word in tabular










share|improve this question
























  • thanks for all of your answers, tried Mico and Bernard's they worked!

    – Zachary Liu
    Feb 11 at 21:45













4












4








4


0






I am trying to break a very very long number, 128 in length, to fit into a table cell so it won't go over the page.



I've looked up methods using longtabu, tabular with p5cm commend, makecell, parbox, multicolumn with p5cm, but non of those works. It seems like they only line break at "space" but does not line break one whole word, in my case is number.



I know it is possible to manually break line with \ or newline, but this doesn't seem practical in the long-run as I need to manually change this as the format of my document may change depending on the requirements given to me.



The only way I have in mind now, is to screenshot the long numbers into a figure, and insert it into the table. But if there is a better solution, I would like to use it.



Code that I use to longtabu attempt



beginlongtabu to textwidth X[1,c]

hline
textbfHead 1 &
textbfHead 2
\ hline
12:18:52 & this is a description for the event \hline
12:18:52 & this is a description for the event \hline
12:18:52 & this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event \hline
12:18:52 & 11111111111111111111111111111111111111222222222222222222222222222222222222222223333333333333333333333333333333333344444444444444444444455555555555555555555555555555555666666666666666666666666666777777777777777777777778888888888888888\hline
endlongtabu




Using p



begintabular
This text will be wrapped & Some more text \hline
this & 11111111111111111111111111111111111111222222222222222222222222222222222222222223333333333333333333333333333333333344444444444444444444455555555555555555555555555555555666666666666666666666666666777777777777777777777778888888888888888\hline
endtabular



Herbert solution at Break long word in tabular










share|improve this question
















I am trying to break a very very long number, 128 in length, to fit into a table cell so it won't go over the page.



I've looked up methods using longtabu, tabular with p5cm commend, makecell, parbox, multicolumn with p5cm, but non of those works. It seems like they only line break at "space" but does not line break one whole word, in my case is number.



I know it is possible to manually break line with \ or newline, but this doesn't seem practical in the long-run as I need to manually change this as the format of my document may change depending on the requirements given to me.



The only way I have in mind now, is to screenshot the long numbers into a figure, and insert it into the table. But if there is a better solution, I would like to use it.



Code that I use to longtabu attempt



beginlongtabu to textwidth X[1,c]

hline
textbfHead 1 &
textbfHead 2
\ hline
12:18:52 & this is a description for the event \hline
12:18:52 & this is a description for the event \hline
12:18:52 & this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event this is a description for the event \hline
12:18:52 & 11111111111111111111111111111111111111222222222222222222222222222222222222222223333333333333333333333333333333333344444444444444444444455555555555555555555555555555555666666666666666666666666666777777777777777777777778888888888888888\hline
endlongtabu




Using p



begintabular
This text will be wrapped & Some more text \hline
this & 11111111111111111111111111111111111111222222222222222222222222222222222222222223333333333333333333333333333333333344444444444444444444455555555555555555555555555555555666666666666666666666666666777777777777777777777778888888888888888\hline
endtabular



Herbert solution at Break long word in tabular







tables numbering line-breaking






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 11 at 19:51









Stefan Pinnow

20.1k83276




20.1k83276










asked Feb 11 at 19:43









Zachary LiuZachary Liu

233




233












  • thanks for all of your answers, tried Mico and Bernard's they worked!

    – Zachary Liu
    Feb 11 at 21:45

















  • thanks for all of your answers, tried Mico and Bernard's they worked!

    – Zachary Liu
    Feb 11 at 21:45
















thanks for all of your answers, tried Mico and Bernard's they worked!

– Zachary Liu
Feb 11 at 21:45





thanks for all of your answers, tried Mico and Bernard's they worked!

– Zachary Liu
Feb 11 at 21:45










3 Answers
3






active

oldest

votes


















8














You could load the xurl package and encase the long number in a url... "wrapper".



(The following code uses a tabularx environment since I'm not familiar with longtabu.)



enter image description here



documentclassarticle
usepackagetabularx,xurl
urlstylesame
begindocument
noindent
begintabularxtextwidth@ lX @
hline
textbfHead 1 & textbfHead 2 \
hline
12:18:52 & this is a description for the event \
hline
12:18:52 &
url11111111111111111111111111111111111111222222222222222222222222222222222222222223333333333333333333333333333333333344444444444444444444455555555555555555555555555555555666666666666666666666666666777777777777777777777778888888888888888\
hline
endtabularx
enddocument





share|improve this answer























  • Very nice (+1)!! Is it compatible with longtable? Because, I am not able to use this nice example in longtable environment :-/.

    – Raaja
    Feb 12 at 8:26







  • 1





    @Raaja - I can see no reason why the xurl package/url macro setup can't be used in other settings. Since longtable doesn't allow the X column type (at least not directly), one would need to replace the X column with a p column with a suitably chosen width. (Aside: The X column type is, in fact, nothing but a p column, with LaTeX performing the width-related calculations.)

    – Mico
    Feb 12 at 10:46











  • I didn't knew this info. I will play with it, If I must need further clarificatoins, I will ping you via chat ;-).

    – Raaja
    Feb 12 at 10:56


















6














Another solution with seqsplit, xltabular, which combines the functionalities of longtable and tabularx, and makecell to define some vertical padding of cells in the table:



documentclassarticle
usepackageseqsplit, makecell, xltabular

begindocument

setcellgapes[b]3pt
setcellgapes[t]2ptmakegapedcells
noindentbeginxltabulartextwidthc%

enddocument


enter image description here






share|improve this answer
































    3














    The problem is that the number is not in the list of words that tex uses to determine possible break points of words, but one can manually add them by placing - at each point where the number can be broken across lines:



    documentclassarticle

    usepackage[english]babel

    begindocument

    begintabular
    This text will be wrapped & Some more text \hline
    this & 1-111-111-1111-111-111-11-111-111-111-111-111-111-122-22-222-22-222-22-22-222-22-22\hline
    endtabular

    enddocument





    share|improve this answer






















      Your Answer








      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "85"
      ;
      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%2ftex.stackexchange.com%2fquestions%2f474399%2fauto-line-break-with-very-long-word-within-table%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      8














      You could load the xurl package and encase the long number in a url... "wrapper".



      (The following code uses a tabularx environment since I'm not familiar with longtabu.)



      enter image description here



      documentclassarticle
      usepackagetabularx,xurl
      urlstylesame
      begindocument
      noindent
      begintabularxtextwidth@ lX @
      hline
      textbfHead 1 & textbfHead 2 \
      hline
      12:18:52 & this is a description for the event \
      hline
      12:18:52 &
      url11111111111111111111111111111111111111222222222222222222222222222222222222222223333333333333333333333333333333333344444444444444444444455555555555555555555555555555555666666666666666666666666666777777777777777777777778888888888888888\
      hline
      endtabularx
      enddocument





      share|improve this answer























      • Very nice (+1)!! Is it compatible with longtable? Because, I am not able to use this nice example in longtable environment :-/.

        – Raaja
        Feb 12 at 8:26







      • 1





        @Raaja - I can see no reason why the xurl package/url macro setup can't be used in other settings. Since longtable doesn't allow the X column type (at least not directly), one would need to replace the X column with a p column with a suitably chosen width. (Aside: The X column type is, in fact, nothing but a p column, with LaTeX performing the width-related calculations.)

        – Mico
        Feb 12 at 10:46











      • I didn't knew this info. I will play with it, If I must need further clarificatoins, I will ping you via chat ;-).

        – Raaja
        Feb 12 at 10:56















      8














      You could load the xurl package and encase the long number in a url... "wrapper".



      (The following code uses a tabularx environment since I'm not familiar with longtabu.)



      enter image description here



      documentclassarticle
      usepackagetabularx,xurl
      urlstylesame
      begindocument
      noindent
      begintabularxtextwidth@ lX @
      hline
      textbfHead 1 & textbfHead 2 \
      hline
      12:18:52 & this is a description for the event \
      hline
      12:18:52 &
      url11111111111111111111111111111111111111222222222222222222222222222222222222222223333333333333333333333333333333333344444444444444444444455555555555555555555555555555555666666666666666666666666666777777777777777777777778888888888888888\
      hline
      endtabularx
      enddocument





      share|improve this answer























      • Very nice (+1)!! Is it compatible with longtable? Because, I am not able to use this nice example in longtable environment :-/.

        – Raaja
        Feb 12 at 8:26







      • 1





        @Raaja - I can see no reason why the xurl package/url macro setup can't be used in other settings. Since longtable doesn't allow the X column type (at least not directly), one would need to replace the X column with a p column with a suitably chosen width. (Aside: The X column type is, in fact, nothing but a p column, with LaTeX performing the width-related calculations.)

        – Mico
        Feb 12 at 10:46











      • I didn't knew this info. I will play with it, If I must need further clarificatoins, I will ping you via chat ;-).

        – Raaja
        Feb 12 at 10:56













      8












      8








      8







      You could load the xurl package and encase the long number in a url... "wrapper".



      (The following code uses a tabularx environment since I'm not familiar with longtabu.)



      enter image description here



      documentclassarticle
      usepackagetabularx,xurl
      urlstylesame
      begindocument
      noindent
      begintabularxtextwidth@ lX @
      hline
      textbfHead 1 & textbfHead 2 \
      hline
      12:18:52 & this is a description for the event \
      hline
      12:18:52 &
      url11111111111111111111111111111111111111222222222222222222222222222222222222222223333333333333333333333333333333333344444444444444444444455555555555555555555555555555555666666666666666666666666666777777777777777777777778888888888888888\
      hline
      endtabularx
      enddocument





      share|improve this answer













      You could load the xurl package and encase the long number in a url... "wrapper".



      (The following code uses a tabularx environment since I'm not familiar with longtabu.)



      enter image description here



      documentclassarticle
      usepackagetabularx,xurl
      urlstylesame
      begindocument
      noindent
      begintabularxtextwidth@ lX @
      hline
      textbfHead 1 & textbfHead 2 \
      hline
      12:18:52 & this is a description for the event \
      hline
      12:18:52 &
      url11111111111111111111111111111111111111222222222222222222222222222222222222222223333333333333333333333333333333333344444444444444444444455555555555555555555555555555555666666666666666666666666666777777777777777777777778888888888888888\
      hline
      endtabularx
      enddocument






      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Feb 11 at 20:00









      MicoMico

      281k31385774




      281k31385774












      • Very nice (+1)!! Is it compatible with longtable? Because, I am not able to use this nice example in longtable environment :-/.

        – Raaja
        Feb 12 at 8:26







      • 1





        @Raaja - I can see no reason why the xurl package/url macro setup can't be used in other settings. Since longtable doesn't allow the X column type (at least not directly), one would need to replace the X column with a p column with a suitably chosen width. (Aside: The X column type is, in fact, nothing but a p column, with LaTeX performing the width-related calculations.)

        – Mico
        Feb 12 at 10:46











      • I didn't knew this info. I will play with it, If I must need further clarificatoins, I will ping you via chat ;-).

        – Raaja
        Feb 12 at 10:56

















      • Very nice (+1)!! Is it compatible with longtable? Because, I am not able to use this nice example in longtable environment :-/.

        – Raaja
        Feb 12 at 8:26







      • 1





        @Raaja - I can see no reason why the xurl package/url macro setup can't be used in other settings. Since longtable doesn't allow the X column type (at least not directly), one would need to replace the X column with a p column with a suitably chosen width. (Aside: The X column type is, in fact, nothing but a p column, with LaTeX performing the width-related calculations.)

        – Mico
        Feb 12 at 10:46











      • I didn't knew this info. I will play with it, If I must need further clarificatoins, I will ping you via chat ;-).

        – Raaja
        Feb 12 at 10:56
















      Very nice (+1)!! Is it compatible with longtable? Because, I am not able to use this nice example in longtable environment :-/.

      – Raaja
      Feb 12 at 8:26






      Very nice (+1)!! Is it compatible with longtable? Because, I am not able to use this nice example in longtable environment :-/.

      – Raaja
      Feb 12 at 8:26





      1




      1





      @Raaja - I can see no reason why the xurl package/url macro setup can't be used in other settings. Since longtable doesn't allow the X column type (at least not directly), one would need to replace the X column with a p column with a suitably chosen width. (Aside: The X column type is, in fact, nothing but a p column, with LaTeX performing the width-related calculations.)

      – Mico
      Feb 12 at 10:46





      @Raaja - I can see no reason why the xurl package/url macro setup can't be used in other settings. Since longtable doesn't allow the X column type (at least not directly), one would need to replace the X column with a p column with a suitably chosen width. (Aside: The X column type is, in fact, nothing but a p column, with LaTeX performing the width-related calculations.)

      – Mico
      Feb 12 at 10:46













      I didn't knew this info. I will play with it, If I must need further clarificatoins, I will ping you via chat ;-).

      – Raaja
      Feb 12 at 10:56





      I didn't knew this info. I will play with it, If I must need further clarificatoins, I will ping you via chat ;-).

      – Raaja
      Feb 12 at 10:56











      6














      Another solution with seqsplit, xltabular, which combines the functionalities of longtable and tabularx, and makecell to define some vertical padding of cells in the table:



      documentclassarticle
      usepackageseqsplit, makecell, xltabular

      begindocument

      setcellgapes[b]3pt
      setcellgapes[t]2ptmakegapedcells
      noindentbeginxltabulartextwidthc%

      enddocument


      enter image description here






      share|improve this answer





























        6














        Another solution with seqsplit, xltabular, which combines the functionalities of longtable and tabularx, and makecell to define some vertical padding of cells in the table:



        documentclassarticle
        usepackageseqsplit, makecell, xltabular

        begindocument

        setcellgapes[b]3pt
        setcellgapes[t]2ptmakegapedcells
        noindentbeginxltabulartextwidthc%

        enddocument


        enter image description here






        share|improve this answer



























          6












          6








          6







          Another solution with seqsplit, xltabular, which combines the functionalities of longtable and tabularx, and makecell to define some vertical padding of cells in the table:



          documentclassarticle
          usepackageseqsplit, makecell, xltabular

          begindocument

          setcellgapes[b]3pt
          setcellgapes[t]2ptmakegapedcells
          noindentbeginxltabulartextwidthc%

          enddocument


          enter image description here






          share|improve this answer















          Another solution with seqsplit, xltabular, which combines the functionalities of longtable and tabularx, and makecell to define some vertical padding of cells in the table:



          documentclassarticle
          usepackageseqsplit, makecell, xltabular

          begindocument

          setcellgapes[b]3pt
          setcellgapes[t]2ptmakegapedcells
          noindentbeginxltabulartextwidthc%

          enddocument


          enter image description here







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Feb 11 at 23:04

























          answered Feb 11 at 21:03









          BernardBernard

          172k776204




          172k776204





















              3














              The problem is that the number is not in the list of words that tex uses to determine possible break points of words, but one can manually add them by placing - at each point where the number can be broken across lines:



              documentclassarticle

              usepackage[english]babel

              begindocument

              begintabular
              This text will be wrapped & Some more text \hline
              this & 1-111-111-1111-111-111-11-111-111-111-111-111-111-122-22-222-22-222-22-22-222-22-22\hline
              endtabular

              enddocument





              share|improve this answer



























                3














                The problem is that the number is not in the list of words that tex uses to determine possible break points of words, but one can manually add them by placing - at each point where the number can be broken across lines:



                documentclassarticle

                usepackage[english]babel

                begindocument

                begintabular
                This text will be wrapped & Some more text \hline
                this & 1-111-111-1111-111-111-11-111-111-111-111-111-111-122-22-222-22-222-22-22-222-22-22\hline
                endtabular

                enddocument





                share|improve this answer

























                  3












                  3








                  3







                  The problem is that the number is not in the list of words that tex uses to determine possible break points of words, but one can manually add them by placing - at each point where the number can be broken across lines:



                  documentclassarticle

                  usepackage[english]babel

                  begindocument

                  begintabular
                  This text will be wrapped & Some more text \hline
                  this & 1-111-111-1111-111-111-11-111-111-111-111-111-111-122-22-222-22-222-22-22-222-22-22\hline
                  endtabular

                  enddocument





                  share|improve this answer













                  The problem is that the number is not in the list of words that tex uses to determine possible break points of words, but one can manually add them by placing - at each point where the number can be broken across lines:



                  documentclassarticle

                  usepackage[english]babel

                  begindocument

                  begintabular
                  This text will be wrapped & Some more text \hline
                  this & 1-111-111-1111-111-111-11-111-111-111-111-111-111-122-22-222-22-222-22-22-222-22-22\hline
                  endtabular

                  enddocument






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Feb 11 at 19:55









                  jihajiha

                  2056




                  2056



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to TeX - LaTeX 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.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f474399%2fauto-line-break-with-very-long-word-within-table%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

                      How to check contact read email or not when send email to Individual?

                      Displaying single band from multi-band raster using QGIS

                      How many registers does an x86_64 CPU actually have?