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 am trying to move on to BibLaTeX. With BibTeX the Style apalike provides everything I need, as illustrated by the following MWE:

\documentclass{article}
\usepackage{xcolor}
\usepackage{natbib}
\usepackage{hyperref}
\hypersetup{%
    colorlinks=true, 
    citecolor=blue} 

\begin{document}
Some text as written by \cite{Attanasio2010} and \citep{Galindo2002}
\bibliographystyle{apalike}
\bibliography{bib}
\end{document}

where the content of the bib is produced by Mendeley and looks like:

@article{Attanasio2010,
abstract = {This paper provides a critical survey of the large literature on the life cycle model of consumption, both from an empirical and a theoretical point of view. It discusses several approaches that have been taken in the literature to bring the model to the data, their empirical successes and failures. Finally, the paper reviews a number of changes to the standard life cycle model that could help solve the remaining empirical puzzles.},
author = {Kaminsky, Graciela Laura and Schmukler, Sergio L.},
journal = {NBER Working Paper},
month = feb,
shorttitle = {Consumption and saving},
title = {{Consumption and saving: models of intertemporal allocation and their implications for public policy}},
url = {http://papers.ssrn.com/sol3/papers.cfm?abstract\_id=1558816 http://www.nber.org/papers/w15756},
volume = {756},
number = {12},
year = {2010}
}

@article{Galindo2002,
author = {Galindo, Arturo and Schiantarelli, Fabio and Weiss, Andrew},
journal = {American Economic Review},
month = apr,
shorttitle = {Does Financial Liberalization Improve the Allocati},
title = {{Does Financial Liberalization Improve the Allocation of Investment?: Micro Evidence from Developing Countries}},
url = {http://ideas.repec.org/p/idb/wpaper/4295.html},
volume = {47},
number = {2},
year = {2002}
}

What I need is actually quite simple and is demonstrated by my example

  • Citations as shown in the example (cite: year in parentheses or citep: Author-Year separated by coma)
  • Use of et al. when more than 2 authors.
  • Bibliography: Only initials for first/middle name.
  • Last name, First name
  • Never use et al.
  • Only show year, even when month is specified
  • Never show URL (retrieved from...)
  • Issue in parentheses, next to volume
  • If using hyperlink, creating link for the full citation and not just the year.

The result should look like: BibTeX example

I have probably forgotten something, but that's the obvious stuff. I have played all day with different styles of BibLaTeX, including authoryear and apa, but I was unable to reproduce the simple apalike style. In fact, I have been unable to get apa for BibLaTeX to work as I get errors such as:

Package biblatex Warning: Bibliography string 'retrieved' undefined(biblatex) at entry 'Attanasio2010'

Edit 1: The biblatex-apa MWE that I cannot get to work is:

\documentclass{article}
\usepackage{xcolor}
\usepackage{hyperref}
\hypersetup{%
    colorlinks=true, 
    citecolor=blue} 

\usepackage{polyglossia}
\setmainlanguage[variant=american]{english}

\usepackage{csquotes}

\PassOptionsToPackage{
        natbib=true,
        style=apa,
        hyperref=true,
        backend=biber,
        maxbibnames=99,
        firstinits=true,
        maxcitenames=2,
        parentracker=true
            }   {biblatex}
\usepackage{biblatex}
\DeclareNameAlias{default}{last-first}    
\DeclareLanguageMapping{american}{american-apa}

\addbibresource{bib.bib}

\begin{document}
Some text as written by \cite{Attanasio2010} and \citep{Galindo2002}

\printbibliography

\end{document}

which produces the errors:

Undefined control sequence: <argument> \mkbibdateapalongextra :    
Package biblatex Warning: Bibliography string 'retrieved' undefined(biblatex) at entry 'Galindo2002'
Package biblatex Warning: Bibliography string 'from' undefined(biblatex) at entry 'Galindo2002'

and looks like this:

enter image description here

Edit 2: The issue lies with polyglossia. When using \usepackage[american]{babel} instead there are no errors.

Edit 3: Further testing shows that, when using polyglossia, one has to use \DeclareLanguageMapping{english}{american-apa}. This takes care of the Bibliography string 'retrieved' undefined errors, but the dates are still wrong and the Undefined control sequence: \mkbibdateapalongextra is still there.

share|improve this question
2  
Since you've asked for a biblatex solution, could you post the biblatex-apa version of your document that didn't work? Most of what you want can probably be done by tweaking a biblatex-apa version. –  Alan Munn Mar 14 '12 at 15:44
    
I've added an MWE for biblatex –  Jörg Mar 14 '12 at 19:15
1  
I am not sure it is the same issue as here: tex.stackexchange.com/questions/44006/…, but it seems like biblatex 1.7 and biblatex-apa 4.6 should work together. –  StrongBad Mar 15 '12 at 15:17
1  
The issue lies with polyglossia. When using \usepackage[american]{babel} instead there are no errors. Is biblatex-apa not compatible with polyglossia? –  Jörg Mar 15 '12 at 16:04
2  
It's not the style which is not compatible, it's biblatex itself which is not compatible with polyglossia. –  PLK Mar 15 '12 at 16:45

1 Answer 1

up vote 11 down vote accepted

I've been able to answer my own question using various hacks I found on tex.sx. As @PLK pointed out, there appears to be a compatibility issue with polyglossia and Biblatex, but among all the styles I tried this issue is only visible with the APA style. So I am using authoryear-comp instead that suits the requirements I stated. This might be useful for anyone wanting a simple, apalike style, particularly when using Mendeley.

  • Citations: cite: year in parentheses or citep: Author-Year separated by coma) -> \let\citealp\cite \let\cite\textcite
  • If using hyperlink, creating link for the full citation and not just the year. -> Answer from @Audrey, see MWE below.
  • Use of et al. when more than 2 authors. -> maxcitenames=2

  • Bibliograpyh: Only initials for first/middle name. -> firstinits=true, uniquename=init

  • Last name, First name -> \DeclareNameAlias{sortname}{last-first}
  • Never use et al. -> maxbibnames=99
  • Only show year, even when month is specified -> \AtEveryBibitem{% \clearfield{month}{}% \clearlist{language}{}% } (also omits the language field)
  • Never show URL (retrieved from...) -> url=false, doi=false, isbn=false, eprint=false
  • Issue in parentheses, next to volume -> see MWE below.

There are also some other tweak in the MWE below, such as using "cited" instead of "cit." for backrefs, removing "in:" for articles, increasing vertical space for bib items.

\documentclass{article}
\usepackage{xcolor}
\usepackage{hyperref}
\hypersetup{%
    colorlinks=true, 
    citecolor=blue} 

\usepackage{polyglossia}
\setmainlanguage[variant=british]{english}

\usepackage{csquotes}

\PassOptionsToPackage{
        natbib=true,
        style=authoryear-comp,
        hyperref=true,
        backend=biber,
        maxbibnames=99,
        firstinits=true,
        uniquename=init,
        maxcitenames=2,
        parentracker=true,
        url=false,
        doi=false,
        isbn=false,
        eprint=false,
        backref=true,
            }   {biblatex}
\usepackage{biblatex}
\DeclareNameAlias{sortname}{last-first} 

% remove "in:" from articles. Thanks to Herbert.
\renewbibmacro{in:}{%
  \ifentrytype{article}{}{%
  \printtext{\bibstring{in}\intitlepunct}}}

% mit "month" and "language" from Bibliography
\AtEveryBibitem{%
  \clearfield{month}{}%
  \clearlist{language}{}%
  }

% some natbib backwards compatibility 
\let\citealp\cite
\let\cite\textcite

% increase vertical space between bibliography items.
\setlength\bibitemsep{0.5ex}
\setlength\bibnamesep{1.2ex}

% Comma before and after journal volume. Thanks to lockstep.
\renewbibmacro*{volume+number+eid}{%
  \setunit*{\addcomma\space}% NEW
  \printfield{volume}%
  \printfield{number}%
  \printfield{eid}}
  \DeclareFieldFormat[article]{number}{(#1)}% number of a journal

% Citation Hyperlinks (not just years), thanks to Audrey.
\makeatletter
\renewbibmacro*{cite}{% Based on cite bib macro from authoryear-comp.cbx
  \iffieldundef{shorthand}
    {\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
       {\printtext[bibhyperref]{% Include labelname in hyperlink
          \DeclareFieldAlias{bibhyperref}{default}% Prevent nested hyperlinks
          \usebibmacro{cite:label}%
          \setunit{\addspace}%
          \usebibmacro{cite:labelyear+extrayear}}%
          \usebibmacro{cite:reinit}}
       {\iffieldequals{namehash}{\cbx@lasthash}
          {\ifthenelse{\iffieldequals{labelyear}{\cbx@lastyear}\AND
                       \(\value{multicitecount}=0\OR\iffieldundef{postnote}\)}
             {\setunit{\addcomma}%
              \usebibmacro{cite:extrayear}}
             {\setunit{\compcitedelim}%
              \usebibmacro{cite:labelyear+extrayear}%
              \savefield{labelyear}{\cbx@lastyear}}}
          {\printtext[bibhyperref]{% Include labelname in hyperlink
             \DeclareFieldAlias{bibhyperref}{default}% Prevent nested hyperlinks
             \printnames{labelname}%
             \setunit{\nameyeardelim}%
             \usebibmacro{cite:labelyear+extrayear}}%
             \savefield{namehash}{\cbx@lasthash}%
             \savefield{labelyear}{\cbx@lastyear}}}}
    {\usebibmacro{cite:shorthand}%
     \usebibmacro{cite:reinit}}%
  \setunit{\multicitedelim}}

\renewbibmacro*{textcite}{% Based on textcite bib macro from authoryear-comp.cbx
  \iffieldequals{namehash}{\cbx@lasthash}
    {\iffieldundef{shorthand}
       {\ifthenelse{\iffieldequals{labelyear}{\cbx@lastyear}\AND
                    \(\value{multicitecount}=0\OR\iffieldundef{postnote}\)}
          {\setunit{\addcomma}%
           \usebibmacro{cite:extrayear}}
          {\setunit{\compcitedelim}%
           \usebibmacro{cite:labelyear+extrayear}%
           \savefield{labelyear}{\cbx@lastyear}}}
       {\setunit{\compcitedelim}%
        \usebibmacro{cite:shorthand}%
        \global\undef\cbx@lastyear}}
    {\ifnameundef{labelname}
       {\printtext[bibhyperref]{% Include labelname in hyperlink
          \DeclareFieldAlias{bibhyperref}{default}% Prevent nested hyperlinks
          \iffieldundef{shorthand}
            {\usebibmacro{cite:label}%
             \setunit{%
               \global\booltrue{cbx:parens}%
               \addspace\bibopenparen}%
             \ifnumequal{\value{citecount}}{1}
               {\usebibmacro{prenote}}
               {}%
             \usebibmacro{cite:labelyear+extrayear}}
            {\usebibmacro{cite:shorthand}}%
          \ifthenelse{\iffieldundef{postnote}\AND
                      \(\value{multicitetotal}=0\AND\value{citetotal}=1\)}
            {\bibcloseparen% Include closing parenthesis in hyperlink
             \global\boolfalse{cbx:parens}}
            {}}}
       {\printtext[bibhyperref]{% Include labelname in hyperlink
          \DeclareFieldAlias{bibhyperref}{default}% Prevent nested hyperlinks
          \printnames{labelname}%
          \setunit{%
            \global\booltrue{cbx:parens}%
            \addspace\bibopenparen}%
          \ifnumequal{\value{citecount}}{1}
            {\usebibmacro{prenote}}
            {}%
          \iffieldundef{shorthand}
            {\iffieldundef{labelyear}
               {\usebibmacro{cite:label}}
               {\usebibmacro{cite:labelyear+extrayear}}%
             \savefield{labelyear}{\cbx@lastyear}}
            {\usebibmacro{cite:shorthand}%
             \global\undef\cbx@lastyear}%
          \ifthenelse{\iffieldundef{postnote}\AND
                      \(\value{multicitetotal}=0\AND\value{citetotal}=1\)}
            {\bibcloseparen% Include closing parenthesis in hyperlink
             \global\boolfalse{cbx:parens}}
            {}}%
          \savefield{namehash}{\cbx@lasthash}}}%
  \setunit{%
    \ifbool{cbx:parens}
      {\bibcloseparen\global\boolfalse{cbx:parens}}
      {}%
    \multicitedelim}}

\makeatother

% Backrefs "cited" instead of "cit"
\DefineBibliographyStrings{english}{%
backrefpage={cited on p\adddot},
backrefpages={cited on pp\adddot}
}

\addbibresource{bib.bib}

\begin{document}
Finally, as written by \cite{Attanasio2010}, my Bibliography is cool \citep{Galindo2002}. Furthermore (see, for example, \citealp{Attanasio2010}) there are some cool tweaks.

\printbibliography

\end{document}

enter image description here

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.