[XeTeX] Redefining \em and \emph
Will Robertson
wspr81 at gmail.com
Sun Sep 26 12:34:08 CEST 2010
On 2010-09-25 09:33:20 +0930, Gareth Hughes
<garzohugo at gmail.com> said:
> Will Robertson wrote:
>> It doesn't seem to. In that case I'd write something like
>>
>> \let\oldemph\emph
>> \renewcommand\emph{%
>> \if at RTL \expandafter\aemph \else \expandafter\oldelse \fi
>> }
>
> I still can't figure out how to do this for \eminnershape as defined in
> fixltx2e. Any suggestions how to do that?
Do you mean so that you can write
\aemph{ ... \aemph{ ...} ... }
and have the inner \aemph not put the overline on top? In this case,
you can write (and this might be a reasonable addition to polyglossia)
\documentclass{article}
\makeatletter
\def\aemph#1{%
\begingroup
\let\aemph\inneraemph
$\overline{\hbox{#1}}$%
\endgroup
}
\def\inneraemph#1{%
\egroup% close \hbox
\egroup% close \overline
$% close math
{\eminnershape #1}% inner emphasis!
$% "reopen" math
\expandafter\overline\bgroup % "reopen" \overline
\hbox\bgroup % "reopen" \hbox
}
\makeatother
\begin{document}
hello there \aemph{foo \aemph{oof rab} bar} baz black
\end{document}
Modulo checks for bidi and using \hboxR instead of \hbox and a
"correct" definition for \eminnershape in this context, and so on. But
this has nothing to do with the idea of \eminnershape: if you want to
tie the two together, fontspec actually overrides fixltx2e's
emph/eminnershape code:
\ExplSynaxOn
\DeclareRobustCommand \em {
\@nomath\em
\tl_if_eq:xxTF \f at shape \itdefault \eminnershape
{
\tl_if_eq:xxTF \f at shape \sldefault \eminnershape \emshape
}
}
\DeclareTextFontCommand{\emph}{\em}
\cs_set_eq:NN \emshape \itshape
\cs_set_eq:NN \eminnershape \upshape
\ExplSyntaxOff
Not sure if that helps directly...
Will
More information about the XeTeX
mailing list