Let's tackle it systematically.
First locate the relevant driver for an entry type that's causing problems: in this case book
(well, actually, in your data incollection
: but we're much better of starting with book
). We find that, after a bit of digging in standard.bbx
(edited).
\DeclareBibliographyDriver{book}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author/editor+others/translator+others}%
\setunit{\labelnamepunct}\newblock
\usebibmacro{maintitle+title}%
...
\newunit\newblock
\printfield{edition}%
...
\newunit\newblock
\usebibmacro{publisher+location+date}%
\newunit\newblock
....
\usebibmacro{finentry}}
Almost immediately we get a clue to the first problem -- the colon. It looks as if \labelnamepunct
gets printed after the author. That turns out to be common to all the drivers we are interested in, and we can redefine it to obtain our colon:
\renewcommand\labelnamepunct{\addcolon\space}
The publisher information is trickier. Let's identify what we want. The information in parentheses seems to consist of the publisher, then a comma, then the original year of publication, then the edition (including 1st), then NO comma, then the year of publication of the most recent edition if it hasn't been printed before. What a muddle!
Our first thought might be to fiddle with the publisher+location+date
macro. But if we look at standard.def
we can see that it's used in a variety of places, not just books and book-like documents; so we might want to be careful. For the moment, it seems safer to define a new macro. Let's take it in stages.
Normally I'd start with a wrapper to make sure there was something to print. But actually we know there will be, because if nothing else everything will be a first edition!
\newbibmacro{publication:info}{%
\printtext{\bibopenparen}
% PUBLISHER,
% ORIGINAL YEAR IF THERE IS ONE OTHERWISE YEAR IF THERE IS ONE,
% EDITION or 1st EDITION
% YEAR IF NOT ALREADY PRINTED
\printtext{\bibcloseparen}}
That gives us a skeleton. Now we can fill in the parts.
Publisher is easy:
\printlist{publisher}%
\newunit
Original or most recent year is a bit trickier: we need to test and clear the year field if it is used to stop it being printed twice
\iffieldundef{origyear}
{\iffieldundef{year}
{}
{\printfield{year}%
\clearfield{year}}}
{\printfield{origyear}%
\clearfield{origyear}}%
\newunit
Edition has only one complication: if no edition has been given, we assume the first (which apparently gets printed -- not something I've ever seen!)
\iffieldundef{edition}
{\printtext{\mkbibordinal{1}\space\bibstring{edition}}}
{\printfield{edition}}
Then we have a complication: we don't want a comma, but a space before the year (if it remains to be printed). Since we have cleared the field if it's already been used, we don't need to do any checking
\setunit{\addspace}%
\printfield{year}%
And finally we have to reckon with the possibility that we may have some stray punctuation hanging around, so we get rid of that before closing the parens;
\setunit{}%
\printtext{\bibcloseparen}}
Having done that we then need to reincorporate it into our driver. Since we are going to be handling the edition in the publication:info
macro we delete the lines dealing with that. We then incorporate the publication:info
, but since this is parenthetical, we put spaces around it. So we replace the lines around \usebibmacro{publisher+location+date}
as follows:
\setunit{\addspace}\newblock
\usebibmacro{publication:info}%
\setunit{\addspace}\newblock
Now we test this in various ways, and if we are happy it's working for a book, we then work out what other drivers need to have the edition and publisher info replaced: certainly inbook
and incollection
: possibly others.
The end result of the amendment to the book driver is given at the end of this long answer. I've taken it slowly because if you are working on a standard style it may be helpful to see some tips about how to tackle the task; I don't say they are perfect, but they work for me most of the time. Do remember that if this is intended to be a standard style you need to reckon with the possibility of less-than-perfect data, and decide how graceful you will be with it. And you need lots of test data and to test constantly, because it's terribly easy to make a small change that causes havoc, such as a missing comment character in a macro that throws all your spacing.
\renewcommand{\labelnamepunct}{\addcolon\space}
\DeclareBibliographyDriver{book}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author/editor+others/translator+others}%
\setunit{\labelnamepunct}\newblock
\usebibmacro{maintitle+title}%
\newunit
\printlist{language}%
\newunit\newblock
\usebibmacro{byauthor}%
\newunit\newblock
\usebibmacro{byeditor+others}%
\newunit\newblock
\iffieldundef{maintitle}
{\printfield{volume}%
\printfield{part}}
{}%
\newunit
\printfield{volumes}%
\newunit\newblock
\usebibmacro{series+number}%
\newunit\newblock
\printfield{note}%
\setunit{\addspace}\newblock
\usebibmacro{publication:info}%
\setunit{\addspace}\newblock
\usebibmacro{chapter+pages}%
\newunit
\printfield{pagetotal}%
\newunit\newblock
\iftoggle{bbx:isbn}
{\printfield{isbn}}
{}%
\newunit\newblock
\usebibmacro{doi+eprint+url}%
\newunit\newblock
\usebibmacro{addendum+pubstate}%
\setunit{\bibpagerefpunct}\newblock
\usebibmacro{pageref}%
\usebibmacro{finentry}}
\newbibmacro{publication:info}{%
\printtext{\bibopenparen}%
\printlist{publisher}%
\newunit
\iffieldundef{origyear}
{\iffieldundef{year}
{}
{\printfield{year}%
\clearfield{year}}}
{\printfield{origyear}%
\clearfield{origyear}}%
\newunit
\iffieldundef{edition}
{\printtext{\mkbibordinal{1}\space\bibstring{edition}}}
{\printfield{edition}}%
\setunit{\addspace}%
\printfield{year}%
\setunit{}%
\printtext{\bibcloseparen}}
You ask several things in the question. Here is my proposed solution, with an explanation following.
\documentclass{article}
\usepackage{xstring}
\usepackage[style=alphabetic,maxbibnames=99]{biblatex}
\addbibresource{ref.bib}
\DeclareLabelalphaTemplate{
\labelelement{
\field[strwidth=4,strside=left,names=1,lowercase]{labelname}
}
\labelelement{
\field[strwidth=2,strside=right]{year}
}
}
\renewcommand{\labelalphaothers}{}
\DeclareFieldFormat{labelalpha}{\textsc{\padded{#1}}}
%\DeclareFieldFormat{extraalpha}{\textsc{\mknumalph{#1}}}
\newcommand{\padded}[1]{\begingroup%
\expandarg\StrGobbleRight{#1}{2}[\mystr]%
\StrLeft{\mystr \textunderscore\textunderscore\textunderscore\textunderscore}{4}%
\StrRight{#1}{2}%
\endgroup}
\begin{document}
\cite{one,oneo,two,three,four}
\printbibliography
\end{document}
with ref.bib
given at the end of my answer.
Firstly, the alphabetic
style is the closest to the one you request and is modifiable via the \DeclareLabelalphaTemplate
. The code above pulls off up to four characters from the last name of the first author, adds to the two final digits of the year, and final a letter to disambiguate if necessary. We make the letters lowercase in preparation for makeing them small caps.
The command setting \labelalphaothers
to null, ensures that no +
sign is added when there are several authors.
The formatting of the labels as small caps is acheived via changing the field format of labelalpha
. This is the part of the label up to and including the year digits, but not the disambiguation letter. If you want that in small caps then uncomment the line with extraalpha
.
Now I use the xstring
package to deal with the padding issue via a command \padded
. We pull off the year, add on underscores and take just the first four characters. Then we put the year back on. The \expandarg
command ensures that only \mystring
gets expanded in the argument to \StrLeft
, expanding the underscores would give problems.
@Article{one,
author = {Author, A. N. and Brother, K. and Style, D.},
title = {One article},
journal = {J. J.},
year = 2003
}
@Article{oneo,
author = {Any, A. N. and Brother, K. and Stile, D.},
title = {One article},
journal = {J. J.},
year = 2003
}
@Misc{three,
author = {Ma, A. and Many, B. and Many, C. and Many, D. and
Many, E.},
title = {One page},
year = 2005
}
@Misc{four,
author = {Ma, A. and Many, B. and Many, C. and Many, D. and
Many, F.},
title = {One page},
year = 2005
}
@Book{two,
author = {Weeks, P. and Days, X. and Years, R. and Months, S.},
editor = {May, X.},
title = {One book},
publisher = {U. Publ.},
year = 2001
}
Best Answer
You can often avoid modifying each individual bibliography driver by applying edits to the bibliography macros instead. In the standard styles the
begentry
bibiliography macro appears at the beginning of every driver. This is a good place to add the item "header".Standard drivers typically print publishing information in the form
<location>: <publisher>
. For most entry types this order can be swapped by editing thepublisher+location+date
bibliography macro.The rest of the problem is handled with edits to
biblatex
's delimiter/punctuation commands and name formats. Here's an example.