3

This question already has an answer here:

Consider the following ridiculous example:

\documentclass{article}

\begin{document}

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

\end{document}

This produces an overfull hbox. I want to allow the word to break at any point, without a hyphen.

Of course, I can work around like this:

\documentclass{article}

\begin{document}

a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a\hspace{0pt}a

\end{document}

But this is far too ugly.

(I want to enable this only for a particular word, because I don't want my whole document to break.)

marked as duplicate by Mico, Raaja, Sebastiano, Stefan Pinnow, Phelype Oleinik Jun 2 at 17:27

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    By "without a hyphen", do you mean there should not be a hyphen even if the word is broken? – schtandard Jun 2 at 13:20
  • @schtandard Yes. The word is not really a "word" in this case. – L. F. Jun 2 at 13:21
5

The seqsplit package does it quite nicely:

\documentclass{article}
\usepackage{seqsplit} 

\begin{document}

\noindent \seqsplit{aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}

\end{document} 

enter image description here

  • Thank you! A dedicated package is the best option! – L. F. Jun 2 at 13:37
4

xurl package will break everywhere without inserting hyphen

\documentclass{article}

\usepackage{xurl}
\DeclareUrlCommand\longword{\urlstyle{rm}}


\begin{document}

\longword{aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}

\end{document}
  • Well, then the whole word is in monospace font. Is there a way to change that? – L. F. Jun 2 at 13:22
  • @L.F. see edited – coffeetable Jun 2 at 13:24
  • (+1) Good to know! I guess I will give a chance for other answers. – L. F. Jun 2 at 13:28
  • With this approach, it's important to specify the option obeyspaces. – Mico Jun 2 at 13:51
4
\documentclass{article}

\def\zz#1{\zzz#1\relax}
\def\zzz#1{\ifx\relax #1\else #1\penalty0 \expandafter\zzz\fi}

\begin{document}

\zz{aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}

\end{document}
  • if you need non-asciii letters you need to work a bit harder. – David Carlisle Jun 2 at 13:35
  • It is always useful to see what actually happens under the hood! – L. F. Jun 2 at 13:46

Not the answer you're looking for? Browse other questions tagged or ask your own question.