Take the 2-minute tour ×

Here, it is just a example. I have a line:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaa

Now, I want to let LaTeX automatically wrap the line according to the width of the text block/margins.

share|improve this question
Does the text have no spaces at all? –  Mico Nov 3 '11 at 10:08
thanks for your remind. there would be some space between words. –  Frank Wang Nov 3 '11 at 10:57
Are your words really that long? Where do you want the breaks? Only at spaces, or within "words"? If within "words", how do you want to indicate continuation of a word? –  Loop Space Nov 3 '11 at 11:24
this is just an example. in my tex, these world may be some virtual word that make no sense. If within "words", i want to use '-' to indicate the continuation. –  Frank Wang Nov 3 '11 at 11:32

3 Answers 3

You are probably looking for something like the seqsplit package.




For lines with spaces the \seqsplit command can of course be used several times.


  \seqsplit{aaaaaaaaaaaaaaaaaaaaaaaa} \seqsplit{aaaaaaaaaaaaaaaaaaaaaaaaaaaaa} \seqsplit{aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa} \seqsplit{aaaaaaaaaaaaaaa}
share|improve this answer
This answer is based on the original version of the question where there had been no spaces in the concerned expression. –  Thorsten Donig Nov 3 '11 at 15:25
This also won't add a hyphenation character to indicate that the word has been split. Not sure if that is required though. –  Peter Grill Nov 4 '11 at 15:30
@PeterGrill: I can't see where the talk was of hyphens in the question. –  Thorsten Donig Nov 4 '11 at 20:34
Yep, that is why I said not sure if it is required by the OP, but seems like a natural thing when breaking up long words. –  Peter Grill Nov 4 '11 at 20:42
It's not sure if we are talking about real words. Could also be something like DNA sequences. –  Thorsten Donig Nov 4 '11 at 20:49

If a word is too long and it does not have a hyphenation pattern, the TeX engine does not know where to insert a break. You can force it by adding a minuscule amount of glue in-between the letters. TeX will then be able to insert a break. How much glue? As it happens even 1sp which is the smallest unit can do the trick (there are 65 536 scaled points in a point, which is less than the wavelength of visible light). All we need is a scanner to scan through the letters. Here is a minimal:

   \g@addto@macro{\tempa}{#1\hskip 0pt plus 1sp minus 1sp}%

  \scan@letters #1\@empty


Edit: egreg at chat brought to my attention that even hskip 0pt will also work.

share|improve this answer
@PeterGrill Yes it does not add one as the individual letters now represent words. For this type of example is difficult to understand what the OP wants. One can easily extend this method for example to break letters into groups of three and hyphenate at that point. –  Yiannis Lazarides Nov 4 '11 at 17:40

You can adapt the solution to Option to break urls with carriage-return symbol? which used the hyphenat pacakge to add a breakable character after each character.

Here is the output for various widths. The last paragraph width was chosen to ensure that the hyphen was not added if the break occurred at a space.

enter image description here


\sbox\MyBreakChar{\hyp}% char to display the break after non char
\sbox\MySpaceBreakChar{}% char to display the break after space

  \StrLen{#1 }[\stringLength]%
    \IfStrEq{\currentLetter}{ }

\newcommand*{\MyLongString}{aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa caaaaaaaaaaaaaaaaaa}%



share|improve this answer

Your Answer


