0

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}
2

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.

  1. Since you're probably using the babel package you can for example use \babelhyphen{hard} instead of the dashes:

    poly(hydroxybutyrate\babelhyphen{hard}\textit{co}\babelhyphen{hard}hydroxyvalerate)
    

    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:

    \useshorthands*{"}
    \defineshorthand{"-}{\babelhyphen{hard}}
    ...
    poly(hydroxybutyrate"-\textit{co}"-hydroxyvalerate)
    
  2. Another possibility would be to use the chemmacros package and its \iupac command which seems quite fitting for your case:

    \iupac{poly(hydroxybutyrate-\textit{co}-hydroxyvalerate)}
    

A complete example:

\documentclass{article}
\usepackage[english]{babel}

% depending on the language of your document this may or may not be necessary:
\useshorthands*{"}
\defineshorthand{"-}{\babelhyphen{hard}}

\usepackage{glossaries}

\usepackage{chemmacros}
\NewChemIUPAC\co{\textit{co}}

% \iupac-commands are only defined within \iupac so we need to prevent
% glossaries from expanding its fields (this may or may not have
% unexpected effects…)
\glsnoexpandfields
\newacronym{PHBVa}{PHBV}{\iupac{poly(hydroxybutyrate-\co-hydroxyvalerate)}}

% depending on the language of your document this may or may not be necessary:
% \shorthandon{"}
\newacronym{PHBVb}{PHBV}{poly(hydroxybutyrate"-\textit{co}"-hydroxyvalerate)}

\usepackage{showframe}

\begin{document}

% 
Cras tincidunt turpis ligula, ut abcdefghijkl
poly(hydroxybutyrate-\textit{co}-hydroxyvalerate)

% with \iupac
Cras tincidunt turpis ligula, ut abcdefghijkl
\iupac{poly(hydroxybutyrate-\co-hydroxyvalerate)}

% with babel
Cras tincidunt turpis ligula, ut abcdefghijkl
poly(hydroxybutyrate"-\textit{co}"-hydroxyvalerate)

% with glossaries and \iupac
Cras tincidunt turpis ligula, ut abcdefghijkl \gls{PHBVa}

% with glossaries and babel
Cras tincidunt turpis ligula, ut abcdefghijkl \gls{PHBVb}

\end{document}

enter image description here

0

Well, this is a bit of a hack, but this is what I am doing. Please let me know if there is a better way!

\acrlong{PHBV} \linebreak (\acrshort{PHBV}) \glsunset{PHBV}

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.