# I am trying to substitute a field (Title) by another custom field (Titlept - title in portuguese) if it exists. Any suggestions?

I've tried to edit a bibmacro copied from standard.bbx. But it does not work. Another solution would be to copy the contents of Titlept into Title, but the Biblatex documentation seem clumsy to me in this respect.

Here is my attempt:

    \renewbibmacro{maintitle+title}{%
\iffieldundef{titlept}{ % if titlept is undefined
\iffieldsequal{maintitle}{title}
{\clearfield{maintitle}%
\clearfield{mainsubtitle}%
{\iffieldundef{maintitle}
{}
{\usebibmacro{maintitle}%
\newunit\newblock
\iffieldundef{volume}
{}
{\printfield{volume}%
\printfield{part}%
{\printfield{titlept}}%
\usebibmacro{title}%
\newunit}

• You can't use titlept as a name of a field. You have to use the fields that are defined by biblatex. You might use usera for example. Otherwise biblatex is not able to recognize your input fields. Other possibilities can be found in section 2.2.4 of the manual. – Thorsten Jan 10 '12 at 13:17

This is easy with biber+biblatex which allows you to re-map the data source as it is read, without changing the source itself. Put this in your biber.conf (see section 3.1.1 of the Biber manual for more details and examples):

<?xml version="1.0" encoding="UTF-8"?>
<config>
<sourcemap>
<maps datatype="bibtex" bmap_overwrite="1">
<map>
<map_step map_field_source="TITLEPT" map_field_target="TITLE"/>
</map>
</maps>
</sourcemap>
</config>


This will overwrite the TITLE field if it also exists. To only rename the field if the TITLE field does not exist, use bmap_overwrite="0" instead.

• Great! I wasn't aware of this. But what if someone wanted to use title and titlept? Looking at the example the OP gives, it seems as if he wants to use both of them? – Thorsten Jan 10 '12 at 13:57
• Ah, I see. Yes, well you could then just map TITLEPT->USERA and then you would have to have some support in the style for the USERA field. In the future, the biblatex data model will be user-definable so you will be able to use any name for fields that you wish. The biber mapping functionality allows you to map into the current static biblatex model (and you can do a lot of other things with this mapping functionality - see the biber docs) – PLK Jan 10 '12 at 14:03
• Exactly Thorsten. I have a catalog of my professional milestones in bibtex and I am producing a CV that takes certain keywords of the bibtex entries and flushes them into CV sections. But I want to produce both english and portuguese versions (In Brazil, it sounds excessively posh to send CV's in english). See the actual work in naveda.info/curriculum – Luiz Naveda Jan 11 '12 at 15:49
• In this case, if you are using biber, this question shows you how to use the currently experimental BibLaTeXML format for such things. – PLK Jan 11 '12 at 17:58
• Thanks for the suggestions. But it seems that the biber triggers sa conflict with one of the tricky things I am doing to have this CV working. So I went for the solution using user[a-d]. – Luiz Naveda Jan 12 '12 at 1:06

The problem here is that you can't use titlept as a custom field name. You have to use the fields that are defined by biblatex. You might use usera for example. Otherwise biblatex is not able to recognize your input fields.

Example:

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

\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@book {foo,
author = {Foo, Francis},
usera = {My custom title},
year = {2011},
location = {Footown},
}

@book {bar,
author = {Bar, Bernie},
title = {Barstory},
year = {2000},
location = {Barcity},
}
\end{filecontents}

\renewbibmacro{maintitle+title}{%
\iffieldundef{usera}{ % if usera is undefined
\iffieldsequal{maintitle}{title}
{\clearfield{maintitle}%
\clearfield{mainsubtitle}%
{\iffieldundef{maintitle}
{}
{\usebibmacro{maintitle}%
\newunit\newblock
\iffieldundef{volume}
{}
{\printfield{volume}%
\printfield{part}%
{\printfield{usera}\newunit\newblock}%
\usebibmacro{title}%
\newunit}

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


For more information about custom fields in biblatex you should read section 2.2.4 of the manual.

Currently these custom fields are supported:

• name[a–c] list (name)
Custom lists for special bibliography styles. Not used by the standard bibliography styles.
• name[a–c]type field (key)
Similar to authortype and editortype but referring to the fields name[a-c]. Not used by the standard bibliography styles.
• list[a–f] list (literal)
Custom lists for special bibliography styles. Not used by the standard bibliography styles.
• user[a–f] field (literal)
Custom lists for special bibliography styles. Not used by the standard bibliography styles.
• verb[a–c] field (literal) Similar to the custom fields above except that these are verbatim fields. Not used by the standard bibliography styles.

I had to renew some macros using the custom fields suggested by Thorsten and it worked like a charm. I ended up in something like the code below. Later on I will publish the complete documented work and I let you know. I had to take user[a] to [d] that substituted Title, Series, Notes and Address fields.

\renewbibmacro{maintitle+title}{%
\iffieldundef{usera}{ % if the translation is not available...
\iffieldsequal{maintitle}{title} % it prints the title macro,
{\clearfield{maintitle}%
\clearfield{mainsubtitle}%
{\iffieldundef{maintitle}
{}
{\usebibmacro{maintitle}%
\newunit\newblock
\iffieldundef{volume}
{}
{\printfield{volume}%
\printfield{part}%
\usebibmacro{title}
}
{\printfield{usera}}% Otherwise, it prints the translation.
\newunit}


and

  \newbibmacro{series+number}{%
\iffieldundef{userb}{
\printfield{series}%