tags:

views:

26

answers:

1

I'm trying to output RTF (Rich Text Format) from a Ruby program - and I'd prefer to just emit RTF directly without using the RTF gem as I'm doing pretty simple stuff.

I would like to highlight specific characters in a DNA sequence alignment and from the docs it seems that I can either use \highlightN ... \highlight0 or \cbN ... \cb1

The problem is that I cannot get \cb to work in either Word:Mac 2008 or Mac TextEdit (\cf works fine so I know it's not a color table issue)

\highlight does work but seemingly only with two of the possible colors (black and red) and \highlight does not use the custom color table.

By creating simple docs in Word with character shading and saving as RTF I can see blocks of ridiculously verbose RTF code that presumably does what I want, but it is so impenetrable that I'm not seeing the wood for the trees.

Part of the problem may well be that Mac Word is just not implementing RTF properly. I don't have a Windows version of Word handy.

Anyone know the right way to shade blocks of text?

Thanks --Rob

A: 

There is a note in the RTF Pocket Guide that says MS Word does not implement the \cb command. It says MS Word uses \chshdng0\chcbpatN (where "N" is the color number that you would use with \cb). The book recommends using something like the following for compatibility with programs that implement \cbN and/or \chshdng0\chcbpatN: {\chshdng0\chcbpat5\cb5 text}.

Note: The copy of the book I have was published in 2003, so it might be a bit out-of-date.

joast