I've been struggling with some long glossary word descriptions that are not breaking correctly. I found a link to a question about hyphens, but it only solves part of a part of my problem. For the most part, the hyphenated acronyms have been fine (see line 1 and fix in line 10/11), however I haven't been able to figure out what to do about line 12. I'd like there to be able to be a break between the long and short form of the acronym, but I'm not sure how to make this happen. I am using PDFLaTex to compile, which is also something that I saw mentioned here, but this doesn't seem to help this particular problem.
\documentclass[smallextended]{article}
\usepackage{glossaries}
\usepackage{lipsum}
\usepackage{lineno}
\linenumbers
\newacronym{PHBV}{PHBV}{poly(hydroxybutyrate-\textit{co}-hydroxyvalerate)}
%Same acronym, just with a hyphen added
\newacronym{PHBVh}{PHBV}{poly(hydroxybutyrate-\textit{co}-hydroxy\-valerate)}
\begin{document}
%What happens most of the time and so you can see paragraphs
Lorem ipsum dolor sit amet, consectetuer adipiscing \gls{PHBV}.
\lipsum[57]
\glsresetall
%Without the hyphen
Cras tincidunt turpis ligula, ut abcdefghijkl \gls{PHBV}.
%Using the manually inputted hyphen
Cras tincidunt turpis ligula, ut abcdefghijkl \gls{PHBVh}.
\glsresetall \Gls{PHBV}.
\glsresetall
%This is the problem:
Cras tincidunt turpis ligulala, \gls{PHBVh}.
\end{document}
Best Answer
The problem is unrelated to
glossaries
. You get the same behaviour if you write the name manually. This is because words containing dashes are not allowed to break anywhere else than at the dashes. Search this site for hyphenating compound words and you'll find your question and answers a few times.Since you're probably using the
babel
package you can for example use\babelhyphen{hard}
instead of the dashes:Depending on the language of your document there are maybe shorthands defined for this already (e.g.,
ngerman
has"=
for the hard babelhyphen) or you can define one yourself:Another possibility would be to use the
chemmacros
package and its\iupac
command which seems quite fitting for your case:A complete example: