Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JohnLukeBentley/9978b50c124de8017d385d0f1bcafcf1 to your computer and use it in GitHub Desktop.
Save JohnLukeBentley/9978b50c124de8017d385d0f1bcafcf1 to your computer and use it in GitHub Desktop.
\documentclass[12pt,a4paper]{article}
\usepackage{a4wide}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Demo
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{filecontents}{\jobname.bib}
% Sorting multiple works by author in year
@article{barker_2016_turkey,
author = {Barker, Anne},
date = {2016-07-18T20:26:06+10:00},
title = {Turkey Divided between Secular and {{Islamist}} Rule},
urldate = {2016-07-24},
journaltitle = {ABC News},
entrysubtype = {newspaper}
}
@article{barker_2016_deep,
author = {Barker, Anne},
date = {2016-07-12},
title = {'{{Deep}} Public Anger' over Daylight Slaying of {{Cambodian}} Activist},
urldate = {2017-10-28},
journaltitle = {ABC News},
entrysubtype = {newspaper}
}
@article{barker_2016_yellow,
author = {Barker, Anne},
date = {2016-04-13},
title = {Yellow Fever Outbreak Spreads amid Vaccine Shortage},
urldate = {2017-10-28},
journaltitle = {ABC News},
entrysubtype = {newspaper}
}
@article{barker_2016_china,
author = {Barker, Anne},
date = {2016-02-24},
title = {China Sends Fighter Jets to Disputed Island},
urldate = {2017-10-28},
journaltitle = {ABC News},
entrysubtype = {newspaper}
}
@online{greenwald_2017_trump,
author = {Greenwald, Glenn},
title = {Trump's {{IRS}} Chief Was Smuggled through the {{Senate}} in a Unanimous Vote in a Private Room {{https://interc.pt/2yRmgFP}}~ by @lhfang @ryangrim},
date = {2017-10-28T04:45:00},
urldate = {2017-10-28},
type = {Tweet},
journaltitle = {@ggreenwald},
shorttitle = {Trump's {{IRS}} Chief Was Smuggled through the {{Senate}} in a Unanimous Vote in a Private Room Https},
url = {https://twitter.com/ggreenwald/status/924240653382496257},
}
@online{greenwald_2017_if,
author = {Greenwald, Glenn},
title = {If You Want to Revere {{FBI}} Directors, Prosecutors, {{CIA}}, Military Medals \& {{Bill Kristol}}, You Have That Right. {{Just}} Odd to Call It \#{{Resistance}}.},
date = {2017-10-28T04:47:00},
urldate = {2017-10-28},
type = {Tweet},
journaltitle = {@ggreenwald},
url = {https://twitter.com/ggreenwald/status/924241127334703104},
}
@online{greenwald_2017_how,
author = {Greenwald, Glenn},
title = {How the {{U}}.{{K}}. Prosecuted a Student on Terrorism Charges for Downloading a Book {{https://interc.pt/2yQT1D7}}~ by @rj\_gallagher},
date = {2017-10-28T04:44:00},
urldate = {2017-10-28},
type = {Tweet},
journaltitle = {@ggreenwald},
shorttitle = {How the {{U}}.{{K}}. Prosecuted a Student on Terrorism Charges for Downloading a Book Https},
url = {https://twitter.com/ggreenwald/status/924240525460426752},
}
@online{greenwald_2017_we,
author = {Greenwald, Glenn},
title = {We Need a Guidebook for When It Is and Is Not "Appropriate" to Criticize Military Officials \& Veterans. {{The}} Standards Seem Quite Confusing.{{https://twitter.com/peterdaou/status/924101542986252288}}~…},
date = {2017-10-28T04:38:00},
urldate = {2017-10-28},
type = {Tweet},
journaltitle = {@ggreenwald},
shorttitle = {We Need a Guidebook for When It Is and Is Not "Appropriate" to Criticize Military Officials \& Veterans. {{The}} Standards Seem Quite Confusing.Https},
url = {https://twitter.com/ggreenwald/status/924238931754971136},
}
\end{filecontents}
\PassOptionsToPackage{%
alldates=ymd,
labeldate=ymd,
alldatesusetime=true,
labeldateusetime=true,
alltimes=24h,
seconds=false,
timezones=true,
datezeros=true,
style=authoryear,
sorting=nst,
dashed=false,
url=false,
mergedate=maximum
}{biblatex}
\usepackage{biblatex}
\addbibresource{\jobname.bib}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Solution
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Sort by name, second (or finest available precision if seconds not available), title.
% 's' for 'Sort down to the second'.
% Timezones are ignored.
\DeclareSortingTemplate{nst}{
\sort{
\field{presort}
}
\sort[final]{
\field{sortkey}
}
\sort{
\field{sortname}
\field{author}
\field{editor}
\field{translator}
\field{sorttitle}
\field{title}
}
\sort{
\field{sortyear}
\field{year}
}
\sort{
\field[padside=left,padwidth=2,padchar=0]{month}
\literal{00}
}
\sort{
\field[padside=left,padwidth=2,padchar=0]{day}
\literal{00}
}
\sort{
\field[padside=left,padwidth=2,padchar=0]{hour}
\literal{00}
}
\sort{
\field[padside=left,padwidth=2,padchar=0]{minute}
\literal{00}
}
\sort{
\field[padside=left,padwidth=2,padchar=0]{second}
\literal{00}
}
\sort{
\field{sorttitle}
\field{title}
}
\sort{
\field{volume}
\literal{0}
}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Support
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Remove indenting for ease of viewing.
\setlength{\parindent}{0pt}
\begin{document}
\section{Sorting multiple works by author in year}
Sorting test by day level precision, using newspaper articles:
\autocite{barker_2016_china} \citetitle{barker_2016_china} \\
\autocite{barker_2016_turkey} \citetitle{barker_2016_turkey}\\
\autocite{barker_2016_deep} \citetitle{barker_2016_deep}\\
\autocite{barker_2016_yellow} \citetitle{barker_2016_yellow}\\
Sorting test by time level precision, using an online entries (tweets):
\autocite{greenwald_2017_how}\\
\autocite{greenwald_2017_if}\\
\autocite{greenwald_2017_trump}\\
\autocite{greenwald_2017_we}\\
\printbibliography
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment