# Justification issue with underscored words

I have a problem with justification in one line:

Similarly to CUDA, OpenACC benchmarks define TILE\_DIM as 32 and BLOCK\_ROWS as 8.


This line on my document has justification issues, as can be seen below (the image is from the right margin of the text, you can see that the line above is not aligned with the rest of the text):

If I remove the underscores, justification works fine. Does anyone know why this is happening, and how should I fix it? Is this a known problem?

-

One option would be to load the underscore package to allow hyphenation after the underscore:

\documentclass{article}
\usepackage{underscore}

\begin{document}

\noindent Similarly to CUDA, OpenACC benchmarks define TILE\_DIM as 32 and BLOCK\_ROWS as 8.

\end{document}


However, I don't know if a hyphen right after the underscore is a good option; to avoid the hyphen you can load the package with the nohyphen option:

\documentclass{article}
\usepackage[nohyphen]{underscore}

\begin{document}

\noindent Similarly to CUDA, OpenACC benchmarks define TILE\_DIM as 32 and BLOCK\_ROWS as 8.

\end{document}


To avoid conflicts with the underscore in places like in the argument of \includegraphics, the package offers the strings option:

\usepackage[nohyphen,strings]{underscore}


Another option would be to try rephrasing the sentence, if possible, so that a line break doesn't occur at the problematic string (this doesn't require any packages and looks much better):

\documentclass{article}

\begin{document}

\noindent OpenACC benchmarks define TILE\_DIM as 32 and BLOCK\_ROWS as 8, similarly to CUDA.

\end{document}


-
Thanks Gonzalo, great answer. Now my issue with the underscore package is that it my figures are no longer recognized (they include underscores on their names). Is there a clean way of getting it to work or I'll have to rename all my figures? –  leo Dec 4 '12 at 2:27
@leo you can load the package with the strings option: \usepackage[nohyphen,strings]{underscore} –  Gonzalo Medina Dec 4 '12 at 2:29
it worked! Many thanks! –  leo Dec 4 '12 at 2:30
@leo You're welcome! –  Gonzalo Medina Dec 4 '12 at 2:31
Can you please add \noindent OpenACC benchmarks define TILE\_DIM as 32 and BLOCK\_ROWS as 8, similarly to CUDA. in your MWE to show the much more better typography of rephrasing? –  Kurt Dec 4 '12 at 2:34
show 1 more comment