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 creating my own class file that I want to use for a series of homeworks I have to write for my studies. I got stuck when trying to get the references sorted as per the university's template.

What I need: Cites in footnotes, so I am using \footcite. In the footnotes I need the following format depending on the reference type.
In case of @book:

{Author Lastname}, {Author First letter of firstname}.: {title}, {year}, {pages}

In case of a @online

{Author Lastname}, {Author First letter of firstname}.: {title}, {url} (as of {date})

in the bibliography however I need a different format such as
In case of @book:

{Author Lastname}, {Author Firstname} ({year}): {title}. {location}:{publisher}, {pages}

In case of @online:

{Author Lastname}, {Author Firstname}.: {title}, {url} (as of {date})

For the last couple of days I have been reading the biblatex manual, I have searched the web and I have tried a number of ways to accomplish the above. Unfortunately I failed. I seemed to get closer to a solution by playing with the following command:

\DeclareCiteCommand{\footcite}[]
{}%Pre Code
{%Loop Code
\printnames{author}%
\printtext{:}
\newunit\newblock
\printfield{title}%
\printtext{,}
\newunit\newblock
\printfield{year}% 
\printtext{,}
\newunit\newblock
\printfield{pages} 
}
{\addsemicolon\space}%Sep Code
{}%Post Code

One problem with the above is that I couldn't manage to get the author's name in the right format. I was able to make biblatex abbreviate the first name by using the firstinits package option but then it was abbreviated in the bibliography, too. That I don't want.

The much bigger problem for me is to handle both @book and @online differently. I don't know how to do that with \DeclareCiteCommand.

I figured I needed help so I started to create a simplified example. Please see below.

\documentclass{article}

\usepackage[backend=biber,style=authoryear]{biblatex}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{book2000, author={Jon Smith}, title={The Book's Title}, pages = {S. 42 - S. 44}, year={2000}}

@online{web2000, author={Author}, title={The website's Title}, date={2000-01-01}, url={www.myurl.com}, year={2001}}
\end{filecontents}

\addbibresource{\jobname.bib}

\begin{document}

Book\footcite{book2000}
Website\footcite{web2000}

\printbibliography

\end{document}

I really do appreciate any help with the above!

share|improve this question
1  
Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. Please, consider registering on the site. You can load different styles for citations and bibliographies via citestyle and bibstyle options; check if any of the styles already provided fill your needs (it looks like an authortitle citation style and an authoryear bibliographics one, with some changes on the punctuation --- for the latter, check lockstep guidelines for customizing biblatex styles) –  henrique Jul 31 '13 at 1:12
    
Quick heads-up for everybody who is interested in this topic. Further to @henrique 's answer I removed style from the example above and I tried citestyle and bibstyle with all existing styles. I got pretty close to what I need but I couldn't get the exact result I need. Eventually I figured I had to create my own styles, i.e. my own .cbx and .bbx files. I am following some guides @henrique referenced and their references in turn. I am in the middle of the process but making some progress. I will post the solution once I have it, probably some time next week. –  Alex Aug 2 '13 at 12:28

1 Answer 1

Having checked a number of potential solutions I found the best way for me to solve my problem was to create my own styles for both bibliography and citations. See below a brief overview of what I did just in case somebody is having a similar issue.

Formatting of cites in bibliography

See below my entire bbx file. It starts with setting the format of some fields. The main part below is about writing a driver for each entry type. In those drivers one can freely determine the order of fields, the separators etc.

\ProvidesFile{mybbx.bbx}

\RequireBibliographyStyle{standard}

\DeclareFieldFormat{title}{#1\isdot}        % title not to be italic 
\DeclareFieldFormat[article]{title}{#1}         % title not to be italic 
\DeclareFieldFormat[book]{title}{#1}        % title not to be italic

\DeclareFieldFormat[norm]{chapter}{#1}  % remove "chap."
\DeclareFieldFormat[norm]{edition}{#1}

\DeclareFieldFormat[manual]{edition}{#1}

\DeclareFieldFormat{pages}{S.\addspace#1} % replace "pp." with "S."

\DeclareFieldFormat{volume}{#1}         %remove "vol."

\DeclareFieldFormat{url}{\burl{#1}}

\setlength{\bibitemsep}{10pt}           %reduce vertical space

\DeclareNameAlias{author}{sortname} %<lastname>, <firstinit>.
\DeclareNameAlias{editor}{sortname} %<lastname>, <firstinit>.
\DeclareNameAlias{translator}{sortname} %<lastname>, <firstinit>.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 \defbibenvironment{bibliography}
                     {\list{}
                        {\setlength{\leftmargin}{\bibhang}%
                         \setlength{\itemindent}{-\leftmargin}%
                         \setlength{\itemsep}{\bibitemsep}%
                         \setlength{\parsep}{\bibparsep}}}
                     {\endlist}
                     {\item}


\DeclareBibliographyDriver{book}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \printnames{author}%
  \addspace
  (\printfield{labelyear})%
  \setunit{\addcolon\addspace}\newblock
  \usebibmacro{title}%
  \addcomma\addspace
  \iffieldundef{volume}
    {}%
    {\printfield{volume}
    \addcomma\addspace} 
  \printlist{location}%
  \addspace
  \printfield{labelyear}%
  \usebibmacro{finentry}}


\DeclareBibliographyDriver{online}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \printlist{publisher}%
  \addspace
  (Hrsg.) (%
  \iffieldundef{labelyear}
    {o. J.}%
    {\printfield{labelyear}}%
  )%
  \setunit{\addcolon\space}%
  \newunit
  \printfield{title}%
  \setunit{\addcomma\space}%
  \printtext{online:}\addspace%
  \printfield{url}
  \setunit{\addcomma\space}%
  Stand: \printfield{edition}, %
  Abruf: \printlist{location}.%
  }


\DeclareBibliographyDriver{manual}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{title}%
  \renewcommand*{\newunitpunct}{}%
  \addspace%
  \newunit%
  \mkbibparens{\printfield{volume}}%
  \renewcommand*{\newunitpunct}{\addcomma\space}
  \newunit%
  \printtext{hrsg. von}%
  \addspace%
  \printlist{organization}%
  \newunit%
  \usebibmacro{publisher+location+date}%
  \renewcommand*{\newunitpunct}{\adddot\space}%
  \usebibmacro{finentry}}


\DeclareBibliographyDriver{norm}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  NORM DIN
  \addspace
  \printfield{number}%
  \addspace
  \iffieldundef{chapter}
    {}%
    {\printfield{chapter}} 
  \printfield{edition}%
  .
  \printfield{title}%
  \usebibmacro{finentry}}    

\endinput

Formatting of cites in footnotes

Analog to bbx files for formatting bibliography entries one has to create a cbx file for formatting cites. It appears to me the concept of drivers for each bib entry type doesn't exist in cbx files though. Hence I implemented something similar myself as you can see in my macro cite below. This macro always gets called first. It checks the entry type and calls the respective macro to render the entry.

\ProvidesFile{mycbx.cbx}

\newbibmacro*{cite}{%
  \ifentrytype{book}{\usebibmacro{cite:book}}{}%
  \ifentrytype{online}{\usebibmacro{cite:online}}{}%
  \ifentrytype{manual}{\usebibmacro{cite:manual}}{}%
  \ifentrytype{norm}{\usebibmacro{cite:norm}}{}%  
}


\DeclareCiteCommand{\footcite}[\mkbibfootnote]
  {\usebibmacro{prenote}}%  Pre-Code
  {\usebibmacro{citeindex}%     Loop-Code
   \usebibmacro{cite}}
  {\multicitedelim}%            Sep-Code
  {\usebibmacro{postnote}}%     Post-Code


\newbibmacro{cite:book}{%
  \ifnameundef{editor}
    {}
    {\printnames{editor}\addspace}
  \addspace%
  \printnames{labelname}%
  \setunit{\addcolon\addspace}%
  \printfield{labeltitle}%
  \setunit{\addcomma\addspace}%
  \printfield{labelyear}%
  \setunit{\addcomma\addspace}%
  \printfield{pages}%
}


\newbibmacro{cite:online}{%
  \addspace
  \printlist{publisher}%
  \addspace%
  (Hrsg.):%
  \setunit{\space}%
  \printfield{title}%
  \setunit{\addcomma\space}%
  \printtext{online:}\addspace%
  \printfield{url}
  \setunit{\addcomma\space}%
  (Abruf: \printlist{location})%
}


\newbibmacro{cite:manual}{%
  \addspace
  \printlist{organization}%
  \addspace%
  \mkbibparens{\printfield{volume}}%
  \setunit{\addcolon\addspace}
  \usebibmacro{title}%
}


\newbibmacro{cite:norm}{%
  \addspace
  DIN
  \addspace
  \printfield{number}%
  \setunit{\addcomma\addspace}
  \printfield{title}%
}

\endinput

MWE tex file

See below the corresponding MWE tex file.

\documentclass[11pt,a4paper]{article}

\usepackage[citestyle=mycbx,bibstyle=mybbx,labeldate=true,labeltitle=true,sorting=none,backend=biber]{biblatex}%    References

\RequireCitationStyle{mycbx}%           custom style for citations (in my case focus on footcite)
\RequireBibliographyStyle{mybbx}%       custom style for bibliography (in my case focus on footcite)

\usepackage{breakurl}%              allow for page breaks in URLs

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@norm{Din69900,Chapter = {Teil 2},  Edition = {01.09},Number = {69900},Title = {Projektmanagement}}
@book{stein2009projektmanagement,Address = {Renningen},Author = {{Stein, F.}},Editor = {vgl.},Publisher = {Expert-Verlag GmbH},Series = {Kontakt und Studium},Title = {Projektmanagement f{\"u}r die Produktentwicklung - Strategien, Erfolgsfaktoren, Organisation},Volume = {3. neu bearbeitete und erweiterte Auflage},Year = {2009}}
@manual{Flyer,Address = {Berlin},Organization = {MyCompany},Title = {Title},Volume = {2012}}
@online{ApoG,   Address = {03.08.2013}, Edition = {15.10.1980},Publisher = {juris GmbH},    Title = {ApoG - Gesetz {\"u}ber das Apothekenwesen}, Url = {www.juris.de/purl/gesetze/_ges/ApoG}, Year = {1980}}
\end{filecontents}

\addbibresource{\jobname.bib}

\begin{document}

  Norm\footcite{Din69900}
  Book\footcite{stein2009projektmanagement}
  Manual\footcite{Flyer}
  Website\footcite{ApoG}

\printbibliography

\end{document}

Open Issues

The above solutions works fine for me and I have been able to solve all my problems. Please note though that in some cases for the sake of time I had to go for the quick and dirty kind of way to solve specific issues. One example was data of certain fields from bib entries not showing up. Despite the respective macros like \printfield not showing any error in some cases they simply didn't generate any output. As a quick and dirty workaround I then abused a different field that happened to work in order to show my data. For instance the address field in the @online entry is not supposed to contain a date but I had to abuse the field because I couldn't make urldate or lastchecked work for me. Anther workaround you will find in the bib driver for @norm. Between the field edition and title I had to put the dot explicitly into the code. When I was trying to use proper commands such as \setunit I couldn't get the order of the separator and spaces in the order I wanted.

Please note that I consider this topic closed now as I got the result I needed. I will continue to investigate the workarounds but I am going to start separate threads on those if needed.

share|improve this answer
    
urldate is not technically a printable field but a date field, you can access its contents trough \printurldate though. In case of @norm, I'm not entirely sure what you want to achieve, but maybe \printunit or a starred version of \setunit or \printunit might help you there. If you really consider this topic closed, you should mark it as solved by accepting your own answer here. –  moewe Sep 13 '13 at 6:28

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.