TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to define hyphenation for a word I have somewhat created.

I have a word that I have hyphenated like


The thing is that every time I want to use that word I have to write everything, including the \-. Is there a way for me to define hyphenation for a word and be able to use it through out the document?

share|improve this question
Do you write it as \url{...}? – Herbert Feb 27 '11 at 15:51
I have it like \texttt{...} – Tiago Veloso Feb 27 '11 at 15:53
Use \url then there is a possible linebreak at the dot by default. – Herbert Feb 27 '11 at 15:57
It is a bit curious to hyphenate a program path ... because nobody knows if the hyphen is part of the path or not. – Herbert Feb 27 '11 at 16:19
@Tiago: \nolinkurl{...} – Herbert Feb 27 '11 at 16:27
up vote 7 down vote accepted

It makes more sense to use \url{..} for Java package names. If you use hyperref and do not want it as a link, then use nolinkurl{...}. Urls can have a line break at the dot by default.

share|improve this answer
I assume you mean "do not want" and "dot". – lockstep Feb 27 '11 at 16:45
thanks, my brain is faster than my two fingers ... – Herbert Feb 27 '11 at 16:46

well, \hyphenation{...} won't work since there are non-letters in the string. probably the most direct approach is to just define a shorthand command that includes all the discretionary hyphens: \newcommand\compuppy{com\-.puppy\-crawl\-.tools\-.check\-style\-.apl} you might want to finish it off with \xspace to avoid having to remember to finish it off with a backslash before a space.

share|improve this answer
the xspace thing didn't work. \newcommand\compuppy{\texttt{com\-.puppy\-crawl\-.tools\-.check\-style\-.api}\x‌​space} Am I using it right? – Tiago Veloso Feb 27 '11 at 16:20
@Tiago You need \usepackage{xspace}, otherwise it is used correctly. – Christian Lindig Feb 27 '11 at 16:23
Thanks. It worked. So far this is the best answer, but Herbert has indeed raised a good question on the comments. – Tiago Veloso Feb 27 '11 at 16:29

Yes: put \hyphenation{man-u-script man-u-scripts ap-pen-dix} into the preamble.

share|improve this answer
and where are the dots? – Herbert Feb 27 '11 at 15:51
I get the following error with this Latex Error: ./report.tex:204 Not a letter. – Tiago Veloso Feb 27 '11 at 15:58
@Herbert My bad - I didn't try it. \hyphenation is incompatible with dots? It might be easier to just define a macro if there are not too many of those words and if dots need special treatment. In this context, the \discretionary command might be useful to define a new scheme how to split up words with dots. Again, I'm sorry and will delete my answer in a short while but want to give people a chance to read the comments here. – Christian Lindig Feb 27 '11 at 15:58
No need to delete the answer. It's just not the correct one. – Tiago Veloso Feb 27 '11 at 16:03

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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