Skip to content

Instantly share code, notes, and snippets.

@ndgnuh
Last active June 16, 2021 17:52
Show Gist options
  • Select an option

  • Save ndgnuh/f6c235698a665702a585c8a4f9f4cd85 to your computer and use it in GitHub Desktop.

Select an option

Save ndgnuh/f6c235698a665702a585c8a4f9f4cd85 to your computer and use it in GitHub Desktop.
Setup biblatex cho đồ án.
% By language
\DeclareSourcemap{
\maps[datatype=bibtex, overwrite] {
\map{
\perdatasource{refs.bib}
\step[fieldset=language, fieldvalue={02english}, append]
\step[fieldset=keywords, fieldvalue={english}, append]
}
\map{
\perdatasource{refs.vn.bib}
\step[fieldset=language, fieldvalue={01vietnamese}, append]
\step[fieldset=keywords, fieldvalue={vietnamese}, append]
}
}
}
% AUTO DATE
\DeclareSourcemap{
\maps[datatype=bibtex, overwrite]{
\map{
\step[fieldsource=volume, match=\regexp{(\A(v|V)ol\Z)?}, replace={}]
\step[fieldsource=month, match=\regexp{\A(j|J)an(uary)?\Z}, replace=1]
\step[fieldsource=month, match=\regexp{\A(f|F)eb(ruary)?\Z}, replace=2]
\step[fieldsource=month, match=\regexp{\A(m|M)ar(ch)?\Z}, replace=3]
\step[fieldsource=month, match=\regexp{\A(a|A)pr(il)?\Z}, replace=4]
\step[fieldsource=month, match=\regexp{\A(m|M)ay\Z}, replace=5]
\step[fieldsource=month, match=\regexp{\A(j|J)un(e)?\Z}, replace=6]
\step[fieldsource=month, match=\regexp{\A(j|J)ul(y)?\Z}, replace=7]
\step[fieldsource=month, match=\regexp{\A(a|A)ug(ust)?\Z}, replace=8]
\step[fieldsource=month, match=\regexp{\A(s|S)ep(tember)?\Z}, replace=9]
\step[fieldsource=month, match=\regexp{\A(o|O)ct(ober)?\Z}, replace=10]
\step[fieldsource=month, match=\regexp{\A(n|N)ov(ember)?\Z}, replace=11]
\step[fieldsource=month, match=\regexp{\A(d|D)ec(ember)?\Z}, replace=12]
}
}
}
% SORTING STUFF
\DeclareSortingNamekeyTemplate{
\keypart{
\namepart{given}
}
\keypart{
\namepart{family}
}
\keypart{
\namepart{prefix}
}
\keypart{
\namepart{suffix}
}
}
\DeclareSortingTemplate[]{sami}{
\sort{\field{language}}
\sort{\field{sortname}\field{author}}
\sort{\field{sorttitle}\field{title}}
}
% REMOVE LANGUAGE FROM ITEM
\AtEveryBibitem{%
\clearlist{language}%
\clearfield{month}%
}
% FORMATTING
\renewcommand*{\finalnamedelim}{\addspace\&\addspace}%
\DeclareFieldFormat[inbook,suppbooksupplemental,bookinbook,booksingle,mvbook]{title}{\textit{#1}}
\DeclareFieldFormat[inbook,suppbooksupplemental,bookinbook,booksingle,mvbook]{publisher}{#1}
\DeclareFieldFormat[article,inproceedings]{title}{\mkbibquote{#1}}
\DeclareFieldFormat{pages}{#1}
\DeclareFieldFormat{volumes}{#1}
\DeclareFieldFormat{number}{#1}
\DeclareFieldFormat{month}{#1}
% SORT FIELD
\newcommand{\booklikebib}{%
\printnames{author}
\addcomma\addspace
\printfield{title}
\addcomma\addspace
\printlist{publisher}%
\addcomma\addspace
\printlist{location}
\addcomma\addspace
\printfield{year}
\newunit\newblock
\finentry
}
\newcommand{\articlelikebib}{%
\printnames{author}
\addcomma\addspace
\printfield{title}
\addcomma\addspace
\printfield{journaltitle}
\iffieldundef{volume}
{}
{\addcomma\addspace{}Vol \printfield{volume}}%
\iffieldundef{number}
{}
{\addsemicolon\addspace\mkbibparens{\printfield{number}}}
\addcomma\addspace
\printfield{year}
\iffieldundef{pages}
{}
{\addcomma\addspace\printfield{pages}}
\finentry
}
\newcommand{\misclikebib}{%
\printnames{author}
\addcomma\addspace
\printfield{title}
\iffieldundef{year}
{}
{\addcomma\addspace\printfield{year}}
\iffieldundef{url}
{}
{\addcomma\addspace\printfield{url}}
\iffieldundef{doi}
{}
{\addcomma\addspace\printfield{doi}}
\iffieldundef{eprint}
{}
{\addcomma\addspace\printfield{eprint}}
\iffieldundef{pages}
{}
{\addcomma\addspace\printfield{pages}}
\finentry
}
\DeclareBibliographyDriver{book}{\booklikebib}
\DeclareBibliographyDriver{inbook}{\booklikebib}
\DeclareBibliographyDriver{article}{\articlelikebib}
\DeclareBibliographyDriver{inproceedings}{\articlelikebib}
\DeclareBibliographyDriver{misc}{\misclikebib}
\documentclass[a4paper,14pt]{extreport}
\usepackage[
citestyle=numeric-verb,
maxnames=40,
backend=biber,
sortcites=true,
sorting=sami,
defernumbers=true,% continuous numbering across bibliography sections
bibencoding=utf8
]{biblatex}
\addbibresource{refs.vn.bib}
\addbibresource{refs.bib}
\input{biblibiography-setup}
\begin{document}
\chapter*{Tài liệu tham khảo}
\addcontentsline{toc}{chapter}{Tài liệu tham khảo}
\nocite{*}
\begin{refcontext}[sorting=sami]
\printbibliography[
heading=subbibliography,
title={Tài liệu Tiếng Việt},
keyword=vietnamese
]
\printbibliography[
heading=subbibliography,
title={Tài liệu Tiếng Anh},
keyword=english
]
\end{refcontext}
\end{document}
@article{Bezanson2017,
title={Julia: A fresh approach to numerical computing},
author={Bezanson, Jeff and Edelman, Alan and Karpinski, Stefan and Shah, Viral B},
journal={SIAM review},
volume={59},
number={1},
pages={65--98},
year={2017},
publisher={SIAM},
url={https://doi.org/10.1137/141000671}
}
@misc{Agents.jl,
title={Agents.jl: A performant and feature-full agent based modelling software of minimal code complexity},
author={George Datseris and Ali R. Vahdati and Timothy C. DuBois},
year={2021},
eprint={2101.10072},
archivePrefix={arXiv},
primaryClass={cs.MA}
}
@misc{GauGau,
title = {Xàm ngôn},
sortname = {Hùng},
author = {Hùng, Nguyễn},
year = {2021},
month = {6},
url = {https://ndgnuh.github.io}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment