Determining the current text style?
Hi! I'd like to write some macros that do different things depending on the style of the current font. That is, \mymacro in this example \mymacro {\bf \mymacro} {\it \mymacro} should be able to do something different in each of those three cases. I remember seeing a bit of clever code in a recent message that could test whether or not it was being used in a region of typewriter font and adjust accordingly; are there similar tests that can be used for \bf, \it, and so forth? If so, what are they? (And how reliable are they?) (For those who are curious, I'm thinking about this for the LaTeX-compatiblity code I'm writing. LaTeX's \itshape command will select \it in normal font, but \bi in boldface font. LaTeX handles this by defining extra flags to keep track of the current style, but I'd like to avoid doing that if I don't need to.) Thanks, - Brooks
Brooks Moses wrote:
Hi!
I'd like to write some macros that do different things depending on the style of the current font. That is, \mymacro in this example
\mymacro {\bf \mymacro} {\it \mymacro}
should be able to do something different in each of those three cases. I remember seeing a bit of clever code in a recent message that could test whether or not it was being used in a region of typewriter font and adjust accordingly; are there similar tests that can be used for \bf, \it, and so forth? If so, what are they? (And how reliable are they?)
The thing to check is the value of \fontalternative. Look up the definition of \em in font-ini.tex for its usage. Cheers, Taco
Brooks Moses wrote:
Hi!
I'd like to write some macros that do different things depending on the style of the current font. That is, \mymacro in this example
\mymacro {\bf \mymacro} {\it \mymacro}
should be able to do something different in each of those three cases. I remember seeing a bit of clever code in a recent message that could test whether or not it was being used in a region of typewriter font and adjust accordingly; are there similar tests that can be used for \bf, \it, and so forth? If so, what are they? (And how reliable are they?)
(For those who are curious, I'm thinking about this for the LaTeX-compatiblity code I'm writing. LaTeX's \itshape command will select \it in normal font, but \bi in boldface font. LaTeX handles this by defining extra flags to keep track of the current style, but I'd like to avoid doing that if I don't need to.)
see definition of \em in font-ini (\fontstyle \fontalternative cum suis) (btw, there is probbaly already quite some 'compatibility code' there) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
participants (3)
-
Brooks Moses
-
Hans Hagen
-
Taco Hoekwater