0

I need to know if a .bib file has fields such as PUBLISHER, DOI, URL, JOURNAL or are empty, this in order to create another new command where I can put conditionals and be able to automatically generate image citations according to APA. So far I have been able to know if the DOI, Journal and URL fields exist or are empty, but I HAVE NOT BEEN ABLE TO DETERMINE IF THE PUBLISHER FIELD EXISTS WITHOUT THE UNDEFINED ERROR APPEARING (if it is empty ) AT the time of running it in OVERLEAF.

NOTE, I have tried the same thing to do with the create command to know if it is a file using the \ifentrytype conditional to know if it is an article or book, but without any result.

\documentclass{article}
\usepackage{etoolbox} % para \ifstrequal
\usepackage{xstring}
\usepackage[T1]{fontenc}
\usepackage[spanish,es-tabla]{babel}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{csquotes}
\usepackage[backend=biber,style=apa,
maxbibnames=3,minbibnames=1]{biblatex}
\usepackage{ifthen}
\usepackage{pdftexcmds}

% MI JOURNAL \DeclareCiteCommand{\citejournal} {\usebibmacro{prenote}} {\usebibmacro{citeindex}% \usebibmacro{journal}} {\multicitedelim} {\usebibmacro{postnote}}

% MI URL \DeclareCiteCommand{\miurl} {\usebibmacro{prenote}} {\usebibmacro{citeindex}% \usebibmacro{url}} {\multicitedelim} {\usebibmacro{postnote}}

%PUBLISHER \newcommand{\mipublisher}[1]{% \entrydata{#1}{% \iffieldundef{publisher}{% % Si el campo 'publisher' no está definido No hay publisher }{% % Si el campo 'publisher' está definido Hay publisher: \citelist{#1}{publisher} % Imprime el valor de publisher }% }% } % DOI \DeclareCiteCommand{\midoi} {\boolfalse{citetracker}% \boolfalse{pagetracker}% \usebibmacro{prenote}} {\ifciteindex {\indexfield{indexdoi}}{} \iffieldundef{doi}{nd}{\printfield{doi}}}{\multicitedelim} {\usebibmacro{postnote}}

%DETERMINE IF IT IS AN ARTICLE OR A BOOK % Comando para verificar si una entrada es un artículo \DeclareCiteCommand{\citetypetest} {\usebibmacro{prenote}} {\usebibmacro{citeindex}% \usebibmacro{entrytype}} % Modifica aquí para usar 'entrytype' {\multicitedelim} {\usebibmacro{postnote}}

% \DefineBibliographyStrings{spanish}{ andothers = {et\addabbrvspace al\adddot}, andmore = {et\addabbrvspace al\adddot}}

\addbibresource{bibliografia.bib} % \begin{document}

  1. Doi-\midoi{Gonzales2010} \par
  2. Publisher- \mipublisher{Gonzales2010} \par %
  3. URL-\miurl{Gonzales2010} \par
  4. Journal-\citejournal{Gonzales2010} \par %
  5. mira esto: my \citelist{Garcia2022}{publisher} \par
  6. \ifentrytype{article}{Es un artículo}{No es un artículo}
  7. \mipublisher{Gonzales2010}

\end{document}

Javier Bezos
  • 10,003

1 Answers1

2

As Ulrike Fischer points out in the comments, publisher is a list, that's why you need to check if it is present with \iflistundef{publisher} and print it with \printlist{publisher}.

It is not entirely clear to me what exactly you are doing, but if you need a command that prints a special citation format for you, you should absolutely not have to use \entrydata. You should also not have to combine several \cite... commands into one.

Instead define one single command that produces the complete output you want with \DeclareCiteCommand.

moewe
  • 175,683
  • Related: https://tex.stackexchange.com/q/501331/35864, https://tex.stackexchange.com/q/73799/35864. – moewe Mar 02 '24 at 12:54