[texhax] [Tex Help] How can (La)TeX break word with underscores (_) at arbitary place?

Wei_Hu at mtk.com.tw Wei_Hu at mtk.com.tw
Wed Oct 18 04:16:50 CEST 2006


Dear all,

When I write design documents, review documents, or coding notes for a 
program project,
I always refer to function names, variable names, and class names in that 
program.
However, these types of strings can not be arranged by (La)TeX well.

For example,

A macro named 'SECONDARY_EXTSRAM_LARGEPOOL_NORMAL', (La)TeX doesn't know
how to break this string at the page margin. The final result I got shown 
below:

..........................................................................
..........................................................................
...................................... SECONDARY_EXTSRAM_LARGEPOOL_NORMAL
..........................................................................
..........................................................................

This is ugly.
Then I use some solutions I can find:

1) use \- to mark places where (La)TeX can break:

Ex: SECONDARY\-\_EXTSRAM\-\_LARGEPOOL\-\_NORMAL

However, this will make (La)TeX inserts a hyphen (-),
and still can not break at the middle of SECONDARY, EXTSRAM, LARGEPOOL, 
NORMAL.

Then the result will be:

..........................................................................
..........................................................................
...................................... SECONDARY_EXTSRAM_-
LARGEPOOL_NORMAL .............................
..........................................................................
..........................................................................

It is still not good.

2) I don't want the additional hyphen, so I use \discretionary{}{}{} 
instead of \-:

Ex: 
SECONDARY\discretionary{}{}{}\_EXTSRAM\discretionary{}{}{}\_LARGEPOOL\discretionary{}{}{}\_NORMAL

The effect of this method is almost the same with the one above, except 
the additional hyphen.
The result of this follows.

..........................................................................
..........................................................................
...................................... SECONDARY_EXTSRAM_
LARGEPOOL_NORMAL .............................
..........................................................................
..........................................................................

3) Use \path from path package (path.sty):

The effect of this method is completely the same with the one of method 2.

Ex: \path|SECONDARY_EXTSRAM_LARGEPOOL_NORMAL|

will produce

..........................................................................
..........................................................................
...................................... SECONDARY_EXTSRAM_
LARGEPOOL_NORMAL .............................
..........................................................................
..........................................................................

Even worse, this \path command conflicts with the listings package and the 
longtable packages.

Does anyone knows how can I break a special string at any character in it?
Maybe there is a package named forcebreak, and there is a command 
\forcebreakhere in it.

\usepackage{forcebreak}
....
........... \forcebreakhere{SECONDARY_EXTSRAM_LARGEPOOL_NORMAL} ......
....

Then the result is:

..........................................................................
..........................................................................
...................................... SECONDARY_EXT
SRAMLARGEPOOL_NORMAL .................
..........................................................................
..........................................................................

or

..........................................................................
..........................................................................
...... SECONDARY_EXTSRAMLARGEPOO
L_NORMAL ...................................................
..........................................................................

depends on the context.

Does such a package exist?
Or can I use some other methods to accomplish this?

Thanks very much.
Wei.


************* Email Confidentiality Notice ********************

The information contained in this e-mail message (including any attachments) may be confidential, proprietary, privileged, or otherwise exempt from disclosure under applicable laws. It is intended to be conveyed only to the designated recipient(s).  Any use, dissemination, distribution, printing, retaining or copying of this e-mail (including its attachments) by unintended recipient(s) is strictly prohibited and may be unlawful. If you are not an intended recipient of this e-mail, or believe that you have received this e-mail in error, please notify the sender immediately (by replying to this e-mail), delete any and all copies of this e-mail (including any attachments) from your system, and do not disclose the content of this e-mail to any other person.   Thank you!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://tug.org/pipermail/texhax/attachments/20061018/6ef0a8cc/attachment.html 


More information about the texhax mailing list