conditional-statementslatexbibliography

Latex sorting bibliography


I have a piece of code that sort my bibliography by date and type from a .bib file. It works just fine however i am asked to provide my bibliography from a starting year say 1996 i.e. skipping everything before.any help on what to amend to add this condition? thanks for the .bib file please save in a file the following test found online, this is an example of database to be sorted:

%%%%%%%%%%% mybib.bib %%%%%%%%%%%%%%%%%%%
@BOOK{HK,
AUTHOR={H. Kopka and P. W. Daly},
TITLE={A Guide to LaTeX},
PUBLISHER={Addison-Wesley},
ADDRESS={Reading, MA},
YEAR=1999.
}
@BOOK{MG,
AUTHOR={M. Goossens and F. Mittelbach and A. Samarin},
TITLE={A LaTeX Companion},
PUBLISHER={Addison-Wesley},
ADDRESS={Reading, MA},
YEAR=1994.
}
@ARTICLE{Pan,
AUTHOR={D. Pan},
TITLE={A Tutorial on MPEG/Audio Compression},
JOURNAL={IEEE Multimedia},
YEAR={1995},
VOLUME= {2} ,
PAGES={60-74},
MONTH={Summer}.
}
@INPROCEEDINGS{Boney96,
AUTHOR={L. Boney and A. H. Tewfik and K. N. Hamdy},
TITLE={Digital Watermarks for Audio Signals},
booktitle={Proceedings of the Third IEEE International Conference on
Multimedia},
PAGES={473-480},
MONTH={June},
YEAR={1996}.
}
%%%%%%%%%%%%% end %%%%%%%%%%%%%%%%%%%%%

\documentclass[12pt]{article}
\usepackage[english]{babel}
\usepackage[backend=biber,sorting=ddatent,style=phys, defernumbers=true, natbib=true, isbn=true]{biblatex}
    
    %sorting by date 
    \DeclareSortingScheme{ddatent}{
        \sort{
            \field{presort}
        }
        \sort[final]{
            \field{sortkey}
        }
        \sort[direction=descending]{
            \field[strside=left,strwidth=4]{sortyear}
            \field[strside=left,strwidth=4]{year}
            \literal{9999}
        }
        \sort[direction=descending]{
            \field[padside=left,padwidth=2,padchar=0]{month}
            \literal{00}
        }
        \sort[direction=descending]{
            \field[padside=left,padwidth=2,padchar=0]{day}
            \literal{00}
        }
        \sort[direction=descending]{
            \field[padside=left,padwidth=4,padchar=0]{volume}
            \literal{9999}
        }
        \sort{
            \name{sortname}
            \name{author}
            \name{editor}
            \name{translator}
            \field{sorttitle}
            \field{title}
        }
        \sort{
            \field{sorttitle}
            \field{title}
        }
    }
    
    \addbibresource{mybib.bib}

    \begin{document}
    \printbibliography[heading=none,type=book]
    \printbibliography[heading=none,type=article]
    \end{document} `

Solution

  • You mustn't use . at the end of your bib entries.


    Back to your actual question: you can define bibcheck:

    \documentclass[12pt]{article}
    \usepackage[english]{babel}
    \usepackage[backend=biber,sorting=ddatent,style=phys, defernumbers=true, natbib=true, isbn=true]{biblatex}
    
    %sorting by date 
    \DeclareSortingScheme{ddatent}{
        \sort{
            \field{presort}
        }
        \sort[final]{
            \field{sortkey}
        }
        \sort[direction=descending]{
            \field[strside=left,strwidth=4]{sortyear}
            \field[strside=left,strwidth=4]{year}
            \literal{9999}
        }
        \sort[direction=descending]{
            \field[padside=left,padwidth=2,padchar=0]{month}
            \literal{00}
        }
        \sort[direction=descending]{
            \field[padside=left,padwidth=2,padchar=0]{day}
            \literal{00}
        }
        \sort[direction=descending]{
            \field[padside=left,padwidth=4,padchar=0]{volume}
            \literal{9999}
        }
        \sort{
            \name{sortname}
            \name{author}
            \name{editor}
            \name{translator}
            \field{sorttitle}
            \field{title}
        }
        \sort{
            \field{sorttitle}
            \field{title}
        }
    }
    
    \begin{filecontents*}[overwrite]{\jobname.bib}
    %%%%%%%%%%% mybib.bib %%%%%%%%%%%%%%%%%%%
    @BOOK{HK,
    AUTHOR={H. Kopka and P. W. Daly},
    TITLE={A Guide to LaTeX},
    PUBLISHER={Addison-Wesley},
    ADDRESS={Reading, MA},
    YEAR=1999,
    }
    @BOOK{MG,
    AUTHOR={M. Goossens and F. Mittelbach and A. Samarin},
    TITLE={A LaTeX Companion},
    PUBLISHER={Addison-Wesley},
    ADDRESS={Reading, MA},
    YEAR=1994,
    }
    @ARTICLE{Pan,
    AUTHOR={D. Pan},
    TITLE={A Tutorial on MPEG/Audio Compression},
    JOURNAL={IEEE Multimedia},
    YEAR={1995},
    VOLUME= {2} ,
    PAGES={60-74},
    MONTH={Summer},
    }
    @INPROCEEDINGS{Boney96,
    AUTHOR={L. Boney and A. H. Tewfik and K. N. Hamdy},
    TITLE={Digital Watermarks for Audio Signals},
    booktitle={Proceedings of the Third IEEE International Conference on
    Multimedia},
    PAGES={473-480},
    MONTH={June},
    YEAR={1996},
    }
    %%%%%%%%%%%%% end %%%%%%%%%%%%%%%%%%%%%
    
    \end{filecontents*}
    
    \addbibresource{\jobname.bib}
    
    
    \defbibcheck{recent}{%
      \iffieldint{year}
      {\ifnumless{\thefield{year}}{1996}
         {\skipentry}
         {}}
      {\skipentry}}
    
    \begin{document}
    
    \nocite{*}
    
    \printbibliography[heading=none,type=book,check=recent]
    \printbibliography[heading=none,type=article,check=recent]
    \end{document} `