# Custom \hyphenation rule does not work on Overleaf

I want to break a long word to the next line in a 2-columns acmart template. The word is Sample_Super.Very.Uber.Long.Word. I have tried with \hyphenation{Sample_Super-.Very-.Uber-.Long-.Word} but it does not break the word.

Below is the sample on Overleaf:

\documentclass[sigconf]{acmart}
\usepackage[utf8]{inputenc}
\usepackage{hyphenat}
\hyphenation{Sample_Super-.Very-.Uber-.Long-.Word}

\title{test}

\begin{document}

\maketitle

\section{Introduction}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Sample_Super.Very.Uber.Long.Word Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

\end{document}


I also got an error notification on Overleaf that says Improper \hyphenation will be flushed. Not a letter. even though the document still compiles. How do I set this rule? the same word can appear at many places so I'd like to set a global rule on this.

• Have you tried removing the dots from the \hyphenation entry? Jan 15, 2020 at 21:05
• @PhelypeOleinik the dot is part of the word. Jan 15, 2020 at 21:08
• Having dots in a "word" will almost certainly make it inappropriate for an ordinary \hyphenation pattern. What you can do is create a macro equivalent with explicitly defined hyphenation points, then always enter it using the macro. (This is not a limitation of Overleaf; it's built into TeX.) Jan 15, 2020 at 21:09
• @barbarabeeton could you help with the macro? I am new to macro... Basically, I have many words that contain . It's actually some variable names. Jan 15, 2020 at 21:11
• I can probably help, but will need to do some research first. (I don't delve into the guts of TeX hyphenation primitives every day. If someone else gets there first, that's okay with me.) Jan 15, 2020 at 21:13

To make something a letter for consideration for hypehnation it needs to have a non zero lower-case code (it can lowercase to itself)

\documentclass[sigconf]{acmart}
\usepackage[utf8]{inputenc}
\usepackage{hyphenat}
\lccode\_=\_
\lccode\.=\.
\catcode\_=12 % use  \sb for math subscripts
\hyphenation{Sample_Super-.Very-.Uber-.Long-.Word}
\showhyphens{Sample_Super-.Very-.Uber-.Long-.Word}

\title{test}

\begin{document}

\maketitle

\section{Introduction}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Sample_Super.Very.Uber.Long.Word Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

\end{document}

• This works :) but is there a general way? Like a macro as @barbara beeton comments? This is because I have many similar long words with . and _ in them Jan 15, 2020 at 21:22
• that's just one document setting, it applies to all words, but I suspect that you do not want hyphenation at all and just allow breaking on . and _ in which case look at the url package (but the question as asked is about \hyphenation Jan 15, 2020 at 21:24
• url works too, but in the final pdf, if I hover the mouse over such word, it will act as if it's an URL, also, in some viewer, it may have a blue box around it. Secondly, what I meant about a macro is something that would behave like url in terms of breaking, but not treat the words as an URL. I have many different long words like Another_Super.Long.Word, etc. So defining rule for each would be tedious and may be used as last resort. Jan 15, 2020 at 21:36
• @hydradon no I said the url package not the \url command, the url package just arranges line breaking it is hyperef that adds linking. the url package would allow you to define a custom command, or use \path which is like \url but hyperref does not activate it Jan 15, 2020 at 21:56
• the \path changes the font and add some extra spaces around the word. Could you show me how to override that? Or how to use a customized command from the url` package? Jan 15, 2020 at 22:21