I have the following situation: very long function names that are put into text with a macro \fun{this-is-a-very-long-fuction-name}. This macro includes indexing, but then finally puts the function name in bold as a hyperlink. I want to have LaTeX do line breaks for adjustment, but break the emboldened name only at the hyphens without adding a hyphen; the hyperlink must work. How can I do that? Specifically, my \fun macro is


The rest of the document should have normal line breaks with adjustment and hyphenation.

Edit: Here is an example:

we need to include the lengths of all months from Tishri until \fun{last-month-of-hebrew-year}

When compiled with latex, it produces the following in the DVI:

DVI output

Note that it breaks the function name after the "he" of "hebrew". Also, it is not a hyperlink, as it should be.

  • 4
    latex doesn't hyphenate hyphenated words, it just breaks at the existing hyphens, so it isn't clear what you need other than teh default behaviour. – David Carlisle Jun 27 '17 at 18:07
  • For example, last-month-of-hebrew-year gets hyphenated after the "he" of "hebrew" and it is not a hyperlink – Edward Reingold Jun 29 '17 at 14:31
  • @EdwardReingold Thanks, I assume you are using latex and not pdflatex, as I was able to reproduce this only with the former. I have edited the question to include your example, and voted to reopen it. (BTW, there is a warning message in the output that says “Package hyperref Warning: You have enabled option breaklinks'. But driver hdvips.def' does not suppport this. Expect trouble with the link areas of broken links.”) – ShreevatsaR Jul 3 '17 at 19:50
  • That explains the broken link; but the bad hyphenation? Is there a way around the two problems? – Edward Reingold Jul 3 '17 at 20:48
  • 2
    (@ShreevatsaR). I made some experiments with TeX’s tracing facilities, and it turned out that, when the hdvips driver is used, discretionaries are not added after explicit hyphens, contrary to what normally happens (cf. The TeXbook, p. 286, sixth to fourth line from the bottom). Since the \hyphenchar is not changed, in all probability this is achieved by typesetting the link in restricted horizontal mode and subsequently \unhboxing it; in any case, the lack of discretionaries fully explains the fact that the word “hebrew” gets hyphenated (see p. 454, esp. ll. -8 to -5). – GuM Jul 4 '17 at 20:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.