9

My Bibliography is subdivided into 2 parts (published / online references). I would like to get an automatic localization of the 2 subheadings, which is controled by the setting of the babel package.

Example with \usepackage[english]{babel}:

Bibliography
List of Published References
Author, A. (2013) - This is the Title.
Author, B. (2013) - This is the second Title.

List of Online References
Author, A. (2013) - URL http://www.test.com

Example with \usepackage[ngerman]{babel}:

Quellenverzeichnis
Literaturverzeichnis
Author, A. (2013) - This is the Title.
Author, B. (2013) - This is the second Title.

Liste der Internetquellen
Author, A. (2013) - URL http://www.test.com


My commands to setup the bibliography look like this:

\printbibheading[title={\bibname}]
\printbibliography[heading=subbibliography,title={\pubname},nottype=online]
\printbibliography[heading=subbibliography,title={\unpubname},type=online]

The commands \pubname and \unpubname are not defined right now. I don't know how to.

I thought it would be best to work with new bibliography strings, since the localization of \bibname works this way. Therefore I introduced the 2 bibliography strings publishedSources and unpublishedSources and defined them afterwards for the different languages. Unfortunately I have no clue about getting those values into the title key of \printbibliography:

\NewBibliographyString{publishedSources,unpublishedSources}
\DefineBibliographyStrings{english}{%
    publishedSources   = {List of Published References},
    unpublishedSources = {List of Online References},
}
\DefineBibliographyStrings{ngerman}{%
    bibliography       = {Quellenverzeichnis},
    publishedSources   = {Literaturverzeichnis},
    unpublishedSources = {Liste der Internetquellen},
}
  • Does \printbibliography[heading=subbibliography,title=\bibstring{publishedSources},nottype=online] work for you? – moewe Sep 3 '13 at 11:35
  • @moewe This looked so promissing. Unfortunately I get an Undefined control sequence error for \bibstring. It seems like you could only use this command wihtin certain environments. Even if I put \bibstring{bibliography} in the middle of my document, I will get the error and latex prints the term in curly braces (bibliography), but won't get the value of the bibliography string. – FrogThomas Sep 3 '13 at 12:32
  • Yes, I really thought that was the solution, but - as you say - the \bibstring macro seems to work only within certain BibLaTex environments and macros. – moewe Sep 3 '13 at 12:54
  • @FrogThomas Does my answer solve your problem? – karlkoeller Sep 4 '13 at 18:58
  • @karlkoeller Sorry for my delay. I was short on time. Yes, your answer solved my problem. Nevertheless I am shocked of the fact, that a hack seems to be the only possible way. Maybe this is an interesting request for future biblatex features. I actually need this for a documentclass which I am building. It is supposed to support multiple languages. I do not think this is all that uncommon. – FrogThomas Sep 4 '13 at 23:13
4

Well, I found a way, but it needs to hack some biblatex internal code.

Keep your definitions:

\NewBibliographyString{publishedSources,unpublishedSources}
\DefineBibliographyStrings{english}{%
    publishedSources   = {List of Published References},
    unpublishedSources = {List of Online References},
}
\DefineBibliographyStrings{ngerman}{%
    bibliography       = {Quellenverzeichnis},
    publishedSources   = {Literaturverzeichnis},
    unpublishedSources = {Liste der Internetquellen},
}

and then add in your preamble

\makeatletter
\def\blx@defbibstrings#1#2{%
  \def\do##1{\csundef{abx@lstr@##1}\csundef{abx@sstr@##1}}%
  \abx@dostrings
  \csuse{abx@strings@#1}%
  \setkeys{blx@lbx}{#2}%
  \let\do\blx@defbibstrings@i
  \csxdef{abx@strings@#1}{\abx@dostrings}%
  \csgappto{abx@strings@#1}{%
    \ifcsdef{\abx@str @bibliography}
      {\letcs\bibname{\abx@str @bibliography}}
      {\let\bibname\@empty}%
    \ifcsdef{\abx@str @references}
      {\letcs\refname{\abx@str @references}}
      {\let\refname\@empty}%
    \ifcsdef{\abx@str @shorthands}
      {\letcs\losname{\abx@str @shorthands}}
      {\let\losname\@empty}
    \ifcsdef{\abx@str @publishedSources}
      {\letcs\pubname{\abx@str @publishedSources}}
      {\let\pubname\@empty}
    \ifcsdef{\abx@str @unpublishedSources}
      {\letcs\unpubname{\abx@str @unpublishedSources}}
      {\let\unpubname\@empty}
    }
  }
\makeatother

Thus the MWE

\documentclass{report}
\usepackage[T1]{fontenc}
\usepackage{csquotes}
\usepackage[style=authortitle,backend=biber]{biblatex}
\usepackage[ngerman]{babel}
\usepackage{hyperref}
\addbibresource{biblatex-examples.bib}

\NewBibliographyString{publishedSources,unpublishedSources}
\DefineBibliographyStrings{english}{%
    publishedSources   = {List of Published References},
    unpublishedSources = {List of Online References},
}
\DefineBibliographyStrings{ngerman}{%
    bibliography       = {Quellenverzeichnis},
    publishedSources   = {Literaturverzeichnis},
    unpublishedSources = {Liste der Internetquellen},
}

\makeatletter
\def\blx@defbibstrings#1#2{%
  \def\do##1{\csundef{abx@lstr@##1}\csundef{abx@sstr@##1}}%
  \abx@dostrings
  \csuse{abx@strings@#1}%
  \setkeys{blx@lbx}{#2}%
  \let\do\blx@defbibstrings@i
  \csxdef{abx@strings@#1}{\abx@dostrings}%
  \csgappto{abx@strings@#1}{%
    \ifcsdef{\abx@str @bibliography}
      {\letcs\bibname{\abx@str @bibliography}}
      {\let\bibname\@empty}%
    \ifcsdef{\abx@str @references}
      {\letcs\refname{\abx@str @references}}
      {\let\refname\@empty}%
    \ifcsdef{\abx@str @shorthands}
      {\letcs\losname{\abx@str @shorthands}}
      {\let\losname\@empty}
    \ifcsdef{\abx@str @publishedSources}
      {\letcs\pubname{\abx@str @publishedSources}}
      {\let\pubname\@empty}
    \ifcsdef{\abx@str @unpublishedSources}
      {\letcs\unpubname{\abx@str @unpublishedSources}}
      {\let\unpubname\@empty}
    }
  }
\makeatother

\begin{document}

\cite{itzhaki}\cite{wassenberg}\cite{aksin}\cite{angenendt}

\printbibheading[title={\bibname}]
\printbibliography[heading=subbibliography,title={\pubname},nottype=online]
\printbibliography[heading=subbibliography,title={\unpubname},type=online]

\end{document}

yields

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.