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 add some "time" information to my online-fields in biblatex. I tried to use the note entry, but that won't work as intended. Right now I got the following:

\documentclass[a4paper, 
    oneside, 
    12pt, 
    bibliography=totocnumbered, 
    listof=totocnumbered
]{scrreprt}
\usepackage[english, ngerman]{babel}
\usepackage[babel,german=quotes]{csquotes}
\usepackage[utf8]{inputenc}
\usepackage[automark]{scrpage2}

\usepackage[backend=biber, style=authoryear, urldate=comp, dateabbrev=false]{biblatex}
\bibliography{source}
\DeclareFieldFormat{url}{\newline\url{#1}}
\DeclareFieldFormat{urldate}{\addcomma\space#1}



\begin{document}
Latex is science \parencite{stack}

\printbibliography

\end{document}

And the file source.bib looks like:

@online{stack,
    author = {Stack},
    title = {Why Latex is science},
    month = {april},
    year = 2012,
    url = {www.tex.stackexchange.com},
    urldate = {2013-04-29},
    note = "14.44 Uhr",
}

This currently gives me the following output:

Current output

What I really need right now is this:

Stack (2012): Why Latex is science, URL: www.tex.stackexchange.com, 29.4.2013, 14.44 Uhr.

So basically:

  • Add time information at the end
  • Add "URL: "-label in front of the actual url
  • change some periods to colon or comma

Any help is appreciated!


Update 1

So I am almost there. The time is added (thanks to Guido). I only need some more field formating. The code part looks like this:

\documentclass[a4paper, 
oneside, 
12pt, 
bibliography=totocnumbered, 
listof=totocnumbered
]{scrreprt}
\usepackage[english, ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage[babel,german=quotes]{csquotes}
\usepackage[automark]{scrpage2}
\usepackage[]{url}


\usepackage[backend=biber, style=authoryear, urldate=comp, dateabbrev=false]{biblatex}
\bibliography{source}
%\begin{filecontents}{biblatex-dm.cfg}
%    \DeclareDatamodelFields[type=field,datatype=literal,skipout=false]{urltime}
%\end{filecontents}
\DeclareFieldFormat{date}{#1}    % Not sure with this one
\DeclareFieldFormat{title}{#1\addcomma}
\DeclareFieldFormat{url}{\newline\bibstring{URL}\addcolon\addspace\url{#1}}
\DeclareFieldFormat{urltime}{#1}
\DeclareFieldFormat{urldate}{\addcomma\space#1\addcomma\addspace\printfield{urltime}}



\begin{document}
Latex is science \parencite{stack}

\printbibliography

\end{document}

And here's a colorful visualization of the way it should be in the end:

how it needs to be in the end

share|improve this question
1  
You can add the image to your question, and remove the leading !. Then, other users with enough reputation can add the ! back. And: Welcome! –  mafp Apr 29 '13 at 21:44
    
Have you tried putting the time and the date in the same field? –  Nicholas Hamilton Apr 29 '13 at 21:47
    
Thank you mafp! Seems like I have enough reputation already. –  Goliathus Apr 29 '13 at 21:48
    
@ADP: I just tried now, but I'm not so sure what the proper format for putting it into the same entry would be. –  Goliathus Apr 29 '13 at 21:52

1 Answer 1

up vote 2 down vote accepted

Modified answer for UPDATE 1

It is better not to use note. Biblatex offers the opportunity to create new fields, so I would create a new field for the url time (urltime).

This can be done with

\begin{filecontents}{biblatex-dm.cfg}
\DeclareDatamodelFields[type=field,datatype=literal,skipout=false]{urltime}
\end{filecontents}

then for the formatting of the URL and related information a possibility is to use the following format instructions:

\DeclareFieldFormat{url}{\newline\bibstring[\MakeUppercase]{url}\addcolon\addspace\url{#1}}
\DeclareFieldFormat{urltime}{#1}
\DeclareFieldFormat{urldate}{%
  \iffieldundef{urlday}
    {}
    {\stripzeros{\thefield{urlday}}\adddot}%
  \iffieldundef{urlmonth}
    {}
    {\stripzeros{\thefield{urlmonth}}\adddot}%
  \printfield{urlyear}%
}

\renewbibmacro{url+urldate}{%
  \printfield{url}\setunit{\addcomma\addspace}
  \printurldate\addcomma\addspace
  \printfield{urltime}}

To change the standard punctuation, from . (dot) to . (comma), one can use

\renewcommand{\newunitpunct}{\adddot}

For the . after the year,

\renewcommand{\labelnamepunct}{\addcomma} 

Finally to remove the month from the label, a possible solution is to use

\AtEveryBibitem{\clearfield{month}} 

Entries in the .bib files now can contain the new urltime field.

@online{stack,
    author = {Stack},
    title = {Why {\LaTeX} is science},
    month = {april},
    year = 2012,
    url = {www.tex.stackexchange.com},
    urldate = {2013-04-29},
    urltime = "14.44 Uhr",
} 

Please notice how properly write LaTeX in a .bib file. In general it is best to enclose whole words in { } of single letters to preserve their capitalisation (and then kerning by enclosing the whole word).

enter image description here

share|improve this answer
    
Thank you Guido, adding the time worked this was. Only thing is, that I get the following warning now: LaTeX Warning: File `biblatex-dm.cfg' already exists on the system. Not generating it from this source. –  Goliathus Apr 29 '13 at 22:34
1  
@Goliathus It's normal once you've already run a LaTeX document containing that filecontents environment: the file doesn't get rewritten. –  egreg Apr 29 '13 at 22:37
1  
This happens on the second or successive run. You have to generate that file only once. You can remove the first snippet after it has been generated the first time. Alternatively load the filecontents package. –  Guido Apr 29 '13 at 22:38
    
Wow Guido, thank you very much! Because of you, I finally got it the way I needed it to be. Furthermore, a nice experience to see how exact one can get in LaTeX. But yeah, it sure is a science that needs to be learned... :} –  Goliathus Apr 30 '13 at 1:35

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.