On Thu, 10 Apr 2025, Jai Flack wrote:

> Greetings everyone!
> First of all, thank you for the glorious software that is ConTeXt.
> 
> Is there any interest in pulling a complete IEEE bibliography style into the
> ConTeXt tree (or even just as a module)?
> I currently have an IEEE bibliography style that is roughly 80% complete for
> my own uses but I am more than willing to complete it (or as close as one
> can be to complete with the number of inconsistencies in the reference
> guide) if anyone is interested in the result.

I use the attached file for my personal documents. It is not complete (as I 
don't use all types of bib entries), but maybe we can merge this with what you 
have. 

Aditya
%D \module
%D   [       file=publ-imp-ieee,
%D        version=2015.03.22,
%D          title=IEEE bibliography style,
%D       subtitle=Publications,
%D         author=Alan Braslau and Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is therefore 
copyrighted
%D by \PRAGMA. See mreadme.pdf for details.

\startbtxrenderingdefinitions[ieee]

%D Reference:
%D \startTEX
%D @Book{APS2011,
%D     title    ={Physical Review Style and Notation Guide}
%D     year     ={2011},
%D     month    ={June}
%D     edition  ={Revised},
%D     editor   ={Waldron, A and Judd, P. and Miller, V.},
%D     address  ={Ridge, NY},
%D     publisher={American Physical Society},
%D     Xpages   ={26},
%D     url      ={http://journals.ieee.org/files/styleguide-pr.pdf}
%D }
%D \stopTEX

% set ALL specific APS compliant values

\definebtx
  [ieee]
  [\c!default=default,
   \c!specification=ieee,
   \c!otherstext={\btxspace{\it\btxlabeltext{ieee:others}}},
   \c!etallimit=6,
   \c!etaldisplay=\btxparameter\c!etallimit,
   %c!journalconversion=\v!normal,
   \c!monthconversion=\v!month,
   \c!title=\v!yes,
   \c!separator:names:2={\btxcomma},
   \c!separator:names:3={\btxcomma\btxlabeltext{ieee:and}\space},
   \c!separator:names:4={\btxspace\btxlabeltext{ieee:and}\space}]

% First, define and set list and rendering parameters

\definebtxrendering
  [ieee]
  [\c!specification=ieee,
   \c!sorttype=\v!default,
   \c!numbering=num]

\setupbtxlist
  [ieee]
  [\c!alternative=b] % spaces

\definebtx
  [ieee:\s!list]
  [ieee]
  [\c!authorconversion=normalshort]

\definebtx
  [ieee:\s!list:author]
  [ieee:\s!list]

\definebtx
  [ieee:\s!list:editor]
  [ieee:\s!list:author]

\definebtx
  [ieee:\s!list:suffix]
  [ieee:\s!list]

\definebtx
  [ieee:\s!list:url]
  [ieee:\s!list]

\definebtx
  [ieee:\s!list:doi]
  [ieee:\s!list]

\definebtx
  [ieee:\s!list:\s!page]
  [ieee:\s!list]
  [\c!separator:2={\btxcomma},
   \c!separator:3={\btxcomma\btxlabeltext{ieee:and}\space},
   \c!separator:4={\btxspace\btxlabeltext{ieee:and}\space},
   \c!left={\btxleftparenthesis},
   \c!right={\btxrightparenthesis},
   \c!command={\wordright}]

\definebtx
  [ieee:\s!list:numbering]
  [ieee:\s!list]
  [left={[},
   right={]}]

\definebtx
  [ieee:\s!list:numbering:default]
  [ieee:\s!list:numbering]

\definebtx
  [ieee:\s!list:numbering:num]
  [ieee:\s!list:numbering]

\definebtx
  [ieee:\s!list:numbering:short]
  [ieee:\s!list:numbering]

\definebtx
  [ieee:\s!list:numbering:tag]
  [ieee:\s!list:numbering]

\definebtx
  [ieee:\s!list:numbering:index]
  [ieee:\s!list:numbering]

%D In order to be able to get journals expanded (or normalized or abbreviated) 
you need
%D to load a list:
%D
%D \starttyping
%D \btxloadjournallist[journals.txt] % the jabref list
%D \stoptyping

% TODO

\definebtx
  [ieee:\s!list:booktitle]
  [ieee:\s!list]
  [\c!style=\v!italic,
   \c!command=\Word]


\definebtx
  [ieee:\s!list:journal]
  [ieee:\s!list]
  [\c!style=\v!italic]
  %command=\btxexpandedjournal] % btxabbreviatedjournal

\definebtx
  [ieee:\s!list:volume]
  [ieee:\s!list]
  [\c!style=\v!normal]

\definebtx
  [ieee:\s!list:title]
  [ieee:\s!list]
  [\c!style=\v!italic,
   \c!command=\Word]

\definebtx
  [ieee:\s!list:title:article]
  [ieee:\s!list:title]
  [\c!style=,
   \c!command=\quotation] % journal is set in italics

\definebtx
  [ieee:\s!list:title:magazine]
  [ieee:\s!list:title]

\definebtx
  [ieee:\s!list:title:newspaper]
  [ieee:\s!list:title]

\definebtx
  [ieee:\s!list:title:periodical]
  [ieee:\s!list:title]

\definebtx
  [ieee:\s!list:title:standard]
  [ieee:\s!list:title]

\definebtx
  [ieee:\s!list:title:book]
  [ieee:\s!list:title]

\definebtx
  [ieee:\s!list:title:inbook]
  [ieee:\s!list:title]

\definebtx
  [ieee:\s!list:title:incollection]
  [ieee:\s!list:title]
  [\c!style=]

\definebtx
  [ieee:\s!list:title:proceedings]
  [ieee:\s!list:title]

\definebtx
  [ieee:\s!list:title:inproceedings]
  [ieee:\s!list:title]
  [\c!style=]
  %\c!command=\quotation] % booktitle is set in italics

\definebtx
  [ieee:\s!list:title:conference]
  [ieee:\s!list:title]
  [\c!style=] % booktitle is set in italics

\definebtx
  [ieee:\s!list:title:thesis]
  [ieee:\s!list:title]

\definebtx
  [ieee:\s!list:title:phdthesis]
  [ieee:\s!list:title]

\definebtx
  [ieee:\s!list:title:mastersthesis]
  [ieee:\s!list:title]

\definebtx
  [ieee:\s!list:title:booklet]
  [ieee:\s!list:title]

\definebtx
  [ieee:\s!list:title:manual]
  [ieee:\s!list:title]

\definebtx
  [ieee:\s!list:title:techreport]
  [ieee:\s!list:title]

\definebtx
  [ieee:\s!list:title:unpublished]
  [ieee:\s!list:title]

\definebtx
  [ieee:\s!list:title:patent]
  [ieee:\s!list:title]

\definebtx
  [ieee:\s!list:title:electronic]
  [ieee:\s!list:title]

\definebtx
  [ieee:\s!list:title:other]
  [ieee:\s!list:title]

\definebtx
  [ieee:\s!list:title:misc]
  [ieee:\s!list:title]

\definebtx
  [ieee:\s!list:title:literal]
  [ieee:\s!list:title]

\definebtx
  [ieee:\s!list:type]
  [\c!command=\Word]

% Then define and set all cite parameters

\definebtx
  [ieee:\s!cite]
  [ieee]
  [\c!alternative=num,
   \c!authorconversion=\v!name,
   \c!compress=\v!yes,
   \c!sorttype=normal]

\definebtx
  [ieee:\s!cite:name]
  [ieee:\s!cite]
  [\c!authorconversion=\v!name]

\definebtx
  [ieee:\s!cite:inverted]
  [ieee:\s!cite]
  [\c!authorconversion=\v!invertedshort]

\definebtx
  [ieee:\s!cite:invertedshort]
  [ieee:\s!cite]
  [\c!authorconversion=\v!invertedshort]

\definebtx
  [ieee:\s!cite:normalshort]
  [ieee:\s!cite]
  [\c!authorconversion=\v!normalshort]

\definebtx
  [ieee:\s!cite:normal]
  [ieee:\s!cite]
  [\c!authorconversion=\v!normal]

\definebtx
  [ieee:\s!cite:author]
  [ieee:\s!cite]

\definebtx
  [ieee:\s!cite:authoryear]
  [ieee:\s!cite:author]
  [\c!left={(},
   \c!right={)},
   \c!inbetween={\btxcomma}]

\definebtx
  [ieee:\s!cite:authoryears]
  [ieee:\s!cite:authoryear]
  [\c!left=,
   \c!right=,
   \c!inbetween={\btxspace}]

\definebtx
  [ieee:\s!cite:authornum]
  [ieee:\s!cite:author]
  [\c!left={(},
   \c!right={)}]

\definebtx
  [ieee:\s!cite:author:num] % todo
  [ieee:\s!cite:authornum]
  [\c!left={\btxspace[},
   \c!right={]}]

\definebtx
  [ieee:\s!cite:author:year] % todo
  [ieee:\s!cite:authoryear]
  [\c!left=,
   \c!right=]

\definebtx
  [ieee:\s!cite:author:years] % todo
  [ieee:\s!cite:authoryears]
  [\c!inbetween=,
   \c!left={\btxspace(},
   \c!right={)}]

\definebtx
  [ieee:\s!cite:year]
  [ieee:\s!cite]

\definebtx
  [ieee:\s!cite:title]
  [ieee:\s!cite]
  [\c!command={\language[\currentbtxlanguage]}, % BAH
   \c!sorttype=none,
   \c!style=\v!italic]

\definebtx
  [ieee:\s!cite:booktitle]
  [ieee:\s!cite:title]
  [\c!style=\v!italic]

\definebtx
  [ieee:\s!cite:tag]
  [ieee:\s!cite]
  [\c!left={[},
   \c!right={]}]

\definebtx
  [ieee:\s!cite:index]
  [ieee:\s!cite]
  [\c!left={[},
   \c!right={]}]

\definebtx
  [ieee:\s!cite:page]
  [ieee:\s!cite]
  [\c!left=,
   \c!right=,
   \c!separator:2={\btxcomma}, % :0 and :1 - between items of a list
   \c!separator:3={\btxcomma\btxlabeltext{ieee:and}\space},
   \c!separator:4={\btxspace\btxlabeltext{ieee:and}\space}]

\definebtx
  [ieee:\s!cite:pages]
  [ieee:\s!cite:page]

\definebtx
  [ieee:\s!cite:keywords]
  [ieee:\s!cite]
  [\c!left={(},
   \c!right={)}]

\definebtx
  [ieee:\s!cite:short]
  [ieee:\s!cite]
  [\c!left={[},
   \c!right={]}]

\definebtx
  [ieee:\s!cite:category]
  [ieee:\s!cite]

\definebtx
  [ieee:\s!cite:url]
  [ieee:\s!cite]
  [\c!left={[},
   \c!right={]}]

\definebtx
  [ieee:\s!cite:doi]
  [ieee:\s!cite:url]

\definebtx
  [ieee:\s!cite:num]
  [ieee:\s!cite]
  [\c!left={[},
   \c!right={]},
  %\c!left=,   % TODO: PRB uses superscript references...
  %\c!right=,  % and after punctuation, PRA, C, D, E, and L are before!
  %\c!command={\high},
   \c!separator:2={\btxcommabreak},
   \c!separator:3=\btxparameter{\c!separator:2},
   \c!separator:4=\btxparameter{\c!separator:2}]

\definebtx
  [ieee:\s!cite:default]
  [ieee:\s!cite:num]

\definebtx
  [ieee:\s!cite:textnum]
  [ieee:\s!cite:num]
  [\c!left={Ref.\nbsp},
   \c!command=,
   \c!separator:2={\btxcomma},
   \c!separator:3={\btxspace\btxlabeltext{ieee:and}\space},
   \c!separator:4={\btxspace\btxlabeltext{ieee:and}\space}]

\definebtx
  [ieee:\s!cite:entry]
  [ieee:\s!cite]
  [\c!left=,
   \c!right=,
   \c!inbetween={\btxspace},
   \c!separator:2={\btxsemicolon},
   \c!separator:3=\btxparameter{\c!separator:2},
   \c!separator:4=\btxparameter{\c!separator:2}]

%D Sometimes we have verbose injections in an entry and these can be language
%D dependent, so we use labels.
%D
%D Because we want to mix rendering (in the manual) we need a namespace in label
%D texts:

\setupbtxlabeltext
  [en]
  [ieee:and=and,
   ieee:number={no.},
   ieee:edition={ed.},
   ieee:Editor={Ed.},
   ieee:Editors={Eds.},
   ieee:Volume={Vol.},
   ieee:Volumes={Vols.},
   ieee:others={et al.},
   ieee:page={p. },
   ieee:pages={pp. },
   ieee:mastersthesis={Master's thesis},
   ieee:phdthesis={PhD thesis},
   ieee:technicalreport={Tech. Rep.},  % Technical report
   ieee:supplement={Suppl.},           % Supplement (not used?)
   ieee:patent=Patent,
   ieee:inpress={in press},
   ieee:tobe={to be published},
   ieee:unpublished={unpublished},
   ieee:In=in]

% Check this (google translate!!):

% cite setups

\startsetups btx:ieee:nd
    \doifelse {\currentbtxcategory} {article} {
        \btxlabeltext{ieee:tobe}
    } {
        \doifelse {\currentbtxcategory} {book} {
            \btxlabeltext{ieee:inpress}
        } {
            \btxlabeltext{ieee:unpublished}
        }
    }
\stopsetups

\startsetups btx:ieee:cite:author:year
    \texdefinition{\s!btx:\s!cite:concat}
    \ifx\currentbtxfirst\empty
        \fastsetup{btx:ieee:nd}
    \else
        \texdefinition {\s!btx:\s!cite:inject} {
            \btxcitereference
            \currentbtxfirst
        }
        \ifx\currentbtxsecond\empty \else
            \btxparameter\c!inbetween
            \texdefinition {\s!btx:\s!cite:inject} {
                \currentbtxsecond
            }
        \fi
        \btxflushsuffix
    \fi
\stopsetups

\startsetups btx:ieee:cite:author:years
    \fastsetup{btx:ieee:cite:author:year}
\stopsetups

% used in publ-imp-page.mkvi

\startsetups [btx:ieee:list:page-or-pages]
    \ifx\currentbtxlastpage\empty
        \btxlabeltext{ieee:page}
    \else
        \btxlabeltext{ieee:pages}
    \fi
    \btxnbsp
\stopsetups

%D Instead of texdefinitions without arguments, we could have used setups but 
in my
%D editor (hh, scite) the commands stand out better. It also saves an additional
%D component in the name (e.g. common:) because commands and setups have a 
different
%D namespace, so similar calls don't clash. Performance of definitions is 
somewhat
%D better.

%D We use "texdefinitions" (with eventual arguments) for helpers that are used
%D in the rendering "setups" defined for each category below.

%D Note that \btxdoif... and \btxflush rely on the definitions in
%D publ-imp-ieee.lua: fields that are not listed as required nor optional are
%D IGNORED. We also make heavy use of the notion of sets - comma-separated lists
%D of alternative fields to be used in hierarchal order. For example:
%D author = { "author", "editor", "publisher", "title" }, will return the
%D author field if it exists; if not, the editor field will be returned, if it
%D exists; if not, the publisher field will be returned, if it exists; if not,
%D the title field will be returned, it it exists; if not, nothing will be
%D returned. In lua syntax, it can be understood as
%D author or editor or publisher or title or ""

\starttexdefinition btx:ieee:composed-title #title
    \btxstartstyleandcolor [ieee:\s!list:title:\currentbtxcategory]
        \begingroup
            \language[\currentbtxlanguage]
            \btxusecommand [ieee:\s!list:title:\currentbtxcategory] {
                \btxflush{#title}
                \btxdoif {sub#title} {
                    \btxcolon
                    \btxflush{sub#title}
                }
            \btxcomma
            }
        \endgroup
    \btxstopstyleandcolor
\stoptexdefinition

\starttexdefinition btx:ieee:title
    \btxdoif {title} {
        % we make the title active, opening file
        \btxdoifelse {file} {
            \texdefinition{btx:format:inject}
                {url(file:\btxflush{file})}
                {
                    \texdefinition{btx:ieee:composed-title}{title}
                }
        } {
            \texdefinition{btx:ieee:composed-title}{title}
        }
    }
\stoptexdefinition

\starttexdefinition btx:ieee:optional-title
    \doif{\btxparameter{\c!title}}\v!yes {
        \texdefinition {btx:ieee:title}
    }
\stoptexdefinition

\starttexdefinition btx:ieee:year
    \btxdoifelse {year} {
      \btxdoif {month} {
          \Word{\monthshort{\btxflush{month}}}\btxspace
        }
        \btxflush{year}
    } {
        \fastsetup{btx:ieee:nd}
    }
\stoptexdefinition

% #author may be author(set) or editor

\starttexdefinition btx:ieee:author-or-editor #author
    \btxdoif {#author} {
        \btxflush{#author}
        \doifelse {\btxfoundname{#author}} {editor} {
            \btxleftparenthesis
            \btxsingularorplural {editor} {
                \btxlabeltext{ieee:Editor}
            } {
                \btxlabeltext{ieee:Editors}
            }
            \btxrightparenthesis
        } {
            \btxdoif {collaboration} {
                \btxleftparenthesis
                \btxflush{collaboration}
                \btxrightparenthesis
            }
        }
    }
\stoptexdefinition

\starttexdefinition btx:ieee:author
    \btxflush{author}
    \btxcomma
\stoptexdefinition

\starttexdefinition btx:ieee:editor-in
    \btxdoif {booktitle} {
        \btxlabeltext{ieee:In}
        \doifnot {\btxfoundname{author}} {editor} {
            \btxspace
            \texdefinition{btx:ieee:author-or-editor} {editor}
        }
        \btxspace
        \texdefinition{btx:ieee:composed-title} {booktitle}
    }
\stoptexdefinition

\starttexdefinition btx:ieee:editionset
    \doif {\currentbtxcategory} {techreport} {
        \btxdoifelse {type} {
            \btxusecommand [\currentbtx:type] {
                \btxflush{type}
            }
        } {
            \btxlabeltext{ieee:technicalreport}
        }
        \btxcomma
    }
    \btxdoif {volume} {
        \btxoneorrange {volume} {
            \btxlabeltext{ieee:Volume}
        } {
            \btxlabeltext{ieee:Volumes}
        }
        \btxspace
        \btxflush{volume}
        \btxcomma
    }
    \btxdoif {number} {
        \btxlabeltext{ieee:number}
        \btxspace
        \btxflush{number}
        \btxcomma
    }
    \btxdoif {edition} {
        \btxflush{edition}
        \btxspace
        \btxlabeltext{ieee:edition}
        \btxcomma
    }
    \btxdoif {pages} {
        \btxoneorrange {pages} {
            \btxlabeltext{ieee:page}
        } {
            \btxlabeltext{ieee:pages}
        }
        \btxnbsp
        \btxflush{pages}
        \btxcomma
    }
\stoptexdefinition

\starttexdefinition btx:ieee:journal-volume-year
    \btxdoif {journal} {
        \btxstartstyleandcolor [ieee:\s!list:journal]
            % expandedjournal abbreviatedjournal
            \btxflush{expandedjournal -> journal}
        \btxstopstyleandcolor
            \btxcomma
        \btxdoifelse {volume} {
            \btxspace
            \btxstartstyleandcolor [ieee:\s!list:volume]
                vol.~\btxflush{volume}
                \btxcomma
            \btxstopstyleandcolor
            \btxdoif {number} {
                no.~\btxflush{number}
                \btxcomma
            }
        } {
            \btxdoif {number} {
                \btxspace
                \btxflush{number}
                \btxcomma
            }
        }
        \btxdoif {pages} {
            \btxspace
            pp.~\btxflush{pages}
            \btxcomma
        }
    }
    \texdefinition{btx:ieee:year}
\stoptexdefinition

\starttexdefinition btx:ieee:publisher-wherefrom-year
    \removeunwantedspaces
    \btxspace
    \btxflush{publisher}
    \btxdoifelse {address} {
        \btxdoif {publisher} {
            \btxcomma
        }
        \btxflush{address}
        \btxdoif {country} {
            \btxcomma
            \btxflush{country}
        }
        \btxcomma
    } {
        \btxdoif {publisher} {
            \btxcomma
        }
    }
    \texdefinition{btx:ieee:year}
\stoptexdefinition

\starttexdefinition btx:ieee:note
    \btxperiod
    \btxdoif {note} {
        \btxleftparenthesis
        \btxflush{note}
        \btxrightparenthesis
    }
\stoptexdefinition

\starttexdefinition btx:ieee:doi-url #text
    \ifconditional\btxinteractive
        \btxdoifelse {doi} {
            \goto {#text} [url(http://dx.doi.org/\btxflush{doi})]
        } {
            \btxdoifelse {url} {
                \goto {#text} [url(\btxflush{url})]
            } {
                #text
            }
        }
    \else
        #text
    \fi
\stoptexdefinition

% Then setups, by category

% An article from a journal
% Required fields: author or editor or title, journal, (year).
% Optional fields: volume, number, pages, type, doi, url, note.
% Note that bibtex (and tools) do not include editor (e.g. special issue or 
section)

\startsetups btx:ieee:list:article
    \texdefinition{btx:ieee:author}
    \texdefinition{btx:ieee:optional-title}
    \texdefinition{btx:ieee:doi-url} 
{\texdefinition{btx:ieee:journal-volume-year}}
    \texdefinition{btx:ieee:note}
\stopsetups

% An article from a magazine.
% Required fields: author or title, journal, (year).
% Optional fields: number, pages, type, month, day, doi, url, note.

\startsetups btx:ieee:list:magazine
    \fastsetup{btx:ieee:list:article}
\stopsetups

% An article from a newspaper.
% Required fields: author or title, journal, (year).
% Optional fields: number, pages, type, month, day, doi, url, note.

\startsetups btx:ieee:list:newspaper
    \fastsetup{btx:ieee:list:article}
\stopsetups

% A complete issue of a periodical, such as a special issue of a journal.
% Required fields: title, year
% Optional fields: editor, publisher, subtitle, series, volume, number, month, 
organization, doi, url, issn, note

% needs to be tuned...
\startsetups btx:ieee:list:periodical
    \fastsetup{btx:ieee:list:article}
\stopsetups

% National and international standards issued by a standards body
% Required fields: author, institution, or organization, year, title
% Optional fields: subtitle, doi, url, note

\startsetups btx:ieee:list:standard
    \texdefinition{btx:ieee:author}
    \texdefinition{btx:ieee:title}
    \texdefinition{btx:ieee:note}
\stopsetups
% year?

% A book with an explicit publisher.
% Required fields: author or editor or publisher, title, (year).
% Optional fields: volume or number, series, address, edition, month, day, note.
% APS? ignores: month, day

% todo: series?

\startsetups btx:ieee:list:book
    \texdefinition{btx:ieee:author}
    \texdefinition{btx:ieee:title}
    \texdefinition{btx:ieee:editionset}
    \texdefinition{btx:ieee:doi-url} 
{\texdefinition{btx:ieee:publisher-wherefrom-year}}
    \texdefinition{btx:ieee:note}
\stopsetups

% There is some debate about how inbook should differ from incollection

% A part of a book, which may be a chapter (or section or whatever) and/or a 
range of pages.
% (note that inbook is handled differently by bibtex and biblatex)
% Required fields: author or editor, title, chapter and/or pages, publisher, 
year.
% Optional fields: volume or number, series, type, address, edition, month, 
note.
% We add optional: booktitle.
% APS? ignores: chapter, month

\startsetups btx:ieee:list:inbook
    \texdefinition{btx:ieee:author}
    \texdefinition{btx:ieee:title}
    \texdefinition{btx:ieee:editor-in}
    \texdefinition{btx:ieee:editionset}
    \texdefinition{btx:ieee:doi-url} 
{\texdefinition{btx:ieee:publisher-wherefrom-year}}
    \texdefinition{btx:ieee:note}
\stopsetups
% chapter?

% A part of a book having its own title.
% Required fields: author, title, booktitle, publisher, year.
% Optional fields: editor, volume or number, series, type, chapter, pages, 
address, edition, month, note.
% APS? ignores: chapter, month

\startsetups btx:ieee:list:incollection
    \fastsetup{btx:ieee:list:inbook}
\stopsetups

% The proceedings of a conference.
% Required fields: title, year.
% Optional fields: editor, volume or number, series, address, month, 
organization, publisher, note.
% todo: series?

\startsetups btx:ieee:list:proceedings
    \fastsetup{btx:ieee:list:book}
\stopsetups

% An article in a conference proceedings.
% Required fields: author, title, booktitle, year.
% Optional fields: editor, volume or number, series, pages, address, month, 
organization, publisher, note.

\startsetups btx:ieee:list:inproceedings
    \texdefinition{btx:ieee:author}
    \quotation{\texdefinition{btx:ieee:title}\removeunwantedspaces}
    \btxspace
    \italic{\texdefinition{btx:ieee:editor-in}}
    \texdefinition{btx:ieee:editionset}
    \btxdoif {organization} {
        \btxspace
        \btxflush{organization}
        \btxcomma
    }
    \texdefinition{btx:ieee:doi-url} 
{\texdefinition{btx:ieee:publisher-wherefrom-year}}
    \texdefinition{btx:ieee:note}
\stopsetups

\startsetups btx:ieee:list:conference
    \fastsetup{btx:ieee:list:inproceedings}
\stopsetups

% A thesis.
% Required fields: author, title, school, year.
% Optional fields: type, address, month, note.

\startsetups btx:ieee:list:thesis
    \texdefinition{btx:ieee:author}
    \texdefinition{btx:ieee:title}
    \btxdoifelse {type} {
        \btxusecommand [ieee:list:type] {
            \btxflush{type}
        }
    } {
        \btxlabeltext{ieee:\currentbtxcategory}
    }
    \btxcomma
    \btxdoif {school} {
        \btxperiod
        \btxflush{school}
    }
    \btxdoif {address} {
        \btxdoifelse {school} {
            \btxcomma
        } {
            \btxperiod
        }
        \btxflush{address}
        \btxdoif {country} {
            \btxcomma
            \btxflush{country}
        }
    }
    \btxcomma
    \texdefinition{btx:ieee:year}
    \texdefinition{btx:ieee:note}
\stopsetups

\startsetups btx:ieee:list:phdthesis
    \fastsetup{btx:ieee:list:thesis}
\stopsetups

\startsetups btx:ieee:list:mastersthesis
    \fastsetup{btx:ieee:list:thesis}
\stopsetups

% A work that is printed and bound, but without a named publisher or sponsoring 
institution.
% Required field: title.
% Optional fields: author, howpublished, address, month, year, note.

\startsetups btx:ieee:list:booklet
    \fastsetup{btx:ieee:list:book}
\stopsetups

% Technical documentation.
% Required field: title.
% Optional fields: author, organization, address, edition, month, year, note.

\startsetups btx:ieee:list:manual
    \fastsetup{btx:ieee:list:book}
\stopsetups

% A report published by a school or other institution, usually numbered within 
a series.
% Required fields: author, title, institution, year.
% Optional fields: type, number, address, month, note.

\startsetups btx:ieee:list:techreport
    \fastsetup{btx:ieee:list:book}
\stopsetups

% A document having an author and title, but not formally published.
% Required fields: author, title, note.
% Optional fields: month, year.

\startsetups btx:ieee:list:unpublished
    \fastsetup{btx:ieee:list:book}
\stopsetups

% A patent. Note that this category was not defined with BIBTEX. Below from 
JabRef:
% Required fields: nationality, number, year, yearfiled
% Optional fields: author, title, assignee, address, type, number, day, 
dayfiled, month, monthfiled, note, url
% Also optional: publisher

% todo: yearfiled, monthfiled, dayfiled

\startsetups btx:ieee:list:patent
    \texdefinition{btx:ieee:author}
    \texdefinition{btx:ieee:title}
    \begingroup
        %\it
        \btxdoif {nationality} {
            \btxspace
            \btxflush{nationality}
            \btxcomma
        }
        \btxspace
        \btxlabeltext{ieee:patent}
        \btxdoif {number} {
            \btxspace
            \btxlabeltext{ieee:number}
            \btxspace
            \btxflush{number}
        }
        \btxperiod
        \italiccorrection
    \endgroup
    \texdefinition{btx:ieee:doi-url} 
{\texdefinition{btx:ieee:publisher-wherefrom-year}}
    \texdefinition{btx:ieee:url}
    \texdefinition{btx:ieee:note}
\stopsetups

% Electronic. Note that this category was not defined with BIBTEX. Below from 
JabRef:
% Required fields: title
% Optional fields: address, author, howpublished, month, note, organization, 
url, year, doi
% Also optional: type

% Like Misc below but includes organization.

\startsetups btx:ieee:list:electronic
    \texdefinition{btx:ieee:author}
    \texdefinition{btx:ieee:title}
    \btxdoif {organization} {
        \btxspace
        \btxflush{organization}
        \btxperiod
    }
    \btxdoif {howpublished} {
        \btxspace
        \btxflush{howpublished}
    }
    \btxleftparenthesis
    \texdefinition{btx:ieee:year}
    \btxrightparenthesis
    \texdefinition{btx:ieee:note}
\stopsetups

% Other. Note that this category was not defined with BIBTEX. Below from JabRef:
% Required fields: author or title, year
% Optional fields: note, doi, url

\startsetups btx:ieee:list:other
    \fastsetup{btx:ieee:list:book}
\stopsetups

% Use this type when nothing else fits.
% Required fields: none.
% Optional fields: author, title, howpublished, month, year, note.

\startsetups btx:ieee:list:misc
    \fastsetup{btx:ieee:list:electronic}
    % Note that organization is an "ignored" field.
\stopsetups

% If all else fails to match:

\startsetups btx:ieee:list:literal
    %\btxleftparenthesis
    \removeunwantedspaces(
    \btxflush{tag}
    \btxrightparenthesis
    \btxdoif {text} {
        \btxflush{text}
    }
\stopsetups

\stopbtxrenderingdefinitions
local specification = {
    --
    -- metadata
    --
    name      = "ieee",
    version   = "1.00",
    comment   = "APS specification",
    author    = "Alan Braslau and Hans Hagen",
    copyright = "ConTeXt development team",
    --
    -- derived (combinations of) fields (all share the same default set)
    --
    virtual = {
        "authoryear",
        "authoryears",
        "authornum",
        "num",
        "suffix",
    },
    --
    -- special datatypes
    --
    types = {
        --
        -- list of fields that are interpreted as names: "NAME [and NAME]" where
        -- NAME is one of the following:
        --
        -- First vons Last
        -- vons Last, First
        -- vons Last, Jrs, First
        -- Vons, Last, Jrs, First
        --
        author      = "author", -- interpreted as name(s)
        editor      = "author",
        doi         = "url",        -- an external link
        url         = "url",
        page        = "pagenumber", -- number or range: f--t
        pages       = "pagenumber",
        volume      = "range",
        number      = "range",
        keywords    = "keyword",    -- comma|-|separated list
        year        = "number",
    },
    --
    -- categories with their specific fields
    --
    categories = {
        --
        -- categories are added below
        --
    },
}

local generic = {
    --
    -- A set returns the first field (in order of position below) that is found
    -- present in an entry. A set having the same name as a field conditionally
    -- allows the substitution of an alternate field.
    --
    -- note that anything can get assigned a doi or be available online.
    editionset = { "edition", "volume", "number", "pages" },
}

-- Note that the APS specification allows an additional field "collaboration"
-- to be rendered following the author list (if the collaboration name appears
-- in the byline of the cited article).

-- Definition of recognized categories and the fields that they contain.
-- Required fields should be present; optional fields may also be rendered;
-- all other fields will be ignored.

-- Sets contain either/or in order of precedence.
--
-- For a category *not* defined here yet present in the dataset, *all* fields
-- are taken as optional. This allows for flexibility in the addition of new
-- categories.

local categories = specification.categories

-- an article from a journal

categories.article = {
    sets = {
        author = { "author", "editor" },
    },
    required = {
        "author",
        "title",
        "year",
    },
    optional = {
        "collaboration",
        "month",
        "subtitle", "type", "file",
        "journal", "volume", "number", "pages",
        "doi", "url", "note",
    },
}

-- an article from a magazine

categories.magazine = {
    sets = categories.article.sets,
    required = {
        "author",
        "year",
        "journal",
    },
    optional = {
        "collaboration",
        "title", "subtitle", "type", "file",
        "number", "pages",
        "month", "day",
        "doi", "url", "note",
    },
}

categories.newspaper = categories.magazine

-- (from jabref) to be identified and setup ...

categories.periodical = {
    sets = {
        author = { "editor", "publisher" },
    },
    required = {
        "title",
        "year",
    },
    optional = {
        "author",
        "collaboration",
        "subtitle", "file",
        "series", "volume", "number", "month",
        "organization",
        "doi", "url", "note",
    },
}

-- (from jabref) to be identified and setup ...

categories.standard = {
    sets = {
        author = { "author", "institution", "organization" },
    },
    required = {
        "author",
        "year",
        "title", "subtitle",
        "doi", "note",
    },
    optional = {
        "collaboration",
        "url",
    },
}

-- a book with an explicit publisher.

categories.book = {
    sets = {
        author     = { "author", "editor", "publisher" },
        editionset = generic.editionset,
    },
    required = {
        "author",
        "title",
    },
    optional = {
        "collaboration",
        "year", "month", "day",
        "title", "subtitle", "type",  "file",
        "editionset", "series",
        "address",
        "doi", "url", "note",
    },
}

-- a part of a book, which may be a chapter (or section or whatever) and/or a 
range of pages.

categories.inbook = {
    sets = {
        author     = { "author", "editor", "publisher", },
        editionset = generic.editionset,
    },
    required = {
        "author",
        "year" ,
        "title",
    },
    optional = {
        "collaboration",
        "subtitle", "type", "file",
        "booktitle",
        -- "chapter",
        "editionset", "series",
        "month",
        "address",
        "doi", "url", "note",
    },
}

-- a book having its own title as part of a collection.
-- (like inbook, but we here make booktitle required)

categories.incollection = {
    sets = {
        author     = { "author", "editor", "publisher" },
        editionset = generic.editionset,
    },
    required = {
        "author",
        "booktitle",
        "year",
    },
    optional = {
        "collaboration",
        "title", "subtitle", "type", "file",
        "editionset", "series",
        "chapter",
        "month",
        "address",
        "doi", "url", "note",
    },
}

-- a work that is printed and bound, but without a named publisher or 
sponsoring institution.

categories.booklet = {
    sets = {
        publisher = { "howpublished" }, -- no "publisher"!
    },
    required = {
        "author",
        "title",
    },
    optional = {
        "publisher",
        "collaboration",
        "year", "month",
        "subtitle", "type", "file",
        "address",
        "doi", "url", "note",
     },
}

-- the proceedings of a conference.

categories.proceedings = {
    sets = {
        author     = { "editor", "organization", "publisher" }, -- no "author"!
        publisher  = { "publisher", "organization" },
        editionset = generic.editionset,
    },
    required = {
        "author",
        "year"
    },
    optional = {
        "collaboration",
        "publisher",
        "title", "subtitle", "file",
        "editionset", "series",
        "month",
        "address",
        "doi", "url", "note",
    },
}

-- an article in a conference proceedings.

categories.inproceedings = {
    sets     = categories.incollection.sets,
    required = categories.incollection.required,
    optional = {
        "collaboration",
        "title", "subtitle", "type", "file",
        "month",
        "edition", "series",
        "address", "organization",
        "doi", "url", "note",
    },
}

categories.conference = categories.inproceedings

-- a thesis (of course).

categories.thesis = {
    required = {
        "author",
        "title",
        "school",
        "year",
        "type"
    },
    optional = {
        "collaboration",
        "subtitle", "file",
        "month",
        "address",
        "doi", "url", "note",
    },
}

categories.mastersthesis = {
    sets     = categories.thesis.sets,
    required = {
        "author",
        "title",
        "school",
        "year"
    },
    optional = {
        "collaboration",
        "type",
        "subtitle", "file",
        "month",
        "address",
        "doi", "url", "note",
    },
}
categories.phdthesis = categories.mastersthesis

-- a report published by a school or other institution, usually numbered within 
a series.

categories.techreport = {
    sets = {
        author     = { "author", "institution", "publisher" },
        publisher  = { "publisher", "institution", },
        editionset = { "type", "volume", "number", "pages" }, -- no "edition"!
    },
    required = {
        "author",
        "title",
        "institution",
        "year"
    },
    optional = {
        "collaboration",
        "publisher",
        "address",
        "subtitle", "file",
        "editionset",
        "month",
        "doi", "url", "note",
    },
}

-- technical documentation.

categories.manual = {
    sets = {
        author     = { "author", "organization", "publisher" },
        publisher  = { "publisher", "organization", },
        editionset = generic.editionset,
    },
    required = {
        "title"
    },
    optional = {
        "author", "publisher",
        "collaboration",
        "address",
        "subtitle", "file",
        "editionset", "month", "year",
        "doi", "url", "note",
    },
}

-- a patent (of course).

categories.patent = {
    sets = {
        author = { "author", "assignee", },
        publisher = { "publisher", "assignee", },
        year = { "year", "yearfiled", },
        month = { "month", "monthfiled", },
        day = { "day", "dayfiled", },
    },
    required = {
        "nationality",
        "number",
        "year",
    },
    optional = {
        "type",
        --check this: "language",
        "author", "publisher",
        "collaboration",
        "title", "subtitle", "file",
        "address",
        "day", "month",
        "doi", "url", "note",
    },
}

-- a document having an author and title, but not formally published.

categories.unpublished = {
    required = {
        "author",
        "title",
        "note"
    },
    optional = {
        "collaboration",
        "subtitle", "file",
        "year", "month",
        "doi", "url",
    },
}

-- like misc below but includes organization.

categories.electronic = {
    sets = {
        author = { "author", "collaboration", "organization", },
        howpublished = { "howpublished", "doi", "url", },
    },
    required = {
        "title"
    },
    optional = {
        "subtitle", "type", "file",
        "year", "month",
        "author",
        "collaboration",
        "organization",
        "address",
        "howpublished",
        "doi", "url", "note",
    },
}

-- use this type when nothing else fits.

categories.misc = {
    sets = {
        author = { "author", "collaboration", },
        howpublished = { "howpublished", "doi", "url", },
    },
    required = {
        -- nothing is really important here
    },
    optional = {
        "author",
        "collaboration",
        "title", "subtitle", "file",
        "year", "month",
        "howpublished",
        "doi", "url", "note",
    },
}

-- other (whatever jabref does not know!)

categories.other = {
    required = {
        "author",
        "title",
        "year"
    },
    optional = {
        "collaboration",
        "subtitle", "file",
        "doi", "url", "note",
    },
}

-- if all else fails to match:

categories.literal = {
    sets = {
        author = { "tag" }, -- need to check this!
    },
    required = {
        "text"
    },
    optional = {
        "author",
        "doi", "url", "note"
    },
    virtual = false,
}

-- done

return specification
_______________________________________________
dev-context mailing list -- dev-context@ntg.nl
To unsubscribe send an email to dev-context-le...@ntg.nl

Reply via email to