0

In my bibliography I have a custom field. I would like to redefine the \parencite{} command so that this field is also printed in the text (not in the bibliography though). In the following example I would like the result not to be

(Gossens, 1993)

but

(Gossens, 1993, Example)

I am aware that I could use some sort of post-cite command like \parencite[][Example]{} command; however I need to directly refer to the field in my bibliography with a new command, for instance: \parenciteNEW. It should be possible with \DeclareCiteCommand, but I have had no success to get it done by changing it's settings.

Do you have any ideas about how to achieve this?

\documentclass{minimal}

\usepackage[american]{babel}
\usepackage[utf8]{inputenc}
\usepackage{csquotes}
\usepackage[style=apa,
        bibencoding=utf8,
        sortcites=true,
        bibwarn=true,
        firstinits=true,
        isbn=false,
        dashed=false,
        maxbibnames=99,
        babel=other,
        backend=biber,
        hyperref=true]{biblatex}

\begin{filecontents}{myworks.bib}
@book{goossens93,
    author    = "Michel Goossens",
    title     = "The LaTeX Companion",
    year      = "1993",
    publisher = "Addison-Wesley",
    address   = "Reading, Massachusetts",
    custom    = "Example"
}

\end{filecontents}


\addbibresource{myworks.bib} 

\DeclareLanguageMapping{american}{american-apa}

\begin{document}

Here is an example\parencite{goossens93}.

\selectlanguage{american}
\printbibliography
\end{document}
2

You should map the custom field to a known field, e.g. usera. Then you can print it either with \printfield in the postnote argument, or use it it some cite command definition:

\documentclass{article}

\usepackage[american]{babel}
\usepackage[utf8]{inputenc}
\usepackage{csquotes}
\usepackage[style=apa,
        bibencoding=utf8,
        sortcites=true,
        bibwarn=true,
        firstinits=true,
        isbn=false,
        dashed=false,
        maxbibnames=99,
        babel=other,
        backend=biber,
        hyperref=true]{biblatex}

\begin{filecontents}{myworks.bib}
@book{goossens93,
    author    = "Michel Goossens",
    title     = "The LaTeX Companion",
    year      = "1993",
    publisher = "Addison-Wesley",
    address   = "Reading, Massachusetts",
    custom    = "Example"
}

\end{filecontents}

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \step[fieldsource=custom, fieldtarget=usera]
    }
  }
}

\addbibresource{myworks.bib}

\DeclareLanguageMapping{american}{american-apa}

 \DeclareCiteCommand{\parenciteNEW}[\mkbibparens]
 {\renewcommand{\finalnamedelim}{\ifnum\value{liststop}>2 \finalandcomma\fi\addspace\&\space}%
   \usebibmacro{cite:init}%
   \usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}%
   \setunit{\postnotedelim}%
   \printfield{usera}}
  {}
  {%
   \usebibmacro{postnote}%
   \usebibmacro{cite:post}}

\begin{document}

Here is an example \parencite[\printfield{usera}]{goossens93}.
And another
\parenciteNEW[postnote]{goossens93}

\printbibliography
\end{document}
  • 1
    Awesome, thank you for your solution. Mapping it to a known field is a great idea. – Mil Nov 2 '15 at 15:28
  • 1
    However, adapting it to multiple references (e.g., \parenciteNEW{goossens93,goossens97} won't work the same way because this is an edited postnote field, will it? – Mil Nov 2 '15 at 15:37
  • 1
    Did you try what happens with multiple references? – Ulrike Fischer Nov 2 '15 at 15:40
  • 1
    Yes, it does not print the ";" between the two entries. – Mil Nov 2 '15 at 15:46
  • 1
    Okay, got it, if you enter \multicitedelim between the last empty brackets, it will be fine. :) – Mil Nov 2 '15 at 15:48

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.