7

I use an alphabetic citestyle with biblatex. Sometimes I have entries where no author or editor or year is given. For example there is often no editor for a proceeding. At the moment I leave the entry for editor empty, but I would like to change this behavior so that biblatex automatically prints ‘s.ed.’ (lat. sine editore) in the bibliography if the field is empty.

When I just write this into the editor field I get s.ed. (Ed.). So I need to prevent the output of (Ed.), but I have no idea where to implement this.

In the same way the following entries should be printed (see link in german) when the field is usually required for the type of entry:

  • ‘s.a.’ (lat. sine auctore "without author")
  • ‘s.ed.’ (lat. sine editore "without editor")
  • ‘s.a.’ (lat. sine anno "without year")
  • ‘s.t.’ (lat. sine titulo "without title")
  • ‘s.l.’ (lat. sine loco "without location")
  • ‘s.ed.’ (lat. sine editore "without publisher")

At the moment I have no idea how to handle a missing author or year for the citations within the text, because sth. like [ABCs.a.] doesn't look good. Therefore, suggestions are welcome ;)

MWE:

The MWE illustrates the different cases of missing entries. I always wrote the abbreviation into the field (except for the second entry) by hand to illustrate what the output should look like. The output is correct except for the case where no editor is given, because the output is s.ed., ed. but it should be s.ed.. That is the first point where I need help to fix it.

If I want to change the abbreviation from latin to english later it would be a complicated task. So this is the second point where I need help with a solution for the following problem:

What I would like to achieve is to tell biblatex that I don't have a value for a specific field and I want to print the appropriate abbreviation to state to the reader that no information is available for that field (maybe a command like \noauthor). If I just leave the field empty it should be interpreted as ignoring the field like biblatex already do for the second entry noAuthor2 WARN - The field 'author' in entry 'noAuthor2' cannot be null, deleting it.

\documentclass{article}
\usepackage[backend=biber,style=alphabetic, autocite=footnote]{biblatex}


\begin{filecontents*}{bibliography.bib}
% Example for no author
@BOOK{noAuthor,
  author = {s.a.},
  title = {Rocket Propulsion and Spaceflight Dynamics},
  year = {1979},
    location = {New York},
  publisher = {Pitman},
}
% Example for no author and field left empty
@BOOK{noAuthor2,
  author = {},
  title = {Rocket Propulsion and Spaceflight Dynamics},
  year = {1979},
    location = {New York},
  publisher = {Pitman},
}
% Example for no editor
@Collection{noEditor,
    editor                  = {s.ed.},
    title                       = {Book of light}, 
    year                        = {1985},
    publisher               = {Springer Science+Business Media, LLC},
    location                = {New York}
}
% Example for an incollection where the collection has no editor
@Incollection{noEditor,
    crossref                = {noEditor},
    author                  = {Wayne, John},
    title                   = {Some nice title},
    pages                   = {10--20},
    bookpagination          = {page},
}
% Example for no year
@BOOK{noYear,
  author = {Cornelisse, J. W. and Schoeyer, H. Ferry R. and Wakker, Karel F.},
  title = {Rocket Propulsion and Spaceflight Dynamics},
  year = {s.a.},
    location = {New York},
  publisher = {Pitman},
}
% Example for no title
@BOOK{noTitle,
  author = {Cornelisse, J. W. and Schoeyer, H. Ferry R. and Wakker, Karel F.},
  title = {s.t.},
  year = {1979},
    location = {New York},
  publisher = {Pitman},
}
% Example for no location
@BOOK{noLocation,
  author = {Cornelisse, J. W. and Schoeyer, H. Ferry R. and Wakker, Karel F.},
  title = {Rocket Propulsion and Spaceflight Dynamics},
  year = {1979},
    location = {s.l.},
  publisher = {Pitman},
}
% Example for no publisher
@BOOK{noPublisher,
  author = {Cornelisse, J. W. and Schoeyer, H. Ferry R. and Wakker, Karel F.},
  title = {Rocket Propulsion and Spaceflight Dynamics},
  year = {1979},
    location = {New York},
  publisher = {s.ed.},
}
\end{filecontents*}


\addbibresource{bibliography.bib}
\nocite{*} 

\begin{document}
\null
\vfill

\printbibliography
\end{document}
user2653422
  • 2,333
  • sound like a case for the \AtEveryBibitem directive... Just don't know how exactly right now. – Benedikt Bauer Nov 25 '14 at 20:24
  • @BenediktBauer I found this question which is related. But I still have the problem that not every entry has e.g. an editor field and the mentioned problem with the citation within the text. – user2653422 Nov 26 '14 at 14:48
  • Could you please add some minimal working example (MWE) which contains also bibentries with the required properties (i.e. a proceeding without editor, an article without author and so on)? This would ease playing a round with the problem a lot. – Benedikt Bauer Nov 26 '14 at 15:22
  • @BenediktBauer Sorry I didn't have time to create the MWE earlier. I hope with the given MWE it is clear now what I would like to achieve. – user2653422 Nov 30 '14 at 11:25

1 Answers1

6

This is a beginning. It is not a full solution but is too long for a comment. It does not solve the editor issue completely although it does work for entries similar to those in the question's MWE.

Basically, the idea is to create a series of bibliography strings in your biblatex.cfg (which you may have to create if you've never used it before - mine is under tex/latex/config/ in my TEXMFHOME). You then specify the value of these strings for each language you need and create some macros to produce the strings. The macros will produce whichever string is appropriate for the active language. In your .bib file, you use the new macros e.g. \noauthor. When processed, these are replaced with the specified strings for the relevant language e.g. s.a. for english or whatever.

If later you decide you want different strings for a given language, you can edit the strings in biblatex.cfg i.e. one edit is required per string you wish to redefine. If you need to use a new language, you can add an additional set of strings for the appropriate language without overwriting the existing ones.

\documentclass[english]{article}
\usepackage{filecontents}
\begin{filecontents}{biblatex.cfg}
  \NewBibliographyString{noauthor}
  \NewBibliographyString{noeditor}
  \NewBibliographyString{nodate}
  \NewBibliographyString{notitle}
  \NewBibliographyString{nolocation}
  \NewBibliographyString{nopublisher}
  \DefineBibliographyStrings{english}{%
    noauthor      =   {s\adddot a\adddot},
    noeditor      =   {s\adddot ed\adddot},
    nodate        =   {s\adddot a\adddot},
    notitle       =   {s\adddot t\adddot},
    nolocation    =   {s\adddot l\adddot},
    nopublisher   =   {s\adddot ed\adddot},
  }
  \newcommand*\nosomethings{noauthor,noeditor,nodate,notitle,nolocation,nopublisher}
  \@for \xx:=\nosomethings \do {%
    \expandafter\ifcsname\xx\endcsname\relax\else
    \expandafter\expandafter\expandafter\expandafter\edef\csname\xx\endcsname{\noexpand\bibstring{\xx}}%
    \fi}
\end{filecontents}

\usepackage[backend=biber, style=alphabetic, autocite=footnote]{biblatex}

\begin{filecontents}{bibliography.bib}
  % Example for no author
  @BOOK{noAuthor,
    author = {\noauthor},
    title = {Rocket Propulsion and Spaceflight Dynamics},
    year = {1979},
    location = {New York},
    publisher = {Pitman},
  }
  % Example for no author and field left empty
  @BOOK{noAuthor2,
    author = {},
    title = {Rocket Propulsion and Spaceflight Dynamics},
    year = {1979},
    location = {New York},
    publisher = {Pitman},
  }
  % Example for no editor
  @Collection{noEditor,
    editor                  = {\noeditor},
    title                       = {Book of light},
    year                        = {1985},
    publisher               = {Springer Science+Business Media, LLC},
    location                = {New York}
  }
  @Collection{noEditor2,
    editor                  = {\noeditor},
    title                       = {Book of Darkness},
    year                        = {1945},
    publisher               = {Oxford University Press},
    location                = {Oxford},
    isbn = {01234556789X}
  }
  @Collection{noEditor3,
    editor                  = {\noeditor},
    title                       = {Book of Greyness},
    year                        = {1045},
    publisher               = {Cambridge University Press},
    location                = {Cambridge},
    isbn = {01234879890789X}
  }
  @Collection{Editor,
    editor                  = {Ditor, E.},
    title                       = {Book of light},
    year                        = {1985},
    publisher               = {Springer Science+Business Media, LLC},
    location                = {New York}
  }
  % Example for no year
  @BOOK{noYear,
    author = {Cornelisse, J. W. and Schoeyer, H. Ferry R. and Wakker, Karel F.},
    title = {Rocket Propulsion and Spaceflight Dynamics},
    year = {\nodate},
    location = {New York},
    publisher = {Pitman},
  }
  % Example for no title
  @BOOK{noTitle,
    author = {Cornelisse, J. W. and Schoeyer, H. Ferry R. and Wakker, Karel F.},
    title = {\notitle},
    year = {1979},
    location = {New York},
    publisher = {Pitman},
  }
  % Example for no location
  @BOOK{noLocation,
    author = {Cornelisse, J. W. and Schoeyer, H. Ferry R. and Wakker, Karel F.},
    title = {Rocket Propulsion and Spaceflight Dynamics},
    year = {1979},
    location = {\nolocation},
    publisher = {Pitman},
  }
  % Example for no publisher
  @BOOK{noPublisher,
    author = {Cornelisse, J. W. and Schoeyer, H. Ferry R. and Wakker, Karel F.},
    title = {Rocket Propulsion and Spaceflight Dynamics},
    year = {1979},
    location = {New York},
    publisher = {\nopublisher},
  }
\end{filecontents}

\addbibresource{bibliography.bib}

\newif\ifuseeditorstg
\useeditorstgfalse
\useeditorstgtrue

\renewbibmacro*{editor}{%
  \ifboolexpr{
    test \ifuseeditor
    and
    not test {\ifnameundef{editor}}
  }
  {\printnames{editor}%
    \setunit{\addcomma\space}%
    \mystringtestnamehash\ifuseeditorstg\usebibmacro{editorstrg}\fi%
    \clearname{editor}}
  {}}

\renewbibmacro*{editor+others}{%
  \ifboolexpr{
    test \ifuseeditor
    and
    not test {\ifnameundef{editor}}
  }
  {\printnames{editor}%
    \setunit{\addcomma\space}%
    \mystringtestnamehash\ifuseeditorstg\usebibmacro{editorstrg}\fi%
    \clearname{editor}}
  {}}


% based on Andrew Swann's answer at http://tex.stackexchange.com/a/169379
\edef\noeditornamehash{\detokenize{a811c44f19354a66e35057fa5cdb5ad2}}
\newcommand*\mystringtestnamehash{%
  \edef\tempa{\strfield{namehash}}%
  \ifx\noeditornamehash\tempa\useeditorstgfalse\else\useeditorstgtrue\fi}

\begin{document}
  \nocite{*}
  \printbibliography
\end{document}

missing information

cfr
  • 198,882
  • Really nice thank you :). I think the problem with entries which have an editor could be solved by redefining the appropriate BibliographyDriver with a test for the existence of the new command noeditor which will prevent the output of ed. or eds.. Or like in this post with the command \AtEveryBibitem which should be easier. The problem is that I don't know how to test for the fact that the command noeditor is within the editor field or not. – user2653422 Dec 01 '14 at 10:24
  • @user2653422 Those answers don't help, I don't think, because the problem is not changing the content of the field itself but changing something in the driver layout when, and only when, the field has a certain value. And it would be better not to change it at the driver level if possible, because you'd need to repeat it for all affected drivers. – cfr Dec 01 '14 at 22:13
  • I read the thread I linked again and agree that the question asked there and the solution provided is different from the problem here. I also agree with you that changing the driver level could be difficult. However, what options to achieve the desired output are left? It must be something at the driver level, because there the additional string for the editor/editors is added, isn't it? – user2653422 Dec 01 '14 at 23:11
  • @user2653422 I can figure out how to switch the (ed.) bit on and off globally using a conditional i.e. if I write \useeditorstgfalse, I don't get the addition, and if I write \useeditortrue, I do get the addition. But I cannot figure out how to compare the value of the field with the \noeditor so as to ever get a boolean set to true. No matter what I try, the test is always false. Probably because I don't really understand what I'm doing :(. If you can figure out how to do the comparison, you can use \AtEveryBibItem to toggle the conditional, and use that conditional... – cfr Dec 01 '14 at 23:56
  • to patch or redefine relevant bibmacros. These are used in drivers but are building blocks for drivers rather than being drivers themselves. – cfr Dec 01 '14 at 23:57
  • @user2653422 Do you need it to work for cases where an author is used as well as an editor? I have a solution which works for your MWE but not for an @incollection type with missing editor. – cfr Dec 03 '14 at 01:33
  • @user2653422 Please see update. Note that this is *not* a robust or complete solution for the editor issue, even though it works for your MWE and for the expanded MWE I used in the edited answer (adds 2 more cases of noEditor to .bib file). It will definitely fail if you have @incollection entries with an author but no editor. I don't know if that is an issue. If it is, it should be possible to do something similar although I'm not sure this is a very robust or efficient approach! – cfr Dec 03 '14 at 01:50
  • http://tex.stackexchange.com/questions/127698/change-editor-expression – cfr Dec 03 '14 at 03:34
  • Thank you very much for the update and the effort. Unfortunately, I have many incollections and inproceedings which are linked by the crossref field with the original collection or proceeding. I will try to find sth. for that problem with the help of your solution and will post any progress here. I accept your answer by now, but if you has another idea it would be great if you share it with us :). – user2653422 Dec 03 '14 at 13:24
  • @user2653422 Could you add some examples to your MWE and ping me? – cfr Dec 03 '14 at 18:39
  • @user2653422 Actually, I think you just need somebody who understands how to manipulate strings in TeX. Unfortunately, that is not me :(. Fortunately, there are bunches of people on the site who fit the bill ;). (Actually, I'm not sure that is all that is needed. But I'm sure that my not understanding that stuff makes it difficult for me to decide whether it is all or not!] – cfr Dec 04 '14 at 02:11
  • Sorry hadn't time earlier. I added an example for an incollection to my initial MWE which has an author but the parent collection has no editor. Though, I need to evaluate what will be the outcome of this example with your modifications which I will try tomorrow. – user2653422 Dec 09 '14 at 00:01
  • @user2653422 There must be a better way to do this... Even if I could make it work, my approach is completely crazy. (And I can't make it work... I can't figure out how to test a relevant string when the editor does not correspond to the label name...) – cfr Dec 09 '14 at 00:06