Paquete de macro expansión y biocon

Paquete de macro expansión y biocon

Estoy usando el bioconpaquete para organizar plantas en un trabajo académico. Creé nuevos taxones según era necesario en el texto, por ejemplo, la familia. En el capítulo final del trabajo, tengo una tabla grande (alrededor de 300 entradas) que enumera información de las plantas (que tengo en todos los taxones nuevos).

Esta tabla está organizada alfabéticamente por familia. Así, en algunos casos tengo familias repetidas en la primera columna. Cuando esto sucede, necesito imprimir solo la primera aparición de la familia y las restantes deben estar en blanco.

Creé una solución alternativa pero no funciona junto con biocon. Para simplificar en el siguiente MWE omití la tabla y en su lugar uso la misma estructura en texto plano:

\documentclass{article}
\usepackage{biocon}
\usepackage{ifthen}

\begin{document}

\newtaxon{family}
\newtaxastyle{Family}{\taxon{!family!}}

\newplant{araca}{genus=Psidium, epithet=cattleianum, author=Sabine, family=Myrtaceae}
\newplant{acafrao}{genus=Curcuma, epithet=longa, author=L., family=Zingiberaceae}
\newplant{gengibre}{genus=Zingiber, epithet=officinale, author=Roscoe, family=Zingiberaceae}

Testing the new taxon: \plant[Family]{araca}.

\newcommand{\myval}{}

\newcommand{\setMyVal}[1]{\gdef\myval{#1}}

\newcommand{\printOnlyFirstOccurence}[1]{
    \ifthenelse{\equal{\myval}{#1}}
        {}
        {\setMyVal{#1}(\myval)}%else
}

The same plant obviously would have the same family, thus: 
\plant[f]{araca}\printOnlyFirstOccurence{\plant[Family]{araca}} and \plant[f]{araca}\printOnlyFirstOccurence{\plant[Family]{araca}};

However, these two have the same family, and yet they are printed duplicated: 
\plant[f]{acafrao}\printOnlyFirstOccurence{\plant[Family]{acafrao}} and \plant[f]{gengibre}\printOnlyFirstOccurence{\plant[Family]{gengibre}};

\end{document}

En el ejemplo anterior, utilizo la definición de \printOnlyFirstOccurencepara decidir si el nombre científico de una planta estaría acompañado o no por su apellido. Sólo quiero mostrar la primera aparición (en secuencia) de una familia (es lo mismo que para la tabla, pero aquí mi ejemplo falla en texto plano).

El resultado del segundo ejemplo es:

Probando el nuevo taxón: Myrtaceae. La misma planta obviamente tendría la misma familia, así:Psidium ganado(Mirtáceas) yPsidium ganado; Sin embargo, estos dos pertenecen a la misma familia y, sin embargo, están impresos duplicados:cúrcuma larga(Zingiberáceas) yZingiber officinale(Zingiberáceas);

Pero el resultado deseado es:

Probando el nuevo taxón: Myrtaceae. La misma planta obviamente tendría la misma familia, así:Psidium ganado(Mirtáceas) yPsidium ganado; Sin embargo, estos dos pertenecen a la misma familia y, sin embargo, están impresos duplicados:cúrcuma larga(Zingiberáceas) yZingiber officinale;

¿Alguna idea?

Respuesta1

También podemos simplificar la sintaxis proporcionando un comando \plantFque agregue automáticamente el nombre de la familia, siempre que no sea el mismo que la última familia que se ha compuesto.

La idea es la misma que la tuya, pero necesitamos profundizar en lo interno; en particular, el apellido de aracase almacena en \Paraca@family.

\documentclass{article}
\usepackage{biocon}
\usepackage{pdftexcmds}

\makeatletter
\newcommand{\opt@family}[1]{%
  \ifnum\pdf@strcmp{\csname P#1@family\endcsname}{\plantfamily@last}=\z@
  \else
    \protected@xdef\plantfamily@last{\csname P#1@family\endcsname}%
    \ (\plant[Family]{#1})%
  \fi
}
\newcommand{\resetfamily}{\gdef\plantfamily@last{}} % reinitialize
\resetfamily % initialize

% user command
\newcommand{\plantF}[2][]{%
  \plant[#1]{#2}\opt@family{#2}%
}
\makeatother

\begin{document}

\newtaxon{family}
\newtaxastyle{Family}{\taxon{!family!}}

\newplant{araca}{genus=Psidium, epithet=cattleianum, author=Sabine, family=Myrtaceae}
\newplant{acafrao}{genus=Curcuma, epithet=longa, author=L., family=Zingiberaceae}
\newplant{gengibre}{genus=Zingiber, epithet=officinale, author=Roscoe, family=Zingiberaceae}

Testing the new taxon: \plant[Family]{araca}.

The same plant obviously would have the same family, thus: 
\plantF[f]{araca} and \plantF[f]{araca}.

However, these two have the same family:
\plantF[f]{acafrao} and \plantF[f]{gengibre}.

The same plant obviously would have the same family, thus: 
\plantF[f]{araca} and \plantF[f]{araca}.

\resetfamily

The same plant obviously would have the same family, thus: 
\plantF[f]{araca} and \plantF[f]{araca}.

\end{document}

Tenga en cuenta que en el último párrafo, la familia se imprime nuevamente debido a \resetfamily.

ingrese la descripción de la imagen aquí

Respuesta2

A propósito dejé otras respuestas primero, para que la mía apareciera en la parte superior ;-)

\documentclass{article}
\usepackage{biocon}
%\usepackage{ifthen}% already loaded by biocon

\newcommand*\OnlyFirstPlantFamily [1]{%
    \expandafter\ifx\csname OnlyFirst@\csname P#1@family\endcsname\endcsname
                    \relax
    \space(\plant[Family]{#1})%
    \global\expandafter
           \let\csname OnlyFirst@\csname P#1@family\endcsname\endcsname \empty
    \fi
}

\begin{document}

\newtaxon{family}
\newtaxastyle{Family}{\taxon{!family!}}

\newplant{araca}{genus=Psidium, epithet=cattleianum, author=Sabine, family=Myrtaceae}
\newplant{acafrao}{genus=Curcuma, epithet=longa, author=L., family=Zingiberaceae}
\newplant{gengibre}{genus=Zingiber, epithet=officinale, author=Roscoe, family=Zingiberaceae}

Testing the new taxon: \plant[Family]{araca}.

The same plant obviously would have the same family, thus: 
\plant[f]{araca}\OnlyFirstPlantFamily{araca} and \plant[f]{araca}\OnlyFirstPlantFamily{araca};

However, these two have the same family, and yet they are printed duplicated: 
\plant[f]{acafrao}\OnlyFirstPlantFamily{acafrao} and
\plant[f]{gengibre}\OnlyFirstPlantFamily{gengibre};

\end{document}

Utiliza partes internas de biocon.

cita en bloque

Respuesta3

Esto no funcionará. \plant[Family]{acafrao}Es un comando muy complicado y en absoluto expandible y no puedes usarlo en otros casos.

Puedes probar algo como esto, pero no conozco el paquete, así que sólo supongo que funcionará:

\documentclass{article}
\usepackage{biocon}
\usepackage{ifthen}

\begin{document}

\newtaxon{family}
\newtaxastyle{Family}{\taxon{!family!}}

\newplant{araca}{genus=Psidium, epithet=cattleianum, author=Sabine, family=Myrtaceae}
\newplant{acafrao}{genus=Curcuma, epithet=longa, author=L., family=Zingiberaceae}
\tracingmacros=1
\newplant{gengibre}{genus=Zingiber, epithet=officinale, author=Roscoe, family=Zingiberaceae}
\tracingmacros=0
Testing the new taxon: \plant[Family]{araca}.

\makeatletter
\newcommand\Lastfamily{}
\def\Lastfamily{}
\newcommand{\printOnlyFirstOccurence}[1]{%
 \edef\Newfamily{\csname \curr@ntid family\endcsname}%
 \ifthenelse{\equal{\Lastfamily}{\Newfamily}}
        {}
        { #1}%else
 \let\Lastfamily\Newfamily        
}
\makeatother

The same plant obviously would have the same family, thus:
\plant[f]{araca}\printOnlyFirstOccurence{\plant[Family]{araca}} and \plant[f]{araca}\printOnlyFirstOccurence{\plant[Family]{araca}};

However, these two have the same family, and yet they are printed duplicated:
\plant[f]{acafrao}\printOnlyFirstOccurence{\plant[Family]{acafrao}} and \plant[f]{gengibre}\printOnlyFirstOccurence{\plant[Family]{gengibre}};

\end{document}

información relacionada