12

A problem that's been annoying me for years (http://newsgroups.derkeiler.com/Archive/Comp/comp.text.tex/2008-04/msg01387.html) has been how to create a column'ed bibliography. E.g., take a look at the bibliography in:

http://www.cgd.ucar.edu/staff/trenbert/trenberth.papers/UppalaERA05.pdf

enter image description here

That's what I want! Ideally, I'd like four columns (Author, Year, Journal/Source, Title+Pages) rather than the three shown in the example (although that's a start).

4

2 Answers 2

7

This is just an idea and should be expanded according to your needs, of course. I used the xpatch package.

\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{tabularx}
\usepackage{xpatch}
\usepackage{biblatex}
\addbibresource{biblatex-examples.bib}

\newcommand{\prebiba}{%
  \par\begin{tabularx}{\textwidth}{p{7em}p{2em}X}
    \usebibmacro{author}
    & \printdate
    & \clearname{author}\clearfield{year}}
\newcommand{\prebibe}{%
  \par\begin{tabularx}{\textwidth}{p{7em}p{2em}X}
    \usebibmacro{editor+others}
    & \printdate
    & \clearname{editor}\clearfield{year}}
\newcommand{\patchdrivers}{%
  \xpretobibdriver{article}{\prebiba}{}{}%
  \xapptobibdriver{article}{\end{tabularx}}{}{}%
  \xpretobibdriver{book}{\prebiba}{}{}%
  \xapptobibdriver{book}{\end{tabularx}}{}{}%
  \xpretobibdriver{incollection}{\prebiba}{}{}%
  \xapptobibdriver{incollection}{\end{tabularx}}{}{}%
  \xpretobibdriver{collection}{\prebibe}{}{}%
  \xapptobibdriver{collection}{\end{tabularx}}{}{}%
}
\defbibenvironment{tablebib}
  {\setlength{\parindent}{0pt}%
    \renewcommand*{\labelnamepunct}{}%
    \patchdrivers}
  {}
  {}

\begin{document}
\cite{westfahl:space,sigfridsson,piccato,matuz:doody}%
\printbibliography[env=tablebib]%
\end{document}

enter image description here

4
  • Oleg, many thanks; that does seem to achieve the desired result. Could you also post a link to the bib file? When I try to use your code with my own bib, I'm not getting the table, just everything in one line, and no carriage return between references either. Commented May 25, 2013 at 11:45
  • You probably need to add the \par command, see my correction of the code. I also replaced tabu with a less "exotic" tabularx. The bib file is actually from the biblatex distribution: mirrors.ctan.org/macros/latex/contrib/biblatex/bibtex/bib/…. Commented May 25, 2013 at 13:07
  • Certainly, it would be better to use the longtable package here, but unfortunately I couldn't cope with it. Perhaps someone else will. Commented May 25, 2013 at 13:38
  • OK, I can reproduce Oleg's example. As surmised, I'd want to expand this. An initial question: the method in the cls file I posted; that seems to allow the user to define what goes in the 1st, 2nd and 3rd columns (line beginning \def\bib#1#2#3{% ). This tightly defines what goes in each column, but would need the bib file to be written in this custom format. Oleg's method handles a normal bib, but would it need each entry type to be programmed similar to what he's done for the 4 types so far. Is this thinking correct? Commented May 29, 2013 at 15:44
7

This is another approach, which doesn't require patching bib drivers. The code is quite long but the structure is clear, I think.

\documentclass[10pt,english]{article}
\usepackage[a4paper,margin=1cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage[maxbibnames=99,firstinits=true,backref=true]{biblatex}
\addbibresource{biblatex-examples.bib}

\renewbibmacro*{pageref}{%
  \iflistundef{pageref}
    {}
    {\printtext{%
       \ifnumgreater{\value{pageref}}{1}
         {\ppno\ppspace}
         {\pno\ppspace}%
       \printlist[pageref][-\value{listtotal}]{pageref}}}}
\renewbibmacro*{in:}{}
\renewbibmacro*{issue+date}{%
  \ifthenelse{ \iffieldundef{issue} \and \iffieldundef{date} }
    {}
    {\printtext[parens]{%
      \iffieldundef{issue}
        {\usebibmacro{date}}
        {\printfield{issue}%
         \setunit*{\addspace}%
         \usebibmacro{date}}}%
    \newunit}}
\renewbibmacro*{begentry}{%
  \par\textbf{${@}$\printfield{entrytype}}\hrulefill
  \par%
  \tabular{@{}p{.2\textwidth}p{.05\textwidth}p{.3\textwidth}p{.3\textwidth}p{.15\textwidth}@{}}
    \raggedright\parindent=2em\hangindent=2em\noindent\baselineskip=9pt%
    \ifthenelse{  \ifentrytype{article}
                  \or \ifentrytype{inbook}
                  \or \ifentrytype{incollection}
                  \or \ifentrytype{inproceedings}
                  }
      {\usebibmacro{author/translator+others}}
      {}%
    \ifthenelse{  \ifentrytype{book}
                  \or \ifentrytype{booklet}
                  \or \ifentrytype{misc}
                  \or \ifentrytype{online}
                  }
      {\usebibmacro{author/editor+others/translator+others}}
      {}%
    \ifthenelse{  \ifentrytype{collection}
                  \or \ifentrytype{proceedings}
                  }
      {\usebibmacro{editor+others}}
      {}%
    \ifentrytype{manual}
      {\usebibmacro{author/editor}}
      {}%
    \ifthenelse{  \ifentrytype{patent}
                  \or \ifentrytype{report}
                  \or \ifentrytype{thesis}
                  \or \ifentrytype{unpublished}
                  }
      {\usebibmacro{author}}
      {}%
    \ifentrytype{periodical}
      {\usebibmacro{editor}}
      {}
  & \raggedright\noindent\baselineskip=9pt\printfield{year}
  & \parindent=2em\hangindent=2em\noindent\baselineskip=9pt%
    \usebibmacro{title}%
    \newunit
    \printfield{pages}%
    \finentry
  & \parindent=2em\hangindent=2em\noindent\baselineskip=9pt%
    \renewbibmacro*{pageref}{}%
    \renewbibmacro*{title}{}%
    \clearfield{pages}%
    \clearfield{year}%
    \ifthenelse{  \ifentrytype{article}
                  \or \ifentrytype{inbook}
                  \or \ifentrytype{incollection}
                  \or \ifentrytype{inproceedings}
                  }
      {\renewbibmacro*{author/translator+others}{}}
      {}%
    \ifthenelse{  \ifentrytype{book}
                  \or \ifentrytype{booklet}
                  \or \ifentrytype{misc}
                  \or \ifentrytype{online}
                  }
      {\renewbibmacro*{author/editor+others/translator+others}{}}
      {}%
    \ifthenelse{  \ifentrytype{collection}
                  \or \ifentrytype{proceedings}
                  }
      {\renewbibmacro*{editor+others}{}%
       \renewbibmacro*{byeditor+others}{}}
      {}%
    \ifentrytype{manual}
      {\renewbibmacro*{author/editor}{}}
      {}%
    \ifthenelse{  \ifentrytype{patent}
                  \or \ifentrytype{report}
                  \or \ifentrytype{thesis}
                  \or \ifentrytype{unpublished}
                  }
      {\renewbibmacro*{author}{}}
      {}%
    \ifentrytype{periodical}
      {\renewbibmacro*{editor}{}%
       \renewbibmacro*{byeditor}{}}
      {}%
    \nopunct\bibsentence%
}
\renewbibmacro*{finentry}{%
  \finentry
  & \usebibmacro{pageref}
  \endtabular
}

\defbibenvironment{tablebib}
  {\setlength{\parindent}{0pt}}
  {}
  {}

\DeclareNameAlias{default}{last-first}

\begin{document}
\cite{piccato}\cite{matuz:doody}\cite{westfahl:space}%\cite{murray}
\newpage\cite{matuz:doody}\cite{kant:kpv}\cite{ctan}
\newpage\cite{aksin}\cite{matuz:doody}\cite{moraux}
\newpage\cite{westfahl:space}\cite{ctan}%\cite{murray}\cite{gaonkar:in}
\cite{almendro} %patent
\cite{chiu} %report
\cite{geer} %thesis
\cite{jcg}  %periodical
\cite{cms} %manual
\newpage
\printbibliography[env=tablebib]%
\end{document}

enter image description here

13
  • \rm is a 2.09 command, I think rmfamily is the recommended way now. Also, you may want to add another column - OP wanted Journal /Source separate from Title/ pages.
    – ach
    Commented Jun 2, 2013 at 15:55
  • Yes, sure. I just copied it from the .cls above. As for the additional column, this demands specific decisions concerning the style --- what is the Source, what to do with books (when Source and Title are the same) etc. The answer is just an idea which should be definitely adjusted. Commented Jun 2, 2013 at 16:02
  • In fact, it needs quite a lot of adjustments. For example, the macro in the first column might be something like \usebibmacro{author/editor+others/translator+others}, it may depend on the entrytype, the year in the last column may be printed or not and so on. These are all style requirements which are difficult to decide in advance. Commented Jun 2, 2013 at 16:41
  • Whilst I can't write the code myself, I can definitely help in defining the requirements to flesh this out further, to make it as useful as possible. One basic additional requirement I'd like to see here is another column, right at the end, for backrefs. @OlegDomanov is that possible? Commented Jun 2, 2013 at 20:59
  • Sure, let's try to do this (I also need something similar :). Could you then provide some additional information: 1) What biblatex style suits you needs best? Is it a standard style, APA or whatever? (It's better to modify a proper style from the very beginning). 2) So, you need 5 columns: Author/Editor, Year (or full date?), Title+Page, Journal/Source, Backref. Right? Commented Jun 3, 2013 at 4:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .