1

I already made a few changes to the original AEA bibliographystyle code. Now I want the year of publication after the authors in brackets. What should I change? This is my Latex-file:

\documentclass{article}
\usepackage{natbib}

\begin{document}

\section{Test}

Here is an example to cite \citet{abeler2010gift} in text.

\pagebreak
\addcontentsline{toc}{section}{References}
\bibliographystyle{aea}
\bibliography{paper}
\nocite{*}


\end{document}

The references are generated with Jabref and saved in a separate bibliography file (paper) and are formatted like this:

@Article{abeler2010gift,
  author    = {Abeler, Johannes and Altmann, Steffen and Kube, Sebastian and Wibral, Matthias},
  title     = {Gift exchange and workers' fairness concerns: When equality is unfair},
  year      = {2010},
  volume    = {8},
  number    = {6},
  pages     = {1299--1324},
  journal   = {Journal of the European Economic Association},
  publisher = {Wiley Online Library},
}

The bibliography style is a modified version of the American Economic Review - Style (AEA). I uploaded the file here: https://www.file-upload.net/download-12626400/aea.bst.html

moewe
  • 175,683
robinho
  • 11
  • 1
    Welcome to TeX.SX! Please don't show only a code snippet of a bst file. To give good answers it is important to have a minimal but working example with bibliography (MWEB) not only to reproduce the problem but also to test our suggestions. And we need as much information as possible what is wrong with the example and what should be different. So please help us to help you. – Schweinebacke Jul 26 '17 at 08:04
  • 1
    Off-Topic: Is there a reason not to use biblatex + biber. It can be configured without bst hacking and has several other advantages. – Schweinebacke Jul 26 '17 at 08:06
  • Thanks for your help! I don't know if I understand you correctly :) You don't want me to post the whole code? I thought it is better, as I don't know exactly where the problem is. My bibliography (besides formatting) should have the following format: Author Name, Author Prename (Year). and then everything else – robinho Jul 26 '17 at 08:27
  • 1
    I want you to post a MWEB. See the links in my comment for more information. – Schweinebacke Jul 26 '17 at 08:29
  • Yes I would like to do this but I am not very familiar with coding etc. :) All of my Latex-stuff is more or less from templates. I tried to do the MWEB but it did not work or I think it did not – robinho Jul 26 '17 at 08:33
  • You want some references in my latex-file, correct? But don't you need my bibliography file or the code of it? – robinho Jul 26 '17 at 08:36
  • We need everything, that is needed to reproduce the problem. So if you are using an external bib file and cannot replace it, e.g., by the biblatex-examples.bib of biblatex we need a bib file with the entries that are valid for the example. But please have a look at the link in my first comment! – Schweinebacke Jul 26 '17 at 08:42
  • Thanks for your help and patience! I tried to integrate the necessary latex things in my original post. How should I integrate now the bibliography style code? Should I upload it? – robinho Jul 26 '17 at 09:16
  • Use filecontents as shown in the community answer from the MWEB link above. If it is too large use a file hoster and add a link. – Schweinebacke Jul 26 '17 at 09:24
  • Sorry, it does not work with filecontents or I don't get it.. I uploaded the bibliography style code above with a link. – robinho Jul 26 '17 at 09:33
  • 1
    Once again: Would answers using biblatex + biber instead ob bibtex + natbib-file also be welcome? – Schweinebacke Jul 26 '17 at 09:45
  • Yes, of course. As long as it is compatible with my previous work and Jabref. Further it would be nice if this does not require too much coding-knowledge.. – robinho Jul 26 '17 at 09:48
  • Still struggling with the AEA code... Does anybody have a tip where the problem lies? – robinho Jul 26 '17 at 14:16
  • 1
    @robinho Do you want all your 'years' to be typeset with brackets, or only the ones for article? (What about book, incollection, inbook etc.?) – Troy Jul 26 '17 at 15:54
  • hey troy. all years should be represented with brackets independent of the class. i have "article", "bookinbook", "techreport" and "book" entries – robinho Jul 26 '17 at 17:28
  • @robinho Please see my answer, and note in particular the use of filecontents as Schweinebacke mentioned in earlier comments. filecontents is especially useful when constructing an MWEB, which you can now copy-paste as a whole into your system to compile (unlike the code in your example, which is fragmented). All we ask is for you to extend the courtesy in doing the same for us when you are asking a question relating to bibliography etc in the future. It saves us a little trouble! :) – Troy Jul 26 '17 at 17:55
  • This is perfect! Thank you very much!!! Now, also the MWEB is clear - sorry I just did not get it before. Of course I understand your concerns and I will take care of them.. Best, robinho – robinho Jul 26 '17 at 18:08
  • @robinho If you like my answer and it was helpful, please consider upvoting (by clicking on the arrows next to the score) and/or marking it as the accepted answer (by clicking on the checkmark ✓). It is the TeX.SE way of saying thank you. – Troy Jul 28 '17 at 14:57

1 Answers1

1

You can achieve the desired effect by modifying the .bst file, with a small caveat as pointed out by the 'comments' in the aea.bst file:

Copying of this file is authorized only if either
     (1) you make absolutely no changes to your copy, including name, or
     (2) if you do make changes, you name it something other than
     btxbst.doc, plain.bst, unsrt.bst, alpha.bst, abbrv.bst, agsm.bst,
     dcu.bst, cje.bst, aer.bst, or kluwer.bst.
     This restriction helps ensure that all standard styles are identical.

If you make the changes as I show below, please save it as a new .bst file and name it something else, like robinho.bst perhaps.


  1. In the .bst file, find (Ctrl+F) the FUNCTION {output.month.year} entry. This controls the formatting of the month and year output. So to add the desired brackets (note that this will change all of the formatting of the year field to include brackets), replace

    FUNCTION {output.month.year}
      {
          space month plain.space.output
          space year plain.comma "year" output.check
      }
    

    with

    FUNCTION {output.month.year}
      {
          space month plain.space.output
          space "(" year * ")" * plain.comma "year" output.check
      }
    
  2. To influence the location of the year field, go ahead and find (Ctrl+F) in the .bst file, FUNCTION {article}. Replace

    FUNCTION {article}
    { output.bibitem
      author.item.check
      format.title.if.not.sortkey.check
      crossref missing$
        { space journal italic comma "journal" output.check
          output.month.year
          output.vol.num.pages
        }
        { space format.article.crossref plain.space output.nonnull
          comma format.pages plain.space.output
        }
      if$
      fin.entry
    }
    

    with

    FUNCTION {article}
    { output.bibitem
      author.item.check
      output.month.year
      format.title.if.not.sortkey.check
      crossref missing$
        { space journal italic comma "journal" output.check
          output.vol.num.pages
        }
        { space format.article.crossref plain.space output.nonnull
          comma format.pages plain.space.output
        }
      if$
      fin.entry
    }
    
  3. Save as robinho.bst. (Do so, for the reasons I mentioned at the beginning of this answer.)

Then consider the following MWEB:

\begin{filecontents*}{\jobname.bib}
    @Article{abeler2010gift,
        author    = {Abeler, Johannes and Altmann, Steffen and Kube, Sebastian and Wibral, Matthias},
        title     = {Gift exchange and workers' fairness concerns: When equality is unfair},
        year      = {2010},
        volume    = {8},
        number    = {6},
        pages     = {1299--1324},
        journal   = {Journal of the European Economic Association},
        publisher = {Wiley Online Library},
    }
\end{filecontents*}

\documentclass{article}
\usepackage{natbib}
\usepackage{filecontents}

\begin{document}
    \section{Test}

    Here is an example to cite \citet{abeler2010gift} in text.

    \bibliographystyle{robinho}% <-----------
    \bibliography{\jobname}% <-----------
%   \nocite{*}

\end{document}

which gives the output:

enter image description here

Troy
  • 13,741