Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Post History

50%
+0 −0
Q&A How can I prevent, or work around, unfortunate hyphenation in critical words?

In technical documentation, sometimes the tool's automatic hyphenation makes a bad break in the middle of a term, like the name of an environment variable or function. In these cases I would rathe...

1 answer  ·  posted 10y ago by Monica Cellio‭  ·  last activity 4y ago by System‭

#3: Attribution notice added by user avatar System‭ · 2019-12-08T03:08:47Z (over 4 years ago)
Source: https://writers.stackexchange.com/q/9166
License name: CC BY-SA 3.0
License URL: https://creativecommons.org/licenses/by-sa/3.0/
#2: Initial revision by (deleted user) · 2019-12-08T03:08:47Z (over 4 years ago)
In technical documentation, sometimes the tool's automatic hyphenation makes a bad break in the middle of a term, like the name of an environment variable or function. In these cases I would rather have a short line than hyphenation, though I want hyphenation in the document in general. I can try to "write around" egregious cases to try to avoid the problem term being near the end of a line, but that's fragile. I'm looking for a solution that fixes all of them, without me having to individually handle each case.

I am using DocBook, which we transform to Formatting Objects (FO) and thence to PDF. Ideally I would like to be able to write a style directive that says "don't hyphenate inside these XML elements" and apply it to \<classname\>, \<methodname\>, and several others. [This FO documentation](http://www.sagehill.net/docbookxsl/PrintCustomEx.html#Hyphenation) describes a way to do this at the page-block level, e.g. to turn off hyphenation in a table of contents or a preface, but that's too coarse. [This forum post](http://docbook.10921.n7.nabble.com/Disabling-hyphenation-on-selected-string-td7037.html) suggests a way to hard-wire them within the text, meaning I would have to put a special directive around _each_ class name, method name, and so on. (Also, it sounds like it didn't work for him.)

How can I most easily prevent bad hyphenation breaks in my code elements, working within the tool chain I have? (I'm not free to change that.)

#1: Imported from external source by user avatar System‭ · 2013-10-16T18:01:29Z (over 10 years ago)
Original score: 8