2

1st question for me so if there is sth wrong just say it. Using the code provided here --> Tabular Bibliogrpahy

How can I add the year on the left side of the tabular and cancel the URL and ISBN entrees for books on the right side without changing the .bib-data?

2 Answers2

1

This is a very under-explained question. I'm simply going to assume that you are doing something like preparing a list for a CV, because I cannot imagine any rational way of referring in citations to a bibliography organised in that weird way (an author/year scheme needs the author to be easily found, not the year!).

So let's assume you will use a simple "verbose" style to produce a list of works ordered by year, and we can modify from that.

Because your label is just a year, you really don't need the complex tabular environment, the technique of redefining labels in an ordinary list environment will work just fine. So, from the answer you cite we can just use the simple definition of a new enumeration. We can adapt the answer there, because we are only using years, so we can have quite narrow labels.

\documentclass{article}
\usepackage[style=verbose,date=year]{biblatex}

\defbibenvironment{bibliography}
  {\list
     {\usebibmacro{date}}
     {\setlength{\labelwidth}{0.1\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}

\addbibresource{biblatex-examples.bib}

\begin{document}

\nocite{*}

\newrefcontext[sorting=ynt]

\printbibliography

\end{document}

The main imperfection of this is that it leaves the date printed twice: once as the label, and once in the citation. It's possible to define a bibmacro to try to clear the excess dates but it doesn't work satisfactorily, in particular with entry sets, but also with some journals which use the date as part of the issue. I give it here for completeness:

\newbibmacro{omitdate}{%
    \clearfield{date}
    \clearfield{year}
    \clearfield{month}
    \clearfield{labelyear}}

This then gets used immediately after \item in the last argument to \defbibenvirobnment. To do this properly would require considerably more work.

For your other question, \AtEveryBibitem{\clearfield{isbn}\clearfield{url}} should do the trick.

Paul Stanley
  • 18,151
  • For the second question url=false, isbn=false should also work. But there are only a few fields for which there are those options, \clearfield is more general. – moewe Apr 05 '17 at 13:57
  • 1
    I also suspect that the OP does not want to create a CV, and wants to see Author and Year in the left column. But as you say, the question is very under explained, so your guess is as good as mine. – moewe Apr 05 '17 at 14:00
  • @moewe you may be right. If he wants the year as well, he needs the tabular approach. If he says that he does want that, someone else can have a go at adapting Audrey's code! – Paul Stanley Apr 05 '17 at 14:10
  • If the OP is still interested in this and gets back to us with a comment to that effect, someone might just have to do that. – moewe Apr 05 '17 at 14:16
  • I know that this is weird but the general layout which I have to use asks for an author & year on the left column...Usually they work with Word but word sucks... – Christoph Neubauer Apr 05 '17 at 14:20
  • 1
    @ChristophNeubauer Maybe you can update your question with the code you have tried so far (I suspect Audrey's code over at the linked answer), so we have the code directly here. Please also include a more detailed description (maybe a mock up) of what you want to achieve. – moewe Apr 05 '17 at 14:26
1

See Custom BibLaTeX bib with two blocks and authors below each other? for a solution to tabular bibliographies with fewer quirks.

This is a slightly updated version of Audrey's tabular bibliography code over at tabular bibliography with biblatex. It is adapted to produce 'author-year' like labels in the left column and the rest of the item on the right.

\documentclass{article}
\usepackage{csquotes}
\usepackage[american]{babel}
\usepackage[bibstyle=authortitle, citestyle=authoryear, sorting=nyt, labeldateparts]{biblatex}

\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@langstrings
  \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}%
  \csuse{blx@hook@bibinit@next}%
  % 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} \\[\bibitemsep]}
  \csuse{blx@env@\blx@theenv}%
  \dolistloop{\blx@tempa}
  \csuse{blx@endenv@\blx@theenv}%
  \blx@bibnote\blx@thepostnote
  \endgroup}


\def\bbx@tab@label#1{%
  \blx@ifdata{#1}
    {\begingroup
     \blx@getdata{#1}%
     \blx@bibcheck
     \iftoggle{blx@skipentry}{}{%
       \blx@setdefaultrefcontext{#1}%
       \global\let\blx@noitem\@empty
       \blx@setoptions@type\abx@field@entrytype
       \blx@setoptions@entry
       \blx@thelabelnumber
       \addtocounter{instcount}\@ne
       \csuse{bbx@tabenv@\blx@theenv}\relax}
     \endgroup}
    {}}

\def\bbx@tab@item#1{%
  \blx@ifdata{#1}
    {\begingroup
     \blx@getdata{#1}%
     \blx@bibcheck
     \iftoggle{blx@skipentry}{}{%
       \blx@setdefaultrefcontext{#1}%
       \global\let\blx@noitem\@empty
       \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@beglangbib
       \bibsentence
       \blx@pagetracker
       \blx@driver\abx@field@entrytype
       \blx@postpunct
       \blx@endlangbib}%
     \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}}
\makeatother

\newbibmacro*{date+extrayear}{%
  \iffieldundef{labelyear}
    {}
    {\printtext[parens]{%
       \printfield{issue}%
       \setunit*{\addspace}%
       \iffieldsequal{year}{labelyear}
         {\printlabeldateextra}%
         {\printfield{labelyear}%
          \printfield{extrayear}}}}}%
\renewbibmacro*{date}{}%
\renewbibmacro*{issue+date}{}

\makeatletter
\newbibmacro{biblabel}{%
  \begingroup
  \DeclareFieldFormat{bibhyperref}{##1}%
  \csuse{blx@hook@cite}%
  \csuse{blx@hook@citekey}%
  \citetrackerfalse\pagetrackerfalse\backtrackerfalse
  \defcounter{maxnames}{\blx@maxcitenames}%
  \usebibmacro{cite}%
  \endgroup
}
\makeatother

%bibitem hook to suppress redundant sortname list
\newbibmacro*{omitlabelname}{%
  \iffieldundef{labelnamesource}
    {}
    {\clearname{\thefield{labelnamesource}}}}

% demo new tabular bibliography format
\defbibtabular{bibtabular}
  {\tabular{p{0.3\textwidth}p{0.7\textwidth}}}
  {\endtabular}
  {\usebibmacro{biblabel}}
  {\usebibmacro{omitlabelname}}

% add multiline labels in default bibliography format
\defbibenvironment{bibliography}
  {\list
     {\usebibmacro{biblabel}}
     {\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{omitlabelname}}

\setlength{\bibitemsep}{\itemsep}

\addbibresource{biblatex-examples.bib}
\newcommand{\cmd}[1]{\texttt{\textbackslash #1}}
\begin{document}
\cite{vangennep:trans,companion,bertram,worman,sigfridsson,geer,knuth:ct:a,knuth:ct:b,knuth:ct:c}
\printbibliography[title={\cmd{printbibliography} with multiline labels}]
\printbibtabular[title={New \cmd{printbibtabular} command}]
\end{document}
moewe
  • 175,683
  • Thanks for the help. Funny thing if the authors name and year is longer the one line it overlaps with the next item? Do you know how to fix it? – Christoph Neubauer Apr 16 '17 at 14:13
  • @ChristophNeubauer That is a known problem of the new \printbibliography, as explained in the other answer. If you use \printbibtabular it should work. – moewe Apr 18 '17 at 12:31
  • Using your code with \printbibtabular, gives me an authoryear left colomn which doesn't start in the same line as the title on the right. Also having a long name on the left will note give a 2nd line for the same item... – Christoph Neubauer Apr 19 '17 at 15:53
  • @ChristophNeubauer Both things work for me in the MWE. If I use \printbibtabular both columns start on the same height and the left column can also cause line breaks. – moewe Apr 19 '17 at 16:00
  • Unfortunatly the <\printbibtabular[]> doesn't create a new page even the list goes on and on <\printbibtabular[type=book,title={Bücherverzeichnis}] \printbibtabular[type=article,title={Artikelverzeichnis}] \printbibtabular[type=misc, title={Internetdokumentenverzeichnis}] [\code]> it will only create a new page after every kind of bib but just 1 page for one typ of. and using <\printbibliography> effects a longer text in the right colomn then the pagelyout. And using <\usepackage[pdftex]{hyperref}> creates a bibl where author+year is 1 line above the title...anyone know why? – Christoph Neubauer Apr 30 '17 at 15:26
  • @ChristophNeubauer That is a known limitation of the table environment in TeX, sorry. One might be able to work around that with environment that are breakable across pages. – moewe May 02 '17 at 08:09