# Define global hyphenation for words containing numbers

In my thesis a have a lot of occurences of the word like ABC2011abc and I want them to be hyphenated as ABC2011\-abc.

Is it possible to define a global hyphenation rule, like say with \hyphenation?

Search and replace would be a last measure and feels very un-LaTeX.

-
How about defining a macro for this? \newcommand{\ABC2011abc}{ABC2011\-abc} – ℝaphink Apr 27 '11 at 7:54
@Raphink: Numbers are not allowed in macro names. Nevertheless, your idea to define a macro is good. Just the name must be changed a little. – Martin Scharrer Apr 27 '11 at 8:02
@Martin: Ah right, thanks. – ℝaphink Apr 27 '11 at 8:06
@Raphink: You should put your (corrected) suggestion in an answer, so that the community can upvote it. – ipavlic Apr 27 '11 at 8:18
@Ipavlic: right, I will thanks. – ℝaphink Apr 27 '11 at 8:24

Since \hypenation doesn't take numbers, you could define a macro for it:

\newcommand{\ABCTwoZeroElevenabc}{ABC2011\-abc}


and use it everytime you want to typeset this word.

-
You might want to add \xspace from the xspace package at the end of the replacement text, otherwise you have to add {} after the macro to avoid the removal of following spaces. Also I would use a short macro name, otherwise it's easier to type the \- by hand. – Martin Scharrer Apr 27 '11 at 8:30
@Martin: thanks for the suggestion of using xspace. I'm actually used to adding {} after most macros when I call them, since this is how many standard (e.g. frenchb) macros behave. There's still an advantage of using a macro over adding \- manually, which is to modify the macro later on if required. – ℝaphink Apr 27 '11 at 8:35
Thanks for the answer, I'll give that a try – tobi Apr 27 '11 at 8:55
@Tobi: As @Martin said, you can change the macro name (without using digits though) to make it easier to type. – ℝaphink Apr 27 '11 at 8:57
I just got bitten by a global search and replace to put the macros i defined in place. I think it's going to be a lot easier to just replace the overflowing occurrences of the words just before printing. – tobi Apr 27 '11 at 9:13

A variant on Raphink's answer: define a macro like

\def\ABC2011abc{ABC2011\-abc}


(i.e. not using \newcommand). This makes a "delimited macro" using a plain TeX construction, where the 2011abc part is not actually in the name of the macro but is required to be present when the macro is expanded. The actual name of the macro is \ABC, so this is prone to unexpected errors if you also define \ABC2011cde, however.

For some reason, this gives bizarre results using \newcommand, probably because of how it internally processes the macro name to check that it was not previously defined.

-