Skip to content

Tips: How to Add Two Different Bibliography Styles in One Thesis (e.g., Numeric for Datasheets, Alphabetic for Papers) #142

@FanWu-fan

Description

@FanWu-fan

If you want to split your bibliography into two sections with different citation styles (e.g., numeric style for datasheets/reference manuals, and alphabetic or author-year style for academic papers), you can achieve this in your thesis using biblatex with the following approach:

1. Use biblatex with advanced options

In your preamble, load biblatex with the labelnumber and defernumbers options:

% BibLaTeX % style=authoryear-icomp
\usepackage[utf8]{inputenc}
\usepackage{csquotes}
\usepackage[
  hyperref=auto,
  mincrossrefs=999,
  backend=biber,
  style=alphabetic,
  labelnumber,
  defernumbers
]{biblatex}
\addbibresource{allpapers.bib}
\addbibresource{datasheets.bib}

% Custom citation format in the text
\renewbibmacro*{cite}{%
  \printtext[bibhyperref]{%
    \printfield{prefixnumber}%
    \ifkeyword{datasheet}  # same as the Tag entries
      {\printfield{labelnumber}}
      {\printfield{labelalpha}\printfield{extraalpha}}}}

Be sure change the run.py as

given_settings = {
  'mainfile':    'thesis.tex',
  'chaptersdir': 'chapters',

  'makebibliography': True,
  'makeindex':        True,
  'makeglossary':     True,
  'makenomenclature': True,

  'usebiblatex':      True, # change it to True
  'biblatexbackend':  'biber', # alternative: bibtex

2. Tag entries by type

Add a keyword to your datasheet or special entries in your datasheets.bib file:

@manual{mydatasheet,
  title = {My Special Device Datasheet},
  year  = {2024},
  keyword = {datasheet}
}

3. Custom bibliography list style for datasheets and Print bibliographies by group

\defbibenvironment{numblist}
  {\list
     {\mkbibbrackets{\printfield{labelnumber}}}
     {\setlength{\labelwidth}{2em}
      \setlength{\leftmargin}{2.5em} # distance between the number to leftmargin
      \setlength{\labelsep}{1em} # distance  between the number to right words
      \setlength{\itemsep}{\bibitemsep}
      \setlength{\parsep}{\bibparsep}}}
  {\endlist}
  {\item}

%Print bibliographies by group
\begin{refcontext}[sorting=nty]
\printbibliography[
  title={Datasheets and Reference Manuals},
  keyword={datasheet},
  resetnumbers=true,
  env=numblist   
]
\end{refcontext}

\begin{refcontext}[sorting=nty]
\printbibliography[
  title={Bibliography},
  notkeyword={datasheet}
]
\end{refcontext}

3. Complie

python run.py

Image

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions