Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have a .sty file for my latex document where I create bibliography category (see[1] below). I have these lines in my document and it worked:

\addtocategory{papers}{sushil}   

But in this way I have to add citekey by hand for a large number of articles. So I have been suggested to use this:

\AtEveryCitekey{%
   \ifentrytype{article}{%
     \iffieldundef{journaltitle}{%
       \addtocategory{subpapers}{\thefield{entrykey}}%
       }{%
         \addtocategory{papers}{\thefield{entrykey}}%
       }{%
           }%
       } 
  }      

Which I guess is same thing but does things automatically. But this case does not work if I do not use \cite{sushil} which again brings me to the same point that I have to add citekeys by hand for a large number of articles. I thought that \nocite{*} could work but I already have \nocite{*} in my .sty file.

Does anyone knows how to solve this? I do not want to add so many citekeys by hand as its quite time taking.


[1]

From my .sty file:

% Bibliography categories
\def\makebibcategory#1#2{\DeclareBibliographyCategory{#1}\defbibheading{#1}{\section*{#2}}}
\makebibcategory{papers}{Refereed Research Papers}
\makebibcategory{subpapers}{Submitted Papers to Journals and arXiv}


\setlength{\bibitemsep}{2.65pt}
\setlength{\bibhang}{.8cm}
\renewcommand{\bibfont}{\small}

\renewcommand*{\bibitem}{\addtocounter{papers}{1}\item \mbox{}\hskip-0.85cm\hbox to 0.85cm{\hfill\arabic{papers}.~~}}
\defbibenvironment{bibliography}
{\list{}
  {\setlength{\leftmargin}{\bibhang}%
   \setlength{\itemsep}{\bibitemsep}%
   \setlength{\parsep}{\bibparsep}}}
{\endlist}
{\bibitem}

\newenvironment{publications}{\section{\LARGE Publications}\label{papersstart}\vspace*{0.2cm}\small
\titlespacing{\section}{0pt}{1.5ex}{1ex}\itemsep=0.00cm
}{\label{papersend}\addtocounter{sumpapers}{-1}\refstepcounter{sumpapers}\label{sumpapers}}

\def\printbib#1{\printbibliography[category=#1,heading=#1]\lastref{sumpapers}}
share|improve this question
    
Welcome to TeX.sx! A tip: If you indent lines by 4 spaces, they'll be marked as a code sample. You can also highlight the code and click the "code" button (with "{}" on it). –  Seamus Jun 22 '12 at 10:18

3 Answers 3

Make sure you are using biber as the backend and then you can add this automatically as biber reads your .bib file by putting this in your biber.cfg:

<sourcemap>
  <maps datatype="bibtex">
    <map final="true">
      <per_type>ARTICLE</per_type>
      <map_step map_field_source="JOURNAL/>
      <map_step map_field_set="KEYWORDS" map_field_value="subpapers"/>
    </map>
    <map>
      <per_type>ARTICLE</per_type>
      <map_step map_field_set="KEYWORDS" map_field_value="subpapers"/>
    </map>
  </maps>
</sourcemap>

Or, if you are using the biblatex 2.0 and biber 1.0 betas, you can also do this on a per-document basis in your preamble:

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \pertype{article}
      \step[fieldsource=journal, final=true]
      \step[fieldset=keywords, fieldvalue={papers}]
    }
    \map{
      \pertype{article}
      \step[fieldset=keywords, fieldvalue={subpapers}]
    }
  }
}

You can then simply filter on keywords with \printbibliography[keyword=papers] etc.

share|improve this answer
    
what package I need to add to my .tex file to use \DeclareSourcemap ?? –  sushil Jun 25 '12 at 13:47
    
It's part of biblatex 2.0 which is on SourceForge but is not released yet to TexLive. I hope it will be released in a week or so. It's easy to install manually though. You must be using biber 1.0 too - this feature relies on biber. –  PLK Jun 25 '12 at 15:48
    
Ok thank you very much for the help and infor. I will wait till it released. But do you know is there a way to add many keys to the following command: \addtocategory{papers}{key1,key2}. For 2 keys its fine but when dealing with 1000 keys its difficult to add them. –  sushil Jun 26 '12 at 8:08
    
The sourcemap functionality is already in 1.7/0.9.9, but only via biber's config file. See the biber manual - you can do the same thing using the biber.conf file using biber's XML options format. It's only the LaTeX macro interface to this which has been added in 2.0. I wouldn't try to create a category like this - just add keywords using sourcemap and then filter on keywords instead of a category. –  PLK Jun 26 '12 at 8:44
    
Could you please point me to the installation link. Thanks a lot once again. Sushil –  sushil Jun 26 '12 at 15:48

If you are willing to add some extra information to the bib file you could add an entrysubtype field with papers\subpapers. Then \nocite{*} coupled with \printbibliography[subtype=papers] or possibly easier \printbibliography[notsubtype=subpapers]

share|improve this answer

No I have this example where I want to add citekeys in an automated way to \cite{} command instead of writing them by hand. Because I am dealing with >500 entries in my bib file and its difficult to add them by hand.


\documentclass{article}

\usepackage[defernumbers=true]{biblatex}

\DeclareBibliographyCategory{articlepublished}
\DeclareBibliographyCategory{articleunpublished}

\AtEveryCitekey{%
  \ifentrytype{article}{%
    \iffieldundef{journaltitle}{%
      \addtocategory{articleunpublished}{\thefield{entrykey}}%
    }{%
      \addtocategory{articlepublished}{\thefield{entrykey}}%
    }%
  }{%
  }%
}

\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@article{AX12,
      author         = "Authors1",
      title          = "{Ttile of articles}",
      collaboration  = "Collaboration",
      year           = "2012",
}
@article{AY11,
      author         = "Authors2",
      title          = "{Ttile of articles}",
      collaboration  = "Collaboration",
      year           = "2011",
      journal        = "Phys.Lett.",  
}
\end{filecontents}

\addbibresource{\jobname.bib}

\begin{document}

\cite{AX12,AY11}

\printbibliography[category=articlepublished,title={Published Articles}]

\printbibliography[category=articleunpublished,title={Unpublished Articles}]

\end{document}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.