Text Formattingword wrapping of continuous text

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
Mima
Posts: 2
Joined: Sat Jan 24, 2009 1:20 am

word wrapping of continuous text

Post by Mima »

I have a continuous sequence of letters (no special characters or breaks) and TeX writes it over the right border of the page. How can I wrap this sequence such that line breaks are introduced where the page ends?

Thanks a lot for your help!!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

phi
Posts: 577
Joined: Tue Oct 21, 2008 8:10 pm

word wrapping of continuous text

Post by phi »

A crude but simple hack (that destroys ligatures and hyphenation) would be to split up the letters and allow breaking everywhere:

Code: Select all

\documentclass{article}
\makeatletter
\newcommand*\wrapletters[1]{\wr@pletters#1\@nil}
\def\wr@pletters#1#2\@nil{#1\allowbreak\if&#2&\else\wr@pletters#2\@nil\fi}
\makeatother
\begin{document}
\wrapletters{akjhghjerbhkjgxhdrjgkbhyxksrfihcgbwaemklcjtnhwabketrbmshrkncgaervbetjkewhbgrkjavkjdkvbkjsjkbtkgvnsetbjsrhtservjbtbjkhtvy}
\end{document}
Mima
Posts: 2
Joined: Sat Jan 24, 2009 1:20 am

Re: word wrapping of continuous text

Post by Mima »

Dear phi

Thanks a lot, that works very well! You helped me a lot.
Post Reply