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 still working on formatting my references according to my department’s standard. I am currently trying to alter a date format but failing.

I need:

30. Sept. 2003.

Yet anything I do doesn’t seem to have any influence. Find attached a MWE:

\documentclass[a4paper,12pt]{article}
\usepackage{xpatch}
\usepackage{polyglossia}
\setmainlanguage[variant=british]{english}
\usepackage{fontspec,xltxtra,xunicode}
\usepackage{csquotes}
\usepackage{url}
\usepackage[style=authoryear-ibid,backend=biber,doi=false,isbn=false,url=false,autolang=hyphen]{biblatex}
     \addbibresource{Merkliste.bib}
     \renewcommand*{\postnotedelim}{\addcolon\space}
     \renewbibmacro{in:}{\ifentrytype{article}{}{\printtext{\bibstring{in}\intitlepunct}}}
    \renewcommand*{\intitlepunct}{\addspace}
     \renewcommand{\bibpagespunct}{\ifentrytype{incollection}{\addperiod\addspace}{\addcolon\addspace}}

\DeclareFieldFormat
  [online]
  {url}{{#1}}
\DeclareFieldFormat
  [online]
  {title}{\mkbibquote{#1\isdot}}
\xpatchbibmacro{title}{\printfield[titlecase]{subtitle}}%
{\printfield[titlecase]{subtitle}\ifentrytype{online}{\addperiod}{}}%
{}{}%
\DeclareFieldFormat{urldate}{#1}
\DeclareFieldFormat{postnote}{#1}
\DeclareFieldFormat{multipostnote}{#1}
\DeclareFieldFormat{pages}{#1}
%% Here are my tries.
\xpatchbibmacro{url+urldate}{\printfield{urlyear}\mkbibmonth{\thefield{urlmonth}}{\thefield{urlday}}}{}{}
    \xpatchbibmacro{date+extrayear}{%
  \printtext[parens]%
}{%
  \setunit*{\addperiod\space}%
  \printtext%
}{}{}

\xpatchbibmacro{title}{\printfield[titlecase]{subtitle}}%
{\printfield[titlecase]{subtitle}\ifentrytype{article}{\addperiod}{}}%
{}{}%

\AtEveryBibitem{\clearlist{language}} % clears language
\AtEveryBibitem{\clearfield{note}}    % clears notes
\AtEveryBibitem{\clearfield{series}}   % clears Series
\AtEveryBibitem{\ifentrytype{book}{\clearfield{number}}{}}
\AtEveryBibitem{\ifentrytype{book}{\clearfield{pages}}{}}

\begin{document}
\nocite{*}. 
\printbibliography
\end{document}

and a .bib-extract:

![@online{secretariat_a_la_politique_linguistique_quebec_dynamique_2014,
    Author = {{Secr{\'e}tariat {\`a} la politique linguistique Qu{\'e}bec}},
    Date-Modified = {2014-08-03 17:01:54 +0000},
    File = {Dynamique des langues en quelques chiffres \: Tableaux - Secr{\'e}tariat {\`a} la politique linguistique.pdf:/Users/Moritz/Desktop/Dynamique des langues en quelques chiffres \: Tableaux - Secr{\'e}tariat {\`a} la politique linguistique.pdf:application/pdf},
    Month = jul,
    Title = {La dynamique des langues en quelques chiffres : Tableaux},
    Urldate = {2014-07-28},
    Year = {2014}}][1]

Here’s my not-perfect output

share|improve this question
    
Is there really a dot after 30? –  Bernard Aug 3 at 17:11
    
Yes, I just double-checked. –  Moritz Aug 3 at 17:15
    
Strange… Never seen that. Btw, do you know that if you use biber, your .bib file can be utf8-encoded, i.e. you can type Québec, for instance (comment aside, I suppose it's du Québec). –  Bernard Aug 3 at 17:19
    
Is the urldate field supposed to be printed in long French format, with mainlanguage=british? –  Bernard Aug 3 at 18:19

2 Answers 2

up vote 5 down vote accepted

Biblatex offers different options to format a date. If the format is not a predefined one, it is possible to use \DeclareFieldFormat to provide a now format, in this case we can provide a format for urldate

\DeclareFieldFormat{urldate}{%
  \thefield{urlday}\adddot\addspace%
  \mkbibmonth{\thefield{urlmonth}}\adddot\addspace%
  \thefield{urlyear}\isdot}

To use the abbreviated version for the month one can use the dateabbrev option of biblatex.

enter image description here

share|improve this answer
    
I'm not sure the braces are correctly placed. –  egreg Aug 3 at 20:03
    
@egreg thanks. fixed now. –  Guido Aug 3 at 20:59
    
There can’t be much that can’t be changed in LaTeX with tex.sx’s help:) –  Moritz Aug 4 at 12:15

biblatex uses more than one date field. We'll want to reformat the output of the date field as well as urldate, for instance. Fortunately, biblatex calls all these date fields through \mkbibdatelong or \mkbibdateshort, so that's what we'll want to look at. We'll also need to count with the possibility that a date field contains only a year, say, or a date range like 1986/1990, so we need to make use of if-then constructions.

Since the document language is set to British English, we'll want to base ourselves on british.lbx. It contains the following definition:

  \protected\def\mkbibdatelong#1#2#3{%
    \iffieldundef{#3}
      {}
      {\mkbibordinal{\thefield{#3}}%
       \iffieldundef{#2}{}{\nobreakspace}}%
    \iffieldundef{#2}
      {}
      {\mkbibmonth{\thefield{#2}}%
       \iffieldundef{#1}{}{\space}}%
    \stripzeros{\thefield{#1}}}%

We need to copy this into our preamble, containing it in the argument of \DefineBibliographyExtras{british} and:

  1. Tell biblatex that we want to use a longer date format using the option alldates=long;
  2. Tell biblatex to abbreviate month names using the option dateabbrev=true;
  3. Remove the alphabetical ordinal in the day field (\mkbibordinal);
  4. Restore the \stripzeros that was previously triggered by the command \mkbibordinal;
  5. Insert our punctuated ordinal with \adddot.

MWE:

\documentclass[a4paper,12pt]{article}
\usepackage{polyglossia}
\setmainlanguage[variant=british]{english}
\usepackage{fontspec}
\usepackage{csquotes}
\usepackage[style=authoryear-ibid,doi=false,isbn=false,url=false,autolang=hyphen,alldates=long,dateabbrev=true]{biblatex}
 \addbibresource{Merkliste.bib}

\DefineBibliographyExtras{english}{%
    \protected\def\mkbibdatelong#1#2#3{%
    \iffieldundef{#3}
      {}
      {\stripzeros{\thefield{#3}}\adddot%
       \iffieldundef{#2}{}{\nobreakspace}}%
    \iffieldundef{#2}
      {}
      {\mkbibmonth{\thefield{#2}}%
       \iffieldundef{#1}{}{\space}}%
    \stripzeros{\thefield{#1}}}%
}

\begin{document}
\nocite{*}
\printbibliography
\end{document}

You'll find that "July" in your sample bibliography is not abbreviated because four-letter months are conventionally not abbreviated.

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.