# Enable automatic hyphenation for Cthulhu-style's document

This question is based on the following thread: How do I make my document look like it was written by a Cthulhu-worshipping madman? ,where doncherry has provided a nice answer with the highest rate. (I can not post my question on that thread, and I don't know why, so I start a new thread here. )

However, after I tried his code, I find that LaTeX is unable to automatically hyphenate any word under the user-defined environment \Cthulhu. I think the reason of such disability is due to the use of turnbox, which turns each word by a random angle, rather than turning each letter. This is just my guess. Anyway, without hyphenation, the document looks odd and not beautiful.

My question:

1. How can I enable automatic hyphenation for the Cthulhu-style's document provided by the user doncherry?

2. Based on the answer from doncherry, how can I turn each letter by a random angle, rather than turning each word please?

Thanks a lot!

-
Welcome to TeX.SE. Starting a new thread here is the right way to do it. Please don't ask questions on other questions' answers sections. –  percusse Jul 24 '12 at 8:54
Would a Cthulhu-worshipping madman hyphenate his handwriting? Maybe you should use \raggedright instead. –  Jellby Jul 24 '12 at 9:05
Sorry, what I said was "Cthulhu-style's document", rather than "Cthulhu-worshipping madman handwriting". I am sure that there are some normal-men who do hyphenate their article. –  c t Jul 24 '12 at 9:24

I didn't have the fonts so this madman uses computer modern.

\documentclass[17pt]{extarticle}% This is a document class providing more font size options

\usepackage[svgnames]{xcolor}
\usepackage{graphicx}
%\usepackage{emerald}% font package
\usepackage[doublespacing]{setspace}% line spacing
\usepackage[T1]{fontenc}
\usepackage{wallpaper}

% thanks to Bruno Le Floch: http://tex.stackexchange.com/q/9331/4012
% and in his comments to http://tex.stackexchange.com/a/29458/4012
\usepackage{rotating}
\usepackage[first=-6,last=6]{lcg}% you can play around with these values
\makeatletter
\newcommand{\globalrand}{\rand\global\cr@nd\cr@nd}
\makeatother

\newcommand{\randomrotation}[1]{\globalrand\turnbox{\value{rand}}{#1}\phantom{#1}}

% thanks to Martin Scharrer: http://tex.stackexchange.com/q/11598/4012
\makeatletter
\def\cthulhu#1{%
\@cthulhu#1 \@empty
}
\def\@cthulhu#1 #2{%
\setbox0\hbox{\ifx\foo#1\global\let\xxfoo\relax\else\global\let\xxfoo\randomrotation\fi}%
\xxfoo{#1}\space
\ifx #2\@empty\else
\expandafter\@cthulhu
\fi
#2%
}

\def\foo#1{\yyfoo#1\relax}

\def\yyfoo#1\-#2\relax{%
\discretionary{\randomrotation{#1-}}{\randomrotation{#2}}{\randomrotation{#1#2}}}

\makeatother
% ----------

\newcommand{\eldersign}{X}

\renewcommand*{\rmdefault}{fts}

\textwidth=.6\textwidth
\hyphenpenalty=-0

\begin{document}\pagestyle{empty}

%\CenterWallPaper{}{backgroundimagefile}

\centering% that madman wouldn't justify his writings
\color{MidnightBlue}% my pick for "looks like ink"

\cthulhu{Hello, I am crazy. I am a Cthulhu \foo{worsh\-ipping} \foo{gibb\-ering} \foo{mad\-man}, \foo{un\-hinged} by
the horrors I have witnessed. I am a Cthulhu \foo{worsh\-ipping} \foo{gibb\-ering} \foo{mad\-man}, \foo{un\-hinged} by
the \foo{horr\-ors} I have witnessed. I am a Cthulhu \foo{worsh\-ipping} \foo{gibb\-ering} \foo{mad\-man}, \foo{un\-hinged} by
the horrors I have witnessed. I am a Cthulhu \foo{worsh\-ipping} \foo{gibb\-ering} \foo{mad\-man}, \foo{un\-hinged} by
the horrors I have witnessed. I am a Cthulhu \foo{worsh\-ipping} \foo{gibb\-ering} \foo{mad\-man}, \foo{un\-hinged} by
the horrors I have witnessed.} \eldersign

\end{document}

-
Hello, David! Thank you for posting your solution. Could you put some comments on your code please? I don't understand what you are doing. Is your code able to rotate each letter by a random angle, rather than rotating each word? Moreover, I was saying to enable AUTOMATIC hyphenation. However, what you did is to hyphenate manually. I don't think you can manually hyphenate some long document with 50 pages. Thank you very much, David! –  c t Jul 24 '12 at 23:28
well it's semi-automatic hyphenation. You need to mark the possible hyphention points but tex still chooses automatically where hyphens are needed. It's not really a problem in a long document, even in that short one, I just globally replaced madman by \foo{mad\-man} using my editor. As is you need \foo and can only mark one point per word, although that is just to make the coding easier. But it would be much harder to not mark the hyphenation points. –  David Carlisle Jul 25 '12 at 6:58
In a long document, there are thousands of words that you need globally to replace, and the more important is that without checking on each line of the document, you don't know which word you need to globally replace. This would be a too tedious job. I don't think your method works. However, thank you very much, David! –  c t Jul 26 '12 at 22:44
If you would really set more than a page in that style you should put a health warning on the front cover. You surely are not really planning to set thousands of words randomly mis-aligned? One page as a joke, perhaps! –  David Carlisle Jul 27 '12 at 0:26
I think if rotate each letter by a random angle rather than rotating each word by using turnbox, then the feature of automatic hyphenation can be enabled by TeX. –  c t Jul 27 '12 at 0:57
show 1 more comment