1

Here is the MWE i used to list me references:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}
\usepackage[style=alphabetic, maxnames=6, natbib=true, backend=biber]{biblatex}
\addbibresource{biblatex-examples.bib}

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \step[fieldsource=author,
            match=Knuth,
            final]
       \step[fieldset=keywords, fieldvalue=knuth]
    }
    \map{
      \step[fieldsource=author,
            match=Sigfridsson,
            final]
      \step[fieldset=keywords, fieldvalue=sigfridsson]
    }
  }
}

\begin{document}
\nocite{sigfridsson,knuth:ct:a,companion,worman,knuth:ct:c}
\printbibliography[keyword=knuth]
\printbibliography[keyword=sigfridsson]
\printbibliography[notkeyword=knuth,notkeyword=sigfridsson]
\end{document}

I am trying to create variables before the document starts so I can substitute any author needed in the document in my bib list. In a perfect world i would want it to look like this:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}
\usepackage[style=alphabetic, maxnames=6, natbib=true, backend=biber]{biblatex}
\addbibresource{biblatex-examples.bib}

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \step[fieldsource=author,
            match= x,
            final]
      \step[fieldset=keywords, fieldvalue= x]
    }
  }
}

\begin{document}
\nocite{*}
\printbibliography[keyword=x=anyauthorspecified]
\printbibliography[notkeyword=x=anyauthorspecified]
\end{document}

I want to do this so I can repeatedly use \declaresourcemap without having to make a map for each specific author when needed. I would just use a \printbibliography and specify which author i wanted

moewe
  • 175,683
Michael
  • 87
  • 1
    The problem is that you can only ever have one single \DeclareSourcemap in your document. If you have several, they overwrite each other. So this won't really work. – moewe Oct 24 '17 at 17:04
  • You could go for a different approach. Have a look at https://tex.stackexchange.com/q/28509/35864, that should scale more easily. – moewe Oct 24 '17 at 17:07

1 Answers1

2

The idea from biblatex: filter out publications from a specific author in the references dynamically is scalable

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[british]{babel}
\usepackage{csquotes}
\usepackage[backend=biber, style=alphabetic]{biblatex}
\bibliography{biblatex-examples}

\newcommand*{\generateauthorcategory}[3]{%
  \DeclareBibliographyCategory{by#1}%
  \DeclareIndexNameFormat{cat#1}{%
    \ifboolexpr{test {\ifdefstring{\namepartfamily}{#2}}
                and test {\ifdefstring{\namepartgiven}{#3}}}
      {\addtocategory{by#1}{\thefield{entrykey}}}
      {}}%
  \AtDataInput{\indexnames[cat#1][1-999]{author}}}

\generateauthorcategory{sigfridsson}{Sigfridsson}{Emma}
\generateauthorcategory{knuth}{Knuth}{Donald\bibnamedelima E.}
\generateauthorcategory{glashow}{Glashow}{Sheldon}

\defbibcheck{yr1986}{%
  \iffieldint{year}
    {\ifnumequal{\thefield{year}}{1986}
       {}
       {\skipentry}}
    {\skipentry}}

\defbibcheck{yr1984}{%
  \iffieldint{year}
    {\ifnumequal{\thefield{year}}{1984}
       {}
       {\skipentry}}
    {\skipentry}}

\begin{document}
\nocite{knuth:ct:a,knuth:ct:b,sigfridsson,glashow,cicero,worman}
\printbibliography[category=bysigfridsson, title=Sigfridsson]
\printbibliography[category=byknuth, check=yr1984, title=Knuth 1984]
\printbibliography[category=byknuth, check=yr1986, title=Knuth 1986]
\printbibliography[category=byglashow, title=Glashow]
\end{document}

The command \generateauthorcategory{<catname>}{<family>}{<given>} generates a category by<catname> and adds all entries whose author has a family name equal to <family> and given name equal to <given>. Note that the given name needs to be given in the format from the .bbl, that means it might have to include some internal macros (\bibnamedelima, \bibnamedelimd, ...) (cf. Knuth above). The first argument <catname> must be unique and it should only contains ASCII chars (I prefer to keep it lowercase as well), it is only used internally and as identifier for by<catname>, so it need not bear any relation to the <family> or <given> argument - but of course it should to avoid confusion.

You can get all entries by an author by filtering the by<catname> category.

To filter by year you can add a simple bibcheck

\defbibcheck{yr1986}{%
  \iffieldint{year}
    {\ifnumequal{\thefield{year}}{1986}
       {}
       {\skipentry}}
    {\skipentry}}

add check=yr1986 to \printbibliography to show only entries from 1986. With \ifnumgreater and \ifnumless you can also check for year ranges.

moewe
  • 175,683
  • It works great! If i wanted to also specify by the year would i just need to make another \declarebibliographycatergory for the year category? – Michael Oct 26 '17 at 14:10
  • @Michael Depends on what exactly you want. Can you elaborate? Do you want to filter by author and year? How do you filter by year (younger than, older than, between x and y)? – moewe Oct 26 '17 at 16:29
  • How would I filter if I wanted to present a list of authors' publications from only 2017 (between x and y might work also if I can still just specify one year if needed)? – Michael Oct 27 '17 at 13:09
  • @Michael See the edit, please. – moewe Oct 27 '17 at 14:36
  • It will only cite the "@inproceedings" and doesn't include the "@article" bibs. How can I have it cite both? – Michael Oct 30 '17 at 15:16
  • @Michael There is nothing in the code that would prevent it from working with @article. So if it doesn't work for you, please ask a new question with an MWE. – moewe Oct 30 '17 at 17:03