3

I am using biblatex and I created my own citation to display some data from a bibliography entry in the way that I need. So far it works fine. However, the command \printfield{<key>} returns formatted text.

Is there a way that I get the non-formatted text of the bibliography entry so I can format it as I want?

In the example below, my citation prints the volume, the number and the doi of a given bibliography entry. But for the two elements, I get different formats (the two bibliographic entries have the same data but different type). For example (see the attached image) one prints Volume: vol. 18 while the other print Volume: 18, or the \printfield{doi} command appends DOI at the beginning of the number.

enter image description here

Here is my MWE:

\begin{filecontents}{bibfile.bib}
@Article{s18041198,
AUTHOR = {Olatinwo, Segun O. and Joubert, Trudi-H.},
TITLE = {Optimizing the Energy and Throughput of a Water-Quality Monitoring System},
JOURNAL = {Sensors},
VOLUME = {18},
YEAR = {2018},
NUMBER = {4},
URL = {http://www.mdpi.com/1424-8220/18/4/1198},
ISSN = {1424-8220},
DOI = {10.3390/s18041198}
}
@inproceedings{s18041197,
AUTHOR = {Olatinwo, Segun O. and Joubert, Trudi-H.},
TITLE = {Optimizing the Energy and Throughput of a Water-Quality Monitoring System},
JOURNAL = {Sensors},
VOLUME = {18},
YEAR = {2018},
NUMBER = {4},
URL = {http://www.mdpi.com/1424-8220/18/4/1198},
ISSN = {1424-8220},
DOI = {10.3390/s18041198}
}
\end{filecontents}


\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{biblatex}

\addbibresource{bibfile.bib}

\DeclareCiteCommand{\mycyte}
{}{
    Volume: \printfield{volume} \\
    Number: \printfield{number} \\
    DOI: \printfield{doi}
}
{}
{}

\begin{document}

\begin{itemize}
    \item \mycyte{s18041198}
    \item \mycyte{s18041197}
\end{itemize}

\printbibliography

\end{document}
  • \thefield{...} – moewe Apr 13 '18 at 16:50
  • In general the number and volume of an @inproceedings mean something else than that of @article. While I would buy that volume is kind of similar, number really means something else entirely for the different types. – moewe Apr 13 '18 at 16:58
5

You can use \thefield{...} to access the raw data of a field. A similar command for name lists and literal lists does not exist.

You could use \printfield[noformat]{<field>} to print a field without additional formatting. But I think what you really want is

\DeclareFieldFormat{myvolume}{\bibcplstring{volume}\addcolon\space#1}
\DeclareFieldFormat{mynumber}{\bibcplstring{number}\addcolon\space#1}
\DeclareFieldFormat{mydoi}{DOI\addcolon\space\nolinkurl{#1}}
\DeclareCiteCommand{\mycyte}
  {}
  {\printfield[myvolume]{volume}%
   \setunit{\newline}%
   \printfield[mynumber]{number}%
   \setunit{\newline}%
   \printfield[mydoi]{doi}}
  {}
  {}

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.