[XeTeX] Roman Numerals as stylistic alternatives

enrico.gregorio at univr.it enrico.gregorio at univr.it
Tue Jun 21 21:23:40 CEST 2011


From: enrico.gregorio at univr.it

> I'll think to a way for adding the /ActualText to the macros I 
> showed you.

There is a way, via the accsupp package by Heiko Oberdiek:

===
\documentclass{article}
\usepackage{fontspec}
\setmainfont[Ligatures=TeX]{DejaVu Serif}

\usepackage{accsupp}
\makeatletter
\def\@URomanx#1{\ifcase#1\or
  Ⅰ\or Ⅱ\or Ⅲ\or Ⅳ\or Ⅴ\or Ⅵ\or Ⅶ\or Ⅷ\or Ⅸ\or Ⅹ\or Ⅺ\or Ⅻ\else
  \expandafter\@slowURoman\romannumeral #1@\fi}
\def\@slowURoman#1{\ifx @#1% then terminate
     \else
       \if i#1Ⅰ\else\if v#1Ⅴ\else\if x#1Ⅹ\else\if
       l#1Ⅼ\else\if c#1Ⅽ\else\if d#1Ⅾ\else \if
       m#1Ⅿ\else#1\fi\fi\fi\fi\fi\fi\fi
       \expandafter\@slowURoman
     \fi
}
\def\@Uromanx#1{\ifcase#1\or
  ⅰ\or ⅱ\or ⅲ\or ⅳ\or ⅴ\or ⅵ\or ⅶ\or ⅷ\or ⅸ\or ⅹ\or ⅺ\or ⅻ\else
  \expandafter\@slowUroman\romannumeral #1@\fi}
\def\@slowUroman#1{\ifx @#1% then terminate
     \else
       \if i#1ⅰ\else\if v#1ⅴ\else\if x#1ⅹ\else\if
       l#1ⅼ\else\if c#1ⅽ\else\if d#1ⅾ\else \if
       m#1ⅿ\else#1\fi\fi\fi\fi\fi\fi\fi
       \expandafter\@slowUroman
     \fi
}
\def\Ordinal#1{%
  \BeginAccSupp{method=escape,ActualText=#1}%
  \@URomanx{#1}\EndAccSupp{}}
\def\ordinal#1{%
  \BeginAccSupp{method=escape,ActualText=#1}%
  \@Uromanx{#1}\EndAccSupp{}}
\makeatother

\begin{document}
\Ordinal{239}

\Ordinal{8}

\ordinal{999}
\end{document}
===

Works with AR 9, though not perfectly in the selections.

Ciao
Enrico

--
Enrico Gregorio          + Dipartimento di Informatica          + Tel: +39 045 8027937
Enrico.Gregorio at univr.it + Università degli Studi di Verona     +
(gregorio at math.unipd.it) + Strada le Grazie 15 / I-37134 Verona + Fax: +39 045 8027928



More information about the XeTeX mailing list