4

Following along with the great article of How to get BibLaTeX-chicago use title case capitalization? I modified the source map to:

<sourcemap>
  <maps datatype="bibtex" map_overwrite="1">
  <map>
    <map_step map_field_source="TITLE"
              map_match="(^|\s)(\w+\S*w*)" map_replace="$1\u\L$2"/>
    <map_step map_field_source="TITLE"
              map_match="\-(\w+)" map_replace="\-\u\L$1"/>
    <map_step map_field_source="TITLE"
              map_match="(\s+|\-)(A(|n|nd|s|t)|werden|zur|f\{\\"\{u\}\}r|die|B(ut|y)|F(or|rom)|I(n|s)|O(f|n|r)|T(he|o)|With)\b"
              map_replace="$1\L$2"/>
    <map_step map_field_source="TITLE"
              map_match="([:;]\s+)([a-z])" map_replace="$1\u$2"/>
  </map>
  </maps>
</sourcemap>

in order to get a non English, i.e. German reference formatted correctly:

@misc{AdrianLobe2016,
author = {{A. Lobe}},
title = {{Social-Media-Daten werden zur Ampel f{\"{u}}r die Kreditw{\"{u}}rdigkeit}},
url = {http://mobil.derstandard.at/2000042297313/Social-Media-Daten-werden-zur-Ampel-fuer-die-Kreditwuerdigkeit},
urldate = {2016-08-05},
year = {2016}
}

As outlined by https://regex101.com/r/RwzhFT/1 the regex should match, but the connecting words are not lowercased and rendered as:

Social-Media-Daten Werden Zur Ampel Für Die Kreditwürdigkeit

Also, I want to apply the same preprocessing to the field JOURNAL, however it is not picked up.

edit

here a full sample:

\documentclass{article}
\usepackage[backend=biber]{biblatex}
\usepackage{filecontents}

\begin{filecontents*}{biber.conf}
<?xml version="1.0" encoding="UTF-8"?>
<config>
<sourcemap>
      <maps datatype="bibtex" map_overwrite="1">
      <map>
        <map_step map_field_source="TITLE"
                  map_match="(^|\s)(\w+\S*w*)" map_replace="$1\u\L$2"/>
        <map_step map_field_source="TITLE"
                  map_match="\-(\w+)" map_replace="\-\u\L$1"/>
        <map_step map_field_source="TITLE"
                  map_match="(\s+|\-)(A(|n|nd|s|t)|werden|zur|f\{\\"\{u\}\}r|die|B(ut|y)|F(or|rom)|I(n|s)|O(f|n|r)|T(he|o)|With)\b"
                  map_replace="$1\L$2"/>
        <map_step map_field_source="TITLE"
                  map_match="([:;]\s+)([a-z])" map_replace="$1\u$2"/>
      </map>
      </maps>
    </sourcemap>
</config>
\end{filecontents*}

\begin{filecontents*}{\jobname.bib}
@misc{AdrianLobe2016,
    author = {{A. Lobe}},
    title = {{Social-Media-Daten werden zur Ampel f{\"{u}}r die Kreditw{\"{u}}rdigkeit}},
    url = {http://mobil.derstandard.at/2000042297313/Social-Media-Daten-werden-zur-Ampel-fuer-die-Kreditwuerdigkeit},
    urldate = {2016-08-05},
    year = {2016}
    }
@BOOK{Smith2003,
  title = {This is an off-the-hook book title, but it doesn't have a subtitle},
  publisher = {Penguin},
  year = {2003},
  author = {Smith, James},
  address = {London}}
@ARTICLE{Doe1970,
  author = {H{\"a}user, {\O}rnulf},
  title = {{\O}rnulf H{\"a}user's letter to the editor: an $\alpha$-to-$\omega$
           summary of $\epsilon$--improvement},
  journal = {Great Journal},
  year = {1970},
  volume = {40},
  pages = {207-234}}
\end{filecontents*}
\addbibresource{\jobname.bib}

\begin{document}
\nocite{*}
\printbibliography
\end{document}
  • 2
    Please make your code snippets compilable. Add the code to your question, do not force people to visit other pages for code ... – Mensch Nov 14 '17 at 20:31
4

This is a partial answer, but perhaps useful.

I couldn't compile your code as is (errors with biber, did it actually run smoothly for you?), and I could identify the problem with your regex for "für".

Additionally, the regexes from Audrey's answer you mention have capitalized first letter and substitute it for lower case ones.

So, if you use (notice the capitalized first letters):

map_match="(\s+|\-)(A(|n|nd|s|t)|Werden|Zur|Die|B(ut|y)|F(or|rom)|I(n|s)|O(f|n|r)|T(he|o)|With)\b"

You get:

enter image description here

Which renders everything as expected, except for "Für". I couldn't figure out how to write a regex for that, which didn't give me a biber error.

But, if you are willing to use \usepackage[utf8]{inputenc} and für instead of f{\"{u}}r in your bibentry's title, then:

map_match="(\s+|\-)(A(|n|nd|s|t)|Werden|Zur|Für|Die|B(ut|y)|F(or|rom)|I(n|s)|O(f|n|r)|T(he|o)|With)\b"

gets the job done. But perhaps someone better with regex than myself can shed some further light with the "für" case.

For the journal case, you can duplicate the sourcemap entries, substituting "TITLE" for "JOURNAL".

Update: Here is a full MWE, assuming the [utf8]{inputenc} case:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[backend=biber]{biblatex}
\usepackage{filecontents}

\begin{filecontents*}{biber.conf}
<?xml version="1.0" encoding="UTF-8"?>
<config>
<sourcemap>
  <maps datatype="bibtex" map_overwrite="1">
  <map>
    <map_step map_field_source="TITLE"
              map_match="(^|\s)(\w+\S*w*)" map_replace="$1\u\L$2"/>
    <map_step map_field_source="TITLE"
              map_match="\-(\w+)" map_replace="\-\u\L$1"/>
    <map_step map_field_source="TITLE"
              map_match="(\s+|\-)(A(|n|nd|s|t)|Werden|Zur|Für|Die|B(ut|y)|F(or|rom)|I(n|s)|O(f|n|r)|T(he|o)|With)\b"
              map_replace="$1\L$2"/>
    <map_step map_field_source="TITLE"
              map_match="([:;]\s+)([a-z])" map_replace="$1\u$2"/>
    <map_step map_field_source="JOURNAL"
              map_match="(^|\s)(\w+\S*w*)" map_replace="$1\u\L$2"/>
    <map_step map_field_source="JOURNAL"
              map_match="\-(\w+)" map_replace="\-\u\L$1"/>
    <map_step map_field_source="JOURNAL"
              map_match="(\s+|\-)(A(|n|nd|s|t)|Werden|Zur|Für|Die|B(ut|y)|F(or|rom)|I(n|s)|O(f|n|r)|T(he|o)|With)\b"
              map_replace="$1\L$2"/>
    <map_step map_field_source="JOURNAL"
              map_match="([:;]\s+)([a-z])" map_replace="$1\u$2"/>
  </map>
  </maps>
</sourcemap>
</config>
\end{filecontents*}

\begin{filecontents*}{\jobname.bib}
@misc{AdrianLobe2016,
    author = {{A. Lobe}},
    title = {{Social-Media-Daten Werden Zur Ampel Für Die Kreditw{\"{u}}rdigkeit}},
    url = {http://mobil.derstandard.at/2000042297313/Social-Media-Daten-werden-zur-Ampel-fuer-die-Kreditwuerdigkeit},
    urldate = {2016-08-05},
    year = {2016}
    }
@BOOK{Smith2003,
  title = {This is an off-the-hook book title, but it doesn't have a subtitle},
  publisher = {Penguin},
  year = {2003},
  author = {Smith, James},
  address = {London}}
@ARTICLE{Doe1970,
  author = {H{\"a}user, {\O}rnulf},
  title = {{\O}rnulf H{\"a}user's letter to the editor: an $\alpha$-to-$\omega$
           summary of $\epsilon$--improvement},
  journal = {Great Die Journal},
  year = {1970},
  volume = {40},
  pages = {207-234}}
\end{filecontents*}
\addbibresource{\jobname.bib}

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

enter image description here

  • 1
    Please make your code snippets compilable ... – Mensch Nov 14 '17 at 22:00

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.