我需要知道 .bib 文件是否有 PUBLISHER、DOI、URL、JOURNAL 等字段或为空,这样才能创建另一个新命令,在其中放置条件并能够根据 APA 自动生成图像引用。到目前为止,我已经能够知道 DOI、Journal 和 URL 字段是否存在或为空,但我无法在 OVERLEAF 中运行时确定 PUBLISHER 字段是否存在,而不会出现未定义的错误(如果它为空)。
注意,我尝试使用 create 命令执行相同的操作来了解它是否是一个文件,使用 \ifentrytype 条件来了解它是否是一篇文章或一本书,但没有任何结果。
\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}