2

I'm trying to set a bibliography this way:

\documentclass[12pt,french]{report}
\usepackage[backend=bibtex,
style=alphabetic
]{biblatex}
\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@article{Cha65,
  author = {Charles, Daniel},
  year = {1965},
  title = {Entr’acte: “Formal” or “Informal” Music?},
  journaltitle = {The Musical Quarterly},
  volume = {51},
  number = {1},
  pages = {144--165},
}
\end{filecontents}

\addbibresource{\jobname.bib}
\begin{document}
\nocite{*}
\printbibliography
\addcontentsline{toc}{chapter}{Bibliography}
\end{document}

Which biblatex's style allows me to display citation this way [AuthorName, Last_two_integers_of_year_number], please ?

Thanks a lot!

doncherry
  • 54,637
dgs
  • 1,637
  • Please post complete code i.e. a complete, small document which includes the class, packages, \begin{document}... \end{document} and which demonstrates the issue. A complete Minimal Working Example is much more useful than mere fragments. Could you also explain the problem? Is it that you are missing a comma and space? – cfr Apr 11 '14 at 23:42
  • @cfr, I've updated my post. – dgs Apr 11 '14 at 23:48
  • Thanks for providing an MWE! Is biber an option? – cfr Apr 11 '14 at 23:49
  • @cfr, I'm beginner to this. You can use what you want until the it answers the question. – dgs Apr 11 '14 at 23:58

1 Answers1

4

This solution modifies the default template for the label. This requires biber rather than bibtex as the backend. This means that the compilation sequence needs to be altered, too:

pdflatex <filename>.tex
biber <filename>
pdflatex <filename>.tex

with possibly an additional

pdflatex <filename>.tex

It will work fine with latex rather than pdflatex - just biber is essential.

\documentclass[12pt,french]{report}
\usepackage{babel}% needed for french
\usepackage[utf8]{inputenc}% needed for sample bib entry
\usepackage{csquotes}% recommended in output (biblatex)
   \MakeAutoQuote*{“}{”}
\usepackage[T1]{fontenc}
\usepackage[backend=biber, style=alphabetic]{biblatex}
\DeclareLabelalphaTemplate{% adjust the template for the label based on the default one - requires biber
  \labelelement{%
    \field[final]{shorthand}% if shorthand specified, use it
    \field{label}% if label specified, use it
    \field[strside=left]{labelname}% if not, use the labelname e.g. author
  }
  \labelelement{%
    \literal{,}% add comma
  }
  \labelelement{%
  \field[strwidth=2,strside=right]{year}% take the rightmost 2 numbers from the year
  }
}
\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@article{Cha65,
  author = {Charles, Daniel},
  year = {1965},
  title = {Entr’acte: “Formal” or “Informal” Music?},
  journaltitle = {The Musical Quarterly},
  volume = {51},
  number = {1},
  pages = {144--165},
}
\end{filecontents}

\addbibresource{\jobname.bib}
\begin{document}
\nocite{*}
\printbibliography
\addcontentsline{toc}{chapter}{Bibliography}
\end{document}

Bibliography

Note that you should check your MWE compiles before posting it. Yours spewed errors which required me to modify it in order to get to the point where I could begin thinking about your question. Minimal is great and definitely what's needed - just make sure it isn't so minimal it doesn't work!

Too Many Names

The above code will cause havoc if your entries have too many authors (or, indeed, if they have names which are too long). The following code will use only the first name but it will append a + if there are other names in the entry. (This seems to be default.)

\documentclass[12pt,french]{report}
\usepackage{babel}% needed for french
\usepackage[utf8]{inputenc}% needed for sample bib entry
\usepackage{csquotes}% recommended in output (biblatex)
   \MakeAutoQuote*{“}{”}
\usepackage[T1]{fontenc}
\usepackage[backend=biber, style=alphabetic]{biblatex}
\DeclareLabelalphaTemplate{% adjust the template for the label based on the default one - requires biber
  \labelelement{%
    \field[final]{shorthand}% if shorthand specified, use it
    \field{label}% if label specified, use it
    \field[names=1,strside=left]{labelname}% if not, use the labelname e.g. author
  }
  \labelelement{%
    \literal{,}% add comma
  }
  \labelelement{%
  \field[strwidth=2,strside=right]{year}% take the rightmost 2 numbers from the year
  }
}
\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@article{Cha65,
  author = {Charles, Daniel},
  year = {1965},
  title = {Entr’acte: “Formal” or “Informal” Music?},
  journaltitle = {The Musical Quarterly},
  volume = {51},
  number = {1},
  pages = {144--165},
}
@article{Cha66,
  author = {Charles, Daniel and Christmas, Father and Fairy, Tooth and Pan, Peter and Beanstalk, Jack},
  year = {1966},
  title = {Entr’acte: “Formal” or “Informal” Music?},
  journaltitle = {The Musical Quarterly},
  volume = {51},
  number = {1},
  pages = {144--165},
}
\end{filecontents}

\addbibresource{\jobname.bib}
\begin{document}
\nocite{*}
\printbibliography
\addcontentsline{toc}{chapter}{Bibliography}
\end{document}

Another bibliography

If an individual author has a very long name, you have a couple of options. One is to truncate all names to some number of letters. (The standard label uses this method with 2 letters but you can specify a different number.) The following uses the first 8 characters of the first author's name:

\documentclass[12pt,french]{report}
\usepackage{babel}% needed for french
\usepackage[utf8]{inputenc}% needed for sample bib entry
\usepackage{csquotes}% recommended in output (biblatex)
   \MakeAutoQuote*{“}{”}
\usepackage[T1]{fontenc}
\usepackage[backend=biber, style=alphabetic]{biblatex}
\DeclareLabelalphaTemplate{% adjust the template for the label based on the default one - requires biber
  \labelelement{%
    \field[final]{shorthand}% if shorthand specified, use it
    \field{label}% if label specified, use it
    \field[strwidth=8,names=1,strside=left]{labelname}% if not, use the labelname e.g. author - use the first 8 characters of the first author's name
  }
  \labelelement{%
    \literal{,}% add comma
  }
  \labelelement{%
  \field[strwidth=2,strside=right]{year}% take the rightmost 2 numbers from the year
  }
}
\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@article{Cha65,
  author = {Charles, Daniel},
  year = {1965},
  title = {Entr’acte: “Formal” or “Informal” Music?},
  journaltitle = {The Musical Quarterly},
  volume = {51},
  number = {1},
  pages = {144--165},
}
@article{Cha66,
  author = {Charles, Daniel and Christmas, Father and Fairy, Tooth and Pan, Peter and Beanstalk, Jack},
  year = {1966},
  title = {Entr’acte: “Formal” or “Informal” Music?},
  journaltitle = {The Musical Quarterly},
  volume = {51},
  number = {1},
  pages = {144--165},
}
@article{Cha67,
  author = {CharlesChristmasFairtyPanBeanstalk, Daniel and Christmas, Father and Fairy, Tooth and Pan, Peter and Beanstalk, Jack},
  year = {1967},
  title = {Entr’acte: “Formal” or “Informal” Music?},
  journaltitle = {The Musical Quarterly},
  volume = {51},
  number = {1},
  pages = {144--165},
}
\end{filecontents}

\addbibresource{\jobname.bib}
\begin{document}
\nocite{*}
\printbibliography
\addcontentsline{toc}{chapter}{Bibliography}
\end{document}

Yet another bibliography

The other option is to override the default labelling for specific entries:

\documentclass[12pt,french]{report}
\usepackage{babel}% needed for french
\usepackage[utf8]{inputenc}% needed for sample bib entry
\usepackage{csquotes}% recommended in output (biblatex)
   \MakeAutoQuote*{“}{”}
\usepackage[T1]{fontenc}
\usepackage[backend=biber, style=alphabetic]{biblatex}
\DeclareLabelalphaTemplate{% adjust the template for the label based on the default one - requires biber
  \labelelement{%
    \field[final]{shorthand}% if shorthand specified, use it
    \field{label}% if label specified, use it
    \field[names=1,strside=left]{labelname}% if not, use the labelname e.g. author - use the first 8 characters of the first author's name
  }
  \labelelement{%
    \literal{,}% add comma
  }
  \labelelement{%
  \field[strwidth=2,strside=right]{year}% take the rightmost 2 numbers from the year
  }
}
\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@article{Cha65,
  author = {Charles, Daniel},
  year = {1965},
  title = {Entr’acte: “Formal” or “Informal” Music?},
  journaltitle = {The Musical Quarterly},
  volume = {51},
  number = {1},
  pages = {144--165},
}
@article{Cha66,
  author = {Charles, Daniel and Christmas, Father and Fairy, Tooth and Pan, Peter and Beanstalk, Jack},
  year = {1966},
  title = {Entr’acte: “Formal” or “Informal” Music?},
  journaltitle = {The Musical Quarterly},
  volume = {51},
  number = {1},
  pages = {144--165},
}
@article{Cha67,
  label = {CharlesCh},
  author = {CharlesChristmasFairtyPanBeanstalk, Daniel and Christmas, Father and Fairy, Tooth and Pan, Peter and Beanstalk, Jack},
  year = {1967},
  title = {Entr’acte: “Formal” or “Informal” Music?},
  journaltitle = {The Musical Quarterly},
  volume = {51},
  number = {1},
  pages = {144--165},
}
\end{filecontents}

\addbibresource{\jobname.bib}
\begin{document}
\nocite{*}
\printbibliography
\addcontentsline{toc}{chapter}{Bibliography}
\end{document}

A variation on Yet another bibliography

cfr
  • 198,882
  • When I compile your code, I get no error but when I display the PDF output I can not see the Bibliography's page. Why please? – dgs Apr 12 '14 at 00:27
  • How are you compiling it? Did you run biber? – cfr Apr 12 '14 at 00:28
  • Oh! When I run biber, I get : INFO - This is Biber 1.5 ,INFO - Logfile is 'fullPathName.tex.blg', ERROR - Cannot find control file 'fullPathName.tex.bcf' - did you pass the "backend=biber" option to BibLaTeX? – dgs Apr 12 '14 at 00:33
  • You are trying to run biber on the .tex file. Don't. It will make no sense of it. Don't specify an extension at all. Just write biber fullPathName. Note in my example above, I drop the extension for the biber run. – cfr Apr 12 '14 at 00:39
  • Well done! That've worked, but look at the bibliography's format that I'm getting. How do I to format this, please? – dgs Apr 12 '14 at 00:44
  • I can't tell without seeing the code that causes that. Obviously the code you posted in your question doesn't trigger it. At a guess, I would say that you have an extremely long author name or list of authors which makes the label for that item very wide and results in lots of space being required for it. How exactly do you want that case handled? And can you post the entry which triggers it? (Add it to your original question.) – cfr Apr 12 '14 at 00:52
  • yes you're right. Here is the full bibliography. – dgs Apr 12 '14 at 00:58
  • Is it possible then to only get the name of the first author? [KING,99] for the first line, for example? – dgs Apr 12 '14 at 01:00
  • @user3289501 See my edit for a way to use only the first author's name. I've also offered a couple of different strategies in case you have any first author's who just have extremely long names. (You don't seem to right now but if you need to add one - you don't want to not use stuff because its authors have awkwardly long names ;).) – cfr Apr 12 '14 at 01:26
  • @user3289501 You might also look at http://tex.stackexchange.com/a/155908/39222. I can't figure out how to insert a space in the labels using alphabetic but that answer suggests you might be able to adapt the authoryear style instead. I'm not sure if that is the approach you are looking for, though. – cfr Apr 12 '14 at 02:14
  • This way \literal{,~ }. – dgs Apr 12 '14 at 02:32
  • @user3289501 Does that work for you? For me, I just get a literal tilde sign with no space. – cfr Apr 12 '14 at 02:34
  • yes that works, I've just only replace the \literal{,} that you have posted with that one. – dgs Apr 12 '14 at 02:38
  • you need to add a space after the tilde. – dgs Apr 12 '14 at 02:39
  • Has that worked? – dgs Apr 12 '14 at 02:52
  • @user3289501 No. It doesn't work for me. But, hey, it is your question so if it works for you, that's great. I don't know why it works for you but not me but I have a later version of biblatex and biber, I think. My biber is 1.8 whereas you seem to have 1.5. biblatex will differ similarly as it is quite sensitive to biber version. So it is likely something is different in how current biber/biblatex handles this case. – cfr Apr 12 '14 at 03:01
  • please try this \literal{,\addhighpenspace}, has this worked? – dgs Apr 12 '14 at 03:06
  • These two commands work for me. – dgs Apr 12 '14 at 03:09
  • @user3289501 Yes! \literal{,\addhighpenspace} does work, indeed. What does it do? (I read the explanation in the manual but don't really know what it means.) By the way, have you considered changing your name to something a little less awkward? – cfr Apr 12 '14 at 03:42
  • that's cool! my name? Which name are you talking about? – dgs Apr 12 '14 at 03:43
  • @user3289501 Your username is currently user3289501. That makes you difficult to identify - 'now, let's see... was it 3289501 who said that? or maybe it was 3289499?- and is also more awkward to type. I'm not saying it isn't a lovely name and all. But you must admit it is a little... institutional. Impersonal. You can change it in your user profile to something slightly more meaningful. http://tex.stackexchange.com/users/46158/user3289501 and chooseedit. Change yourdisplay name`. – cfr Apr 12 '14 at 03:51
  • is it better now :p ? – dgs Apr 12 '14 at 03:52
  • @cfr'srecommandation Technically that is, indeed, more meaningful ;). But it is not precisely what I had in mind... What will you do when scandal drags my name (and yours) through the mud of TeX SE?! – cfr Apr 12 '14 at 03:54
  • I was kidding :) :p – dgs Apr 12 '14 at 03:57
  • @dgs So was I :). – cfr Apr 12 '14 at 11:12