TransWikia.com

Biblatex: small caps for pages in roman numerals

TeX - LaTeX Asked by gattex on January 11, 2021

In Biblatex I can use roman numerals in the pages fiels and in the citation commands.
E.g.:

@InBook{id,
author    = {Surname, Name},
title     = {Title},
booktitle = {Book Title},
date      = {2000},
pages     = {x-cx},

}

or:

footcite[xc]{id}

I’d like to print the pages numbers in small caps. Is it possible somehow?

2 Answers

Here's how you can get Roman page numbers in biblatex to appear in small caps.

First we define a macro mknormrangescromannums that detects if a given number is a Roman numeral and applies additional formatting in that case. The test for Roman numerals is based on the other numeral tests of biblatex (ifinteger, ifnumeral, ifnumerals, ...).

Then we use the <itempostpro> argument of mknormrange (introduced in biblatex 3.13 [2019-08-17]) to call mknormrangescromannums on all page numbers.

documentclass[british]{article}
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage{babel}
usepackage{csquotes}

usepackage[style=authoryear, backend=biber]{biblatex}

makeatletter
defblx@hook@ifromannum{%
  defdo##1{uccode`##1=`%}%
  doidovdoxdoldocdoddom
  doIdoVdoXdoLdoCdoDdoM}

protecteddefblx@imc@ifromannumeral{%
  blx@ifnumblx@hook@ifromannum}

blx@regimcs{ifromannumeral}
makeatother

newrobustcmd*{smallcapsromannums}[1]{%
  ifromannumeral{#1}
    {textsc{lowercase{#1}}}
    {#1}}

newcommand*{mknormrangescromannums}{mknormrange[][smallcapsromannums]}

DeclareFieldFormat{postnote}{mkpageprefix[pagination][mknormrangescromannums]{#1}}
DeclareFieldFormat{pages}{mkpageprefix[bookpagination][mknormrangescromannums]{#1}}

begin{filecontents}{jobname.bib}
@InBook{id,
  author    = {Surname, Name},
  title     = {Title},
  booktitle = {Book Title},
  date      = {2000},
  pages     = {x-cx},
}
end{filecontents}
addbibresource{jobname.bib}

begin{document}
autocite[xxi]{id}

autocite[12-45]{id}

autocite[hello]{id}

printbibliography
end{document}

(Surname 2000, p. xxi) with 'xxi' in small caps

Correct answer by moewe on January 11, 2021

It is perfectly possible: add this code to your preamble to define the scroman numbering:

makeatletter
    defscroman#1{expandafter@scromancsname c@#1endcsname}
    def@scroman#1{{scshaperomannumeral #1}}
makeatother

If needed, we also can define a scosroman numbering, same as the above, except that a number such as xviii (several final is) is printed as xviij, i.e. the final i is replaced with a (smallcaps) j.

Answered by Bernard on January 11, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP