2

I am using the code as suggested by Audrey in this post in order to produce a tabular bibliography and adapted it as follows.

Naturally, the authors' names should be printed in the first column and everything else in the second, yet the names are repeated in the second column. The second modification that I wish to make, is to add some text between the heading and the table.

\documentclass[12pt,a4paper,oneside]{memoir}
\usepackage[backend=biber,style=biblatex-swiss-legal-general]{biblatex}
\usepackage{etoolbox}
\usepackage{chngcntr}
\usepackage{csquotes}
\usepackage{array}
\usepackage{ragged2e}
\newcolumntype{P}[1]{>{\raggedright\hspace{0pt}}p{#1}}
\usepackage{multicol}
\usepackage{etoolbox}

\renewcommand{\mkbibnamefirst}[1]{\textsc{#1}}
\renewcommand{\mkbibnamelast}[1]{\textsc{#1}}
\renewcommand{\mkbibnameprefix}[1]{\textsc{#1}}
\renewcommand{\mkbibnameaffix}[1]{\textsc{#1}}

\makeatletter

% user-level command for printing tabular bibliography
\let\printbibtabular\printbibliography
\patchcmd{\printbibtabular}{\blx@printbibliography}{\bbx@printbibtabular}{}{}
\patchcmd{\printbibtabular}{\blx@printbibliography}{\bbx@printbibtabular}{}{}
\let\bbx@printbibtabular\blx@printbibliography
\patchcmd{\bbx@printbibtabular}{\blx@bibliography}{\bbx@bibtabular}{}{}
\patchcmd{\bbx@printbibtabular}
  {\def\blx@theenv{bibliography}}{\def\blx@theenv{bibtabular}}{}{}

% underlying macros
\def\bbx@bibtabular#1{%
  \blx@bibheading\blx@theheading\blx@thetitle
  \blx@bibnote\blx@theprenote
  \begingroup
  \blx@bibinit
  \let\@noitemerr\@empty
  \let\blx@noitem\blx@warn@bibempty
  \ifnum\bibinitsep=\z@
    \let\blx@initsep\relax
  \fi
  \ifnum\bibnamesep=\z@
    \let\blx@namesep\relax
  \fi
  \csuse{blx@hook@bibinit}%

  % copy filtered list of entries to internal list macro
  \def\blx@do##1{%
    \blx@ifdata{##1}{%
      \begingroup
      \blx@getdata{##1}
      \blx@bibcheck
      \iftoggle{blx@skipentry}{}{%
        \global\let\blx@noitem\@empty
        \listadd\blx@tempa{##1}}%
      \endgroup}{}}
  \let\blx@done\relax
  \blx@listloop{#1}

  % tabular output for each item in list macro
  \def\do##1{\bbx@tab@label{##1} & \bbx@tab@item{##1} \\}
  \def\do##1{\bbx@tab@label{##1} & \bbx@tab@item{##1} \\}
  \csuse{blx@env@\blx@theenv}%
  \dolistloop{\blx@tempa}
  \csuse{blx@endenv@\blx@theenv}%
  \blx@bibnote\blx@thepostnote
  \endgroup}

\def\bbx@tab@label#1{%
  \begingroup
  \blx@getdata{#1}%
  \blx@setoptions@type\abx@field@entrytype
  \blx@setoptions@entry
  \blx@thelabelnumber
  \blx@addprefixnumber
  \addtocounter{instcount}\@ne
  \csuse{bbx@tabenv@\blx@theenv}\relax
  \endgroup}

\def\bbx@tab@item#1{%
  \begingroup
  \blx@getdata{#1}%
  \blx@setoptions@type\abx@field@entrytype
  \blx@setoptions@entry
  \csuse{blx@item@\blx@theenv}\relax
  \blx@initsep
  \blx@namesep
  \csuse{blx@hook@bibitem}%
  \blx@execute
  \blx@initunit
  \blx@anchor
  \blx@beglang
  \bibsentence
  \blx@pagetracker
  \blx@driver\abx@field@entrytype
  \blx@postpunct
  \blx@endlang
  \endgroup}

% user-level command for defining tabular bibliography format
\newrobustcmd*{\defbibtabular}[5]{%
  \long\csdef{blx@env@#1}{#2}%
  \long\csdef{blx@endenv@#1}{#3}%
  \long\csdef{bbx@tabenv@#1}{#4}%
  \long\csdef{blx@item@#1}{#5}}

% user-level access to some entry options
\def\useeditorfalse{\togglefalse{blx@useeditor}}
\def\usetranslatorfalse{\togglefalse{blx@usetranslator}}

\makeatother

% sortname labels (a robust style should add provision for missing labelnames)
\newbibmacro*{sortname}{%
  \renewcommand*{\multinamedelim}{\addslash\break}%
  \let\finalnamedelim\multinamedelim
  \printtext{\printnames[last-first]{labelname}}}

% bibitem hook to suppress redundant sortname list
\newbibmacro*{omitsortname}{%
  \ifnameundef{labelname}{}{%
    \ifnameundef{author}
      {\ifnameundef{editor}
         {\ifusetranslator{\clearname{translator}}{}}}
         {\clearname{editor}}
      {\clearname{author}}%
    \useeditorfalse%
    \usetranslatorfalse}}

% demo new tabular bibliography format
\defbibtabular{bibtabular}
 {\setlength{\tabcolsep}{8pt}\begin{tabular}{@{}P{5.5cm} >{\raggedright\arraybackslash}p{9cm}}}
 {\end{tabular}}
 {\usebibmacro{sortname}}
 {\usebibmacro{omitsortname}}

% add multiline labels in default bibliography format
\defbibenvironment{bibliography}
  {\list
     {\usebibmacro{sortname}}
     {\setlength{\labelwidth}{0.3\textwidth}%
      \setlength{\leftmargin}{\labelwidth}%
      \setlength{\labelsep}{\biblabelsep}%
      \addtolength{\leftmargin}{\labelsep}%
      \setlength{\itemsep}{\bibitemsep}%
      \setlength{\parsep}{\bibparsep}}%
     \renewcommand*{\makelabel}[1]{%
       \nobreak\strut\smash{\parbox[t]\labelwidth{\raggedright##1}}}}
  {\endlist}
  {\item\usebibmacro{omitsortname}}

\addbibresource{biblatex-examples.bib}

\renewcommand{\cmd}[1]{\texttt{\textbackslash #1}}

\begin{document}

\printbibtabular

\cite{vangennep:trans,companion,bertram}

\end{document}

Thank you for your help.

Jonas
  • 230
  • @Moewe Long time has passed. Any easy solution with current biblatex? Or maybe we already have a question like that on site? – Johannes_B Jan 29 '17 at 11:54
  • @Johannes_B Tabular bibliographies have always been a pain. To get them really right one would have to at least rewrite parts of the bibliography driver as well as the bibliography environment definition, and maybe even some internals (as was done here). Additionally, the style used here biblatex-swiss-legal-general is outdated and doesn't work with biblatex >= 3.3 any more. So I'm not too excited about investigating this further any time soon. – moewe Jan 29 '17 at 17:25
  • @moewe Alright. Since you mention it, any chance to get (limited) support for this style directly from biblatex? Alon with the standard styles? – Johannes_B Jan 29 '17 at 17:29
  • @Johannes_B Mhhh, as I see that would be a lot of work currently. As you can see in some of the questions about tabular bibliographies on this site. It does not seem to be that common a wish (and if it is wished fore that is probably caused by templates from MS Word), certainly so common that it would warrant being included into the biblatex core. Maybe I will have a look into the whole 'tabular bibliography' stuff once (if) I have time later this year. – moewe Jan 29 '17 at 17:37
  • @moewe Great to know somebody is (might be) looking into this. No hurry though. Probably, i personaly will never need it. And if, i can lend a helping hand ;-) – Johannes_B Jan 29 '17 at 17:52
  • @Johannes_B I can't promise anything though, but I will hopefully be able to take a look if I don't forget it. – moewe Jan 29 '17 at 18:16

0 Answers0