0

I know that is unusual to ask two questions in a single topic, but somehow they are related: first is technical and second is related to style.

First: I have a .tex file that I use as bibliography database. It shows cite keys in red. The problem is that I can't use it along annotation. If I enable syntax to show cite keys, I can't see annotation.

Second: I want annotation to be smaller than the font I use to display references.

Here is the MWE. Note the part to display the cite keys. With this enabled, the annotation disappears.

\documentclass[british]{article}
\usepackage[margin=2cm]{geometry}
\usepackage{expl3}
\RequirePackage{fontspec}
\setmainfont{texgyretermes}[
  Ligatures = {TeX},
  Extension = {.otf},
  UprightFont = {*-regular},
  ItalicFont = {*-italic},
  BoldFont = {*-bold},
  BoldItalicFont = {*-bolditalic}
]%%
\usepackage[romanian]{babel}
\usepackage{csquotes}

\usepackage[%
  abbreviate=false,% 
  annotation, % 
  cmsbreakurl, % 
  sorting=nyt, % 
  maxnames=3, % 
  minnames=1, % 
  isbn=false, % 
  url=true, % 
  date=long, % 
  cmsdate=both, % 
  bibencoding=inputenc,%
  bibannotesep=vpar,%
  longcrossref=bib,%
  bookpages=true,%
  doi=true,%
  related=true,%
  notes]%
{biblatex-chicago}

% Show citekeys at the end of reference

\DeclareFieldFormat{entrykey}{%
  \textcolor{red}{%
    \mkbibbrackets{#1}}}

\renewbibmacro*{finentry}{%
  \setunit{\finentrypunct\addspace}%
  \printfield{entrykey}%
  \renewcommand\finentrypunct{}%
  \finentry
}

\NewBibliographyString{revisededition}
\DefineBibliographyStrings{romanian}{revisededition = {ediție revizuită}}

% divide bibliography by keywords
% see https://tex.stackexchange.com/questions/634876/biblatex-bibliography-divided-by-every-keyword

\ExplSyntaxOn
\makeatletter
\def\blx@addkeyword#1#2{%
  \seq_if_exist:cF {g_hchr_keyword_\the\c@refsection _seq}
    {
      \seq_new:c {g_hchr_keyword_\the\c@refsection _seq}
    }
  \seq_if_in:cxF {g_hchr_keyword_\the\c@refsection _seq} {\detokenize{#2}}
    {
      \seq_gput_left:cx {g_hchr_keyword_\the\c@refsection _seq} {\detokenize{#2}}
    }
  \listcsxadd{blx@keyw@\the\c@refsection @\detokenize{#2}}{#1}}

\newcommand*{\DefineKeywordTitle}[2]{%
  \csdef{keyword@title@\detokenize{#1}}{#2}}

\def\blx@bibbykeyword@i#1{%
  \ifcsundef{keyword@title@\detokenize{#1}}
    {\printbibliography[keyword=#1, title=#1]}
    {\printbibliography[keyword=#1, title=\csuse{keyword@title@\detokenize{#1}}]}}

\newcommand*{\bibbykeyword}
  {
    \seq_if_exist:cT {g_hchr_keyword_\the\c@refsection _seq}
      {
        \seq_sort:cn {g_hchr_keyword_\the\c@refsection _seq}
          {
            \str_compare:nNnTF { ##1 } > { ##2 }
              { \sort_return_swapped: }
              { \sort_return_same: }
          }

        \seq_map_function:cN {g_hchr_keyword_\the\c@refsection _seq} \blx@bibbykeyword@i
      }
  }
\makeatother
\ExplSyntaxOff

\usepackage[linkcolor=red,
            colorlinks=true,
            citecolor=black,
            bookmarksnumbered=true,
            bookmarksopen=true,
            unicode]
            {hyperref}
\usepackage{url}

\begin{filecontents}[overwrite]{\jobname.bib}
@string{oup      = {Oxford University Press}}
@string{cup      = {Cambridge University Press}}
@book{abbott:introduction,
    title        = {An introduction to narrative},
    author       = {Abbott, Porter H.},
    year         = 2002,
    location     = {Cambridge},
    publisher    = cup,
    isbn         = {0-521-65969-8},
    pagetotal    = 200,
    keywords     = {literary theory,narrativity},
    annotation   = {[A published collection of letters, in a Book entry
                  rather than Letter. References to it would be by
                  page rather than by individual letter.]}
}
@book{barnes:aristotle,
    title        = {Aristotle},
    subtitle     = {A very short introduction},
    author       = {Barnes, Jonathan},
    year         = 2000,
    location     = {Oxford},
    publisher    = oup,
    series       = {Very short introductions},
    volume       = 32,
    isbn         = {0192854089},
    pubstate     = {revisededition},
    keywords     = {philosophy},
    annotation   = {[The influence of Aristotle, the prince of philosophers, on the intellectual history of the West is second to none. In this book, Jonathan Barnes examines Aristotle's scientific researches, his discoveries in logic and his metaphysical theories, his work in psychology and in ethics and politics, and his ideas about art and poetry, placing his teachings in their historical context.]}
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}
\nocite{*}
\bibbykeyword
\end{document}

1 Answer 1

2

With biblatex-chicago the bibmacro finentry, which you use to print the entry key, has a slightly different definition that we need to take into account.

The font size of the annotation can be controlled with \DeclareFieldFormat as usual.

\documentclass[british]{article}
\usepackage[margin=2cm]{geometry}
\usepackage{expl3}
\RequirePackage{fontspec}
\setmainfont{texgyretermes}[
  Ligatures = {TeX},
  Extension = {.otf},
  UprightFont = {*-regular},
  ItalicFont = {*-italic},
  BoldFont = {*-bold},
  BoldItalicFont = {*-bolditalic}
]%%
\usepackage[romanian]{babel}
\usepackage{csquotes}

\usepackage[%
  abbreviate=false,% 
  annotation, % 
  cmsbreakurl, % 
  sorting=nyt, % 
  maxnames=3, % 
  minnames=1, % 
  isbn=false, % 
  url=true, % 
  date=long, % 
  cmsdate=both, % 
  bibencoding=inputenc,%
  bibannotesep=vpar,%
  longcrossref=bib,%
  bookpages=true,%
  doi=true,%
  related=true,%
  notes]%
{biblatex-chicago}

\DeclareFieldFormat{annotation}{\small#1}%

\DeclareFieldFormat{entrykey}{%
  \textcolor{red}{%
    \mkbibbrackets{#1}}}

\renewbibmacro*{finentry}{%
  \setunit{\finentrypunct\addspace}%
  \printfield{entrykey}%
  \renewcommand\finentrypunct{}%
  \togglefalse{cms@switchdates}%
  \ifboolexpr{%
    togl {cms@annotation}%
    or
    togl {cms@cbxannote}%
  }%
    {\usebibmacro{entrytail}}%
    {}%
  \finentry}

\NewBibliographyString{revisededition}
\DefineBibliographyStrings{romanian}{revisededition = {ediție revizuită}}

% divide bibliography by keywords
% see https://tex.stackexchange.com/questions/634876/biblatex-bibliography-divided-by-every-keyword

\ExplSyntaxOn
\makeatletter
\def\blx@addkeyword#1#2{%
  \seq_if_exist:cF {g_hchr_keyword_\the\c@refsection _seq}
    {
      \seq_new:c {g_hchr_keyword_\the\c@refsection _seq}
    }
  \seq_if_in:cxF {g_hchr_keyword_\the\c@refsection _seq} {\detokenize{#2}}
    {
      \seq_gput_left:cx {g_hchr_keyword_\the\c@refsection _seq} {\detokenize{#2}}
    }
  \listcsxadd{blx@keyw@\the\c@refsection @\detokenize{#2}}{#1}}

\newcommand*{\DefineKeywordTitle}[2]{%
  \csdef{keyword@title@\detokenize{#1}}{#2}}

\def\blx@bibbykeyword@i#1{%
  \ifcsundef{keyword@title@\detokenize{#1}}
    {\printbibliography[keyword=#1, title=#1]}
    {\printbibliography[keyword=#1, title=\csuse{keyword@title@\detokenize{#1}}]}}

\newcommand*{\bibbykeyword}
  {
    \seq_if_exist:cT {g_hchr_keyword_\the\c@refsection _seq}
      {
        \seq_sort:cn {g_hchr_keyword_\the\c@refsection _seq}
          {
            \str_compare:nNnTF { ##1 } > { ##2 }
              { \sort_return_swapped: }
              { \sort_return_same: }
          }

        \seq_map_function:cN {g_hchr_keyword_\the\c@refsection _seq} \blx@bibbykeyword@i
      }
  }
\makeatother
\ExplSyntaxOff

\usepackage[linkcolor=red,
            colorlinks=true,
            citecolor=black,
            bookmarksnumbered=true,
            bookmarksopen=true,
            unicode]
            {hyperref}
\usepackage{url}

\begin{filecontents}{\jobname.bib}
@string{oup      = {Oxford University Press}}
@string{cup      = {Cambridge University Press}}
@book{abbott:introduction,
    title        = {An introduction to narrative},
    author       = {Abbott, Porter H.},
    year         = 2002,
    location     = {Cambridge},
    publisher    = cup,
    isbn         = {0-521-65969-8},
    pagetotal    = 200,
    keywords     = {literary theory,narrativity},
    annotation   = {[A published collection of letters, in a Book entry
                  rather than Letter. References to it would be by
                  page rather than by individual letter.]}
}
@book{barnes:aristotle,
    title        = {Aristotle},
    subtitle     = {A very short introduction},
    author       = {Barnes, Jonathan},
    year         = 2000,
    location     = {Oxford},
    publisher    = oup,
    series       = {Very short introductions},
    volume       = 32,
    isbn         = {0192854089},
    pubstate     = {revisededition},
    keywords     = {philosophy},
    annotation   = {[The influence of Aristotle, the prince of philosophers, on the intellectual history of the West is second to none. In this book, Jonathan Barnes examines Aristotle's scientific researches, his discoveries in logic and his metaphysical theories, his work in psychology and in ethics and politics, and his ideas about art and poetry, placing his teachings in their historical context.]}
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}
\nocite{*}
\bibbykeyword
\end{document}

Abbott, Porter H., An introduction to narrative, Cambridge: Cambridge University Press, 2002. [abbott:introduction].
[A published collection of letters, in a Book entry rather than Letter. References to it would be by page rather than by individual letter.]

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .