4

I have a question about the automatic line breaking in latex. Right now i wright some text and its formatting it like this:

Lorem Ipsum is simply dummy text
of the printing and typesetting
industry. Lorem Ipsum has been
the industry’s standard dummy
text ever since the 1500s, when
an …

But I want to have something like that:

Lorem Ipsum is simply dummy text
of the printing and typesetting i
ndustry. Lorem Ipsum has been the
industry’s standard dummy text ev
er since the 1500s, when an …

so with every end of line, just keep the first characters of a word to the end and go on with the rest in the new line. So to say, just continuing the text flow without holding words together.

Is this kind of formatting possible in latex?

  • 1
    Do you need it -in all of your document. -in a paragraph. -in an environment. -or are you willing to do formatting on single words? – hpekristiansen Jan 12 '14 at 14:41
  • Welcome to TeX.SX! Please add a minimal working example (MWE) that illustrates your problem. Without it we are missing some crucial details of your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – yo' Jan 12 '14 at 14:54
  • This question will help. – Masroor Jan 12 '14 at 15:29
5

This is a possibility, using the standard hyphenation. For enabling hyphenation "everywhere", a new set of patterns should be prepared. See below for a different approach; in the next code, the \hyphenchar is set to an invisible one; the setting must be restored manually, because a setting of the \hyphenchar is inherently global.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\newenvironment{zerohyphen}
 {\global\chardef\savedhyphenchar=\hyphenchar\font % save the current hyphenchar
  \lefthyphenmin=1 \righthyphenmin=1 % no limits on hyphenation
  \hyphenchar\font=23 }
 {\par\hyphenchar\font=\savedhyphenchar}% eject the paragraph and restore

\begin{document}

\hyphenpenalty=-100 % just to make hyphenation more desirable

\begin{minipage}{3.5cm}
\begin{zerohyphen}
Lorem Ipsum is simply dummy text
of the printing and typesetting
industry. Lorem Ipsum has been
the industry’s standard dummy
text ever since the 1500s, when
an
\end{zerohyphen}
\end{minipage}
\end{document}

enter image description here

Here's a different approach (notice, however, that cooperation with UTF-8 would be complicated); the text is split at spaces and every word is printed letter by letter with a zero penalty between any two letters.

\documentclass{article}
\usepackage{xparse,environ}
\ExplSyntaxOn
\NewEnviron{zerohyphen}
 {
  \par
  \franx_zerohyphen:V \BODY
  \par
 }

\seq_new:N \l_franx_body_seq

\cs_new_protected:Npn \franx_zerohyphen:n #1
 {
  \seq_set_split:Nnn \l_franx_body_seq { ~ } { #1 }
  \seq_map_inline:Nn \l_franx_body_seq { \franx_printword:n { ##1 } }
 }
\cs_generate_variant:Nn \franx_zerohyphen:n { V}

\cs_new_protected:Npn \franx_printword:n #1
 {
  \tl_map_inline:nn { #1 } { ##1 \penalty0 \scan_stop: }
  \c_space_tl
 }
\ExplSyntaxOff

\begin{document}

\begin{minipage}{3.5cm}
\begin{zerohyphen}
Lorem Ipsum is simply dummy text
of the printing and typesetting 
industry. Lorem Ipsum has been 
the industry's standard dummy 
text ever since the 1500s, when 
an
\end{zerohyphen}
\end{minipage}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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