Take the 2-minute tour ×
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.

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):

Justification issue

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?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

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} 

enter image description here

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} 

enter image description here

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} 

enter image description here

share|improve this answer
    
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
1  
@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
1  
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

Your Answer

 
discard

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.