0

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. Below is the sample on Overleaf:

\documentclass[sigconf]{acmart}
\usepackage[utf8]{inputenc}

\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 have attempted:

  • using \hyphenation{Sample_Super-.Very-.Uber-.Long-.Word} but this is tedious because I have many different long words.
  • The \path command, but this changes the font of the word and add some space around it.
  • The \url command, which breaks line as I want without changing the font, however, it creates a hyperlink which sometimes shows a blue box around the word.
  • I have read the url package to create a customized command but have not figured out how.

How do I define a command with the url package? Or how do I achieve the same behaviour of \path without changing the font or adding the space?

0
1

If I understand your objective correctly, you're not actually looking to hyphenate a long word. Instead, you're simply looking to create a suitable line-break in that word. Is this interpretation correct?

I suggest you (a) load the xurl package, which allows for arbitrary line breaks in the argument of \url, and (b) use \nolinkurl instead of \url. This change is needed to make sure that the quasi-URL string isn't made into a hyperlink.

A full MWE (minimum working example):

\documentclass[sigconf]{acmart}
\usepackage[utf8]{inputenc}
\usepackage{xurl} % <-- new

\title{test}

\begin{document}
\maketitle

\section{Introduction}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor 
incididunt dolore magna aliqua. \nolinkurl{Sample_Super.Very.Uber.Long.Word} 
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut 
aliquip ex ea commodo consequat. 
\end{document}

Addendum: Here's a screenshot of the left-hand column produced by this MWE. I've highlighted the output of the \url directive in yellow. Aside: I use MacTeX2019, and I compiled the test document with pdfLaTeX. I use LaTeX2e <2019-10-01> patch level 3 and the acmart 2020/01/11 v1.67 document class.

enter image description here

5
  • it will cause the S in Super to become like subscript, next to the e while the underscore _ disappears. So it's like Samplesuper.Very.Uber.Long.Word I have tried to escape the underscore like \_ but it does not fix.
    – hydradon
    Jan 18 '20 at 19:27
  • @hyradon — Did you load the xurl package and encase the very long word in a \nolunkurl directive?
    – Mico
    Jan 19 '20 at 6:43
  • I copy your code onto Overleaf. Could you check on your side?
    – hydradon
    Jan 19 '20 at 7:36
  • @hydradon - Please see the addendum I just posted, including the screenshot.
    – Mico
    Jan 19 '20 at 8:54
  • it works on my local PC, but not Overleaf. I guess it's different engine, maybe. But thank you for the solution, I'll stick to my local PC
    – hydradon
    Jan 19 '20 at 16:51

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.