Numeri romani e XeLaTeX

  • Creatore
    Topic
  • #60188
    Up
    0
    Down
    ::


    Penso di far cosa gradita a qualcuno con questo codice:
    `\makeatletter
    \def\URoman#1{\expandafter\@URoman\csname c@#1\endcsname}
    \def\Uroman#1{\expandafter\@Uroman\csname c@#1\endcsname}
    \def\URomanx#1{\expandafter\@URomanx\csname c@#1\endcsname}
    \def\Uromanx#1{\expandafter\@Uromanx\csname c@#1\endcsname}

    \def\@URoman#1{\expandafter\@slowURoman\romannumeral #1@}
    \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\@Uroman#1{\expandafter\@slowUroman\romannumeral #1@}
    \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
    }
    \makeatother`
    È modellato sul modo di ottenere un numero in cifre romane del nucleo di LaTeX, ma usa i “veri” numerali. Funziona come le normali assegnazioni della rappresentazione di un contatore: scegliendo uno dei \renewcommand che seguono si ottiene una diversa rappresentazione del contatore.
    `\newcounter{pippo}
    \renewcommand{\thepippo}{\URoman{pippo}}
    \renewcommand{\thepippo}{\Uroman{pippo}}
    \renewcommand{\thepippo}{\URomanx{pippo}}
    \renewcommand{\thepippo}{\Uromanx{pippo}}`
    I comandi possono essere usati anche direttamente: per avere i numeri romani “maiuscoletti” è sufficiente dire, per esempio,
    `\small\URoman{page}`
    Qual è la differenza fra \URoman e \URomanx? Che il secondo usa i caratteri specifici per i numeri da 1 a 12; dunque \URomanx e \Uromanx sono utili solo se i numeri da rappresentare sono in questo intervallo.

    Naturalmente occorre che il font possieda i caratteri, che stanno nel blocco U+2160–U+217F; sono disponibili in

      Asana Math, Charis SIL, DejaVu Sans, DejaVu Serif, EB Garamond, FreeMono, FreeSans, FreeSerif, JUnicode, Linux Biolinum O, Linux Libertine O, OldStandard

    e qualche altro.

    Ciao
    Enrico

  • Devi essere connesso per rispondere a questo topic.

Go to top