%D \module %D [ file=publ-ini, %D version=2013.05.12, %D title=\CONTEXT\ Publication Support, %D subtitle=Initialization, %D author=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 %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. % todo: we cannot use 'default' as this wipes metadata names (maybe no longer do that) % todo: \v!cite => \s!cite % todo: interface with (ml)bibtex (export -> call -> import) % todo: check if 'all' etc are ok ... either use list or use other criterium % todo: \the\everysetupbtxciteplacement probably too often % \definecolor[btx:field] [darkred] % \definecolor[btx:crossref][darkblue] % \definecolor[btx:key] [darkgreen] % \definecolor[btx:todo] [darkyellow] %D We operate on several axis: %D %D \startitemize[packed] %D \startitem we can have several databases (or combinations) \stopitem %D \startitem we can add entries to them if needed (coded in tex) \stopitem %D \startitem we can have several lists each using one of the databases \stopitem %D \startitem we can render each list or citation independently \stopitem %D \stopitemize %D %D We assume that the rendering of a list entry is consistent in a document, %D although one can redefine properties if needed. Adding more granularity would %D complicate the user interface beyond comprehension. \writestatus{loading}{ConTeXt Publication Support / Initialization} \registerctxluafile{publ-dat}{1.001} \registerctxluafile{publ-aut}{1.001} \registerctxluafile{publ-usr}{1.001} \registerctxluafile{publ-ini}{1.001} \registerctxluafile{publ-oth}{1.001} % this could become an option \registerctxluafile{publ-fnd}{1.001} % new method (for the moment only local) \unprotect \startcontextdefinitioncode \def\s!btx {btx} \def\s!cite {cite} \def\s!nocite {nocite} \def\s!list {list} \def\s!author {author} \def\v!btxcite {btxcite} \def\v!btxlist {btxlist} \def\v!btxrendering {btxrendering} \def\s!btxset {btxset} \def\s!btxref {btxref} \def\s!btxint {btxint} \def\s!btxbck {btxbck} \definelabelclass[btxlabel][2] % a dedicated construction mechanism \installcorenamespace {btxlist} \installcommandhandler \??btxlist {btxlist} \??btxlist \unexpanded\setvalue{\??constructioninitializer\v!btxlist}% {\let\currentbtxlist \currentconstruction \let\constructionparameter \btxlistparameter \let\detokenizedconstructionparameter\detokenizedbtxlistparameter \let\letconstructionparameter \letbtxlistparameter \let\useconstructionstyleandcolor \usebtxliststyleandcolor \let\setupcurrentconstruction \setupcurrentbtxlist} \expandafter\let\csname\??constructionmainhandler \v!btxlist\expandafter\endcsname\csname\??constructionmainhandler \v!construction\endcsname \expandafter\let\csname\??constructioncommandhandler\v!btxlist\expandafter\endcsname\csname\??constructioncommandhandler\v!construction\endcsname \expandafter\let\csname\??constructiontexthandler \v!btxlist\expandafter\endcsname\csname\??constructiontexthandler \v!construction\endcsname \unexpanded\setvalue{\??constructioncommandhandler\v!btxlist}% {\csname\??constructionstarthandler\v!construction\endcsname \csname\??constructionstophandler \v!construction\endcsname \endgroup} \unexpanded\def\startbtxlistentry#1% {\begingroup \strc_constructions_initialize{#1}% \csname\??constructionstarthandler\currentconstructionhandler\endcsname} \unexpanded\def\stopbtxlistentry {\csname\??constructionstophandler\currentconstructionhandler\endcsname} % interactivity is handled in setups \unexpanded\setvalue{\??constructiontexthandler\v!btxlist}% {\begingroup \fastsetup{\v!btxrendering:\v!number:\constructionparameter\c!number}% \endgroup} % the whole entry can be interactive \unexpanded\setvalue{\??constructionstarthandler\v!btxlist}% {\csname\??constructionstarthandler\v!construction\endcsname \ifx\currentbtxnumbering\v!no\else \ifx\currentbtxinternal\empty \else \startgoto[\s!internal(\currentbtxinternal)]% \fi \fi} \unexpanded\setvalue{\??constructionstophandler\v!btxlist}% {\ifx\currentbtxnumbering\v!no\else \ifx\currentbtxinternal\empty \else \stopgoto \fi \fi \csname\??constructionstophandler\v!construction\endcsname \endgroup} \startsetups[\v!btxrendering:\v!number:\v!no] % \btx_reference_checked % needs testing \stopsetups \startsetups[\v!btxrendering:\v!number:\v!yes] \useconstructionstyleandcolor\c!headstyle\c!headcolor % move to \currentconstructiontext \the\everyconstruction \relax \strut \constructionparameter\c!text \btx_list_reference_inject \relax \stopsetups % construction (todo:low level builder commands without using the constructor) \unexpanded\def\strc_constructions_initialize#1% class instance {\edef\currentconstruction{#1}% \let\currentconstructionlistentry\!!zerocount \expandafter\let\expandafter\currentconstructionmain \csname\??constructionmain \currentconstruction\endcsname \expandafter\let\expandafter\currentconstructionlevel \csname\??constructionlevel\currentconstruction\endcsname \expandafter\let\expandafter\currentconstructionhandler\csname\??constructionclass\currentconstruction\endcsname \csname\??constructioninitializer\currentconstructionhandler\endcsname} \appendtoks % \ifx\currentbtxlistparent\empty % \defineconstruction[\currentbtxlist][\currentbtxlistparent][\s!handler=\v!btxlist,\c!level=1]% % \else % \defineconstruction[\currentbtxlist][\s!handler=\v!btxlist,\c!level=1]% % \fi \ifx\currentbtxlistparent\empty \letvalue{\??constructionmain\currentbtxlist}\currentbtxlist \else \letvalue{\??constructionmain\currentbtxlist}\currentbtxlistparent \fi \setevalue{\??constructionlevel\currentbtxlist}{\number\btxlistparameter\c!level}% \setevalue{\??constructionclass\currentbtxlist}{\btxlistparameter\s!handler}% \to \everydefinebtxlist \setupbtxlist [\s!handler=\v!btxlist, \c!level=1] \setupbtxlist [\c!alternative=\v!left, \c!headstyle=, \c!titlestyle=, %\c!style=, %\c!color=, %\c!headcolor=, %\c!titlecolor=, \c!width=4\emwidth, \c!distance=\emwidth, %\c!titledistance=.5\emwidth, %\c!hang=, %\c!sample=, %\c!align=, %\c!headalign=, \c!margin=\v!no, \c!before=\blank, \c!inbetween=\blank, \c!after=\blank, %\c!indentnext=\v!yes, %\c!indenting=\v!never, %\c!titleleft=(, %\c!titleright=), %\c!closesymbol=, %\c!closecommand=\wordright, \c!display=\v!yes, \c!command=, %\c!titlecommand=, %\c!expansion=\v!no, %\c!xmlsetup=, %\s!catcodes=, %\c!title=\v!yes, %\c!text=, \c!number=\v!yes, ] % here starts the bib stuff \installcorenamespace {btxdataset} \installcorenamespace {btxlistvariant} \installcorenamespace {btxcitevariant} \installcorenamespace {btxrendering} \installcorenamespace {btxcommand} \installcorenamespace {btxrenderingdefinition} \installcommandhandler \??btxdataset {btxdataset} \??btxdataset \installcommandhandler \??btxlistvariant {btxlistvariant} \??btxlistvariant \installcommandhandler \??btxcitevariant {btxcitevariant} \??btxcitevariant \installcommandhandler \??btxrendering {btxrendering} \??btxrendering \unexpanded\def\usebtxdataset {\dodoubleargument\publ_use_dataset} \def\publ_use_dataset[#1][#2]% {\ifsecondargument \ctxcommand{usebtxdataset("#1","#2")}% \else \ctxcommand{usebtxdataset("\v!standard","#1")}% \fi} \definebtxdataset [\v!standard] % \usebtxdataset % [standard] % [mybibs.bib] \unexpanded\def\startpublication {\dodoubleempty\publ_set_publication} \let\stoppublication\relax \def\publ_set_publication[#1][#2]% {\begingroup \catcode\commentasciicode\othercatcode \ifsecondargument \expandafter\publ_set_publication_indeed \else\iffirstargument \doubleexpandafter\publ_set_publication_checked \else \doubleexpandafter\publ_set_publication_default \fi\fi{#1}{#2}} \def\publ_set_publication_default#1#2% {\publ_set_publication_indeed\v!standard{#1}} \def\publ_set_publication_checked#1#2% {\doifassignmentelse{#1} {\publ_set_publication_indeed\v!standard{#1}} {\publ_set_publication_indeed{#1}{}}} \def\publ_set_publication_indeed#1#2#3\stoppublication {\ctxcommand{addbtxentry("#1",\!!bs#2\!!es,\!!bs\detokenize{#3}\!!es)}% \endgroup \ignorespaces} % commands \unexpanded\def\btxcommand#1% {\ifcsname\??btxcommand#1\endcsname \expandafter\publ_command_yes \else \expandafter\publ_command_nop \fi{#1}} \let\btxcmd\btxcommand \def\publ_command_yes#1% {\csname\??btxcommand#1\endcsname} \def\publ_command_nop#1% {\ifcsname#1\endcsname \showmessage\m!publications{10}{#1,#1}% %\setuxvalue{\??btxcommand#1}{\expandafter\noexpand\csname#1\endcsname}% \global\expandafter\let\csname\??btxcommand#1\expandafter\endcsname\csname#1\endcsname \else\ifcsname\utfupper{#1}\endcsname \showmessage\m!publications{10}{#1}{\utfupper{#1}}% %\setuxvalue{\??btxcommand#1}{\expandafter\noexpand\csname\utfupper{#1}\endcsname}% \global\expandafter\let\csname\??btxcommand#1\expandafter\endcsname\csname\utfupper{#1}\endcsname \else \showmessage\m!publications{11}{#1}% \setugvalue{\??btxcommand#1}{\underbar{\tttf#1}}% \fi\fi \publ_command_yes{#1}} \unexpanded\def\definebtxcommand#1% {body} #1..#n{body} {\setuvalue{\??btxcommand\strippedcsname#1}}% % tracing \installtextracker {publications.crosslinks} {\let\btx_trace_list_cross\strc_references_tracer} {\let\btx_trace_list_cross\gobbletwoarguments} \let\btx_trace_list_cross\gobbletwoarguments % access \let\currentbtxtag \empty \let\currentbtxdataset\v!standard \unexpanded\def\setbtxdataset[#1]% {\edef\currentbtxdataset{\ctxcommand{setbtxdataset("#1","\currentbtxdataset")}}} \unexpanded\def\setbtxentry[#1]% {\edef\currentbtxtag{\ctxcommand{setbtxentry("\currentbtxdataset","#1")}}} \setbtxdataset [\v!standard] % \let\btxsetdataset\setbtxdataset % \let\btxsetentry \setbtxentry \def\btxfield #1{\ctxcommand{btxfield("\currentbtxdataset","\currentbtxtag","#1")}} \def\btxdetail #1{\ctxcommand{btxdetail("\currentbtxdataset","\currentbtxtag","#1")}} \def\btxflush #1{\ctxcommand{btxflush("\currentbtxdataset","\currentbtxtag","#1")}} \def\btxdoifelse#1{\ctxcommand{btxdoifelse("\currentbtxdataset","\currentbtxtag","#1")}} \def\btxdoif #1{\ctxcommand{btxdoif("\currentbtxdataset","\currentbtxtag","#1")}} \def\btxdoifnot #1{\ctxcommand{btxdoifnot("\currentbtxdataset","\currentbtxtag","#1")}} \let\btxsetup\fastsetup %D How complex will we go? Can we assume that e.g. an apa style will not be mixed %D with another one? I think this assumption is okay. For manuals we might want to %D mix but we can work around it. %D Rendering. \unexpanded\def\btxspace {\removeunwantedspaces\space} \unexpanded\def\btxnobreakspace{\removeunwantedspaces\nobreakspace} % these two are the \unexpanded\def\btxnbsp {\removeunwantedspaces\nbsp} % same anyway \unexpanded\def\btxperiod {\removeunwantedspaces.\space} \unexpanded\def\btxcomma {\removeunwantedspaces,\space} \unexpanded\def\btxcolon {\removeunwantedspaces:\space} \unexpanded\def\btxsemicolon {\removeunwantedspaces;\space} \unexpanded\def\btxlparent {\removeunwantedspaces\space(} \unexpanded\def\btxrparent {\removeunwantedspaces)\space} \unexpanded\def\btxlbracket {\removeunwantedspaces\space[} \unexpanded\def\btxrbracket {\removeunwantedspaces]\space} %D Variables: \let\currentbtxbacklink \empty \unexpanded\def\btxsetbacklink {\def\currentbtxbacklink} \let\currentbtxbacktrace \empty \unexpanded\def\btxsetbacktrace {\def\currentbtxbacktrace} \let\currentbtxcategory \empty \unexpanded\def\btxsetcategory {\def\currentbtxcategory} \let\currentbtxcombis \empty \unexpanded\def\btxsetcombis {\def\currentbtxcombis} \let\currentbtxdataset \empty \unexpanded\def\btxsetdataset {\def\currentbtxdataset} \let\currentbtxfirst \empty \unexpanded\def\btxsetfirst {\def\currentbtxfirst} \let\currentbtxfirstnames \empty \unexpanded\def\btxsetfirstnames {\def\currentbtxfirstnames} \let\currentbtxinitials \empty \unexpanded\def\btxsetinitials {\def\currentbtxinitials} \let\currentbtxinternal \empty \unexpanded\def\btxsetinternal {\def\currentbtxinternal} \let\currentbtxjuniors \empty \unexpanded\def\btxsetjuniors {\def\currentbtxjuniors} \let\currentbtxlanguage \empty \unexpanded\def\btxsetlanguage {\def\currentbtxlanguage} \let\currentbtxsecond \empty \unexpanded\def\btxsetsecond {\def\currentbtxsecond} \let\currentbtxsurnames \empty \unexpanded\def\btxsetsurnames {\def\currentbtxsurnames} \let\currentbtxtag \empty \unexpanded\def\btxsettag {\def\currentbtxtag} \let\currentbtxvons \empty \unexpanded\def\btxsetvons {\def\currentbtxvons} \let\currentbtxauthorvariant\v!normal \unexpanded\def\btxsetauthorvariant{\def\currentbtxauthorvariant} \newconstant\currentbtxoverflow \unexpanded\def\btxsetoverflow#1{\currentbtxoverflow#1\relax} \newconstant\currentbtxconcat \unexpanded\def\btxsetconcat #1{\currentbtxconcat #1\relax} \newconstant\currentbtxcount \unexpanded\def\btxsetcount #1{\currentbtxcount #1\relax} \def\currentbtxauthorvariant{normal} \unexpanded\def\btxlistreset {\let\currentbtxcombis \empty \let\currentbtxcategory \empty \let\currentbtxinternal \empty \let\currentbtxbacklink \empty \let\currentbtxbacktrace\empty \let\currentbtxlanguage \empty \let\currentbtxtag \empty \let\currentbtxdataset \empty} \unexpanded\def\btxcitereset % check for less .. not all resets needed {\let \currentbtxfirst \empty \let \currentbtxsecond \empty \let \currentbtxinternal \empty \let \currentbtxbacklink \empty \let \currentbtxbacktrace\empty % not used here \let \currentbtxlanguage \empty \let \currentbtxdataset \empty \let \currentbtxtag \empty \setconstant\currentbtxoverflow \zerocount \setconstant\currentbtxconcat \zerocount \setconstant\currentbtxcount \zerocount} %D Tracing \newconditional\c_btx_trace \installtextracker {btxrendering} {\settrue \c_btx_trace} {\setfalse\c_btx_trace} %D Rendering lists and citations. \unexpanded\def\startbtxrendering {\begingroup \dosingleempty\btx_start_rendering} \def\btx_start_rendering[#1]% {\edef\currentbtxrendering{#1}% \btxrenderingparameter\v!before} \unexpanded\def\stopbtxrendering {\btxrenderingparameter\v!after \endgroup} \unexpanded\def\btxtodo#1% {[#1]} %D Specific rendering definitions (like apa): \unexpanded\def\loadbtxdefinitionfile[#1]% {\ctxcommand{loadbtxdefinitionfile("#1")}} %D Lists: \newdimen\d_publ_number_width %newdimen\d_publ_number_distance \ifdefined\btxblock \else \newcount\btxblock \fi \btxblock\plusone \ifdefined\btxlistcounter \else \newcount\btxlistcounter \fi % maintained here, maybe in lua too? \ifdefined\btxcitecounter \else \newcount\btxcitecounter \fi % maybe pass this to lua \newtoks \everysetupbtxlistplacement % name will change \newtoks \everysetupbtxciteplacement % name will change % \def\publ_list_processor % bibref -> btx (old method, keep as reference) % {\ctxcommand{btxaddtolist("\currentbtxrendering",\currentlistindex,"btxref")}} \definelist % only used for selecting [\s!btx] \setuplist [\s!btx]% [\c!state=\v!start]% \appendtoks \ifx\currentbtxrenderingparent\empty \definebtxlist [\currentbtxrendering]% \else \definebtxlist [\currentbtxrendering]% [\currentbtxrenderingparent]% \fi \to \everydefinebtxrendering \unexpanded\def\btx_entry_inject {\begingroup \edef\currentbtxcategory{\btxfield{category}}% \ignorespaces \edef\currentbtxsetup{\s!btx:\currentbtxalternative:\currentbtxcategory}% \doifsetupselse\currentbtxsetup \btx_entry_inject_yes \btx_entry_inject_nop \endgroup} \def\btx_entry_inject_yes {\fastsetup\currentbtxsetup \removeunwantedspaces \ifx\currentbtxcombis\empty \else \btxrenderingparameter\c!separator \processcommacommand[\currentbtxcombis]\btx_entry_inject_combi \fi} \def\btx_entry_inject_nop {\tttf \getmessage\m!publications{12}{\currentbtxsetup}} \def\btx_entry_inject_combi#1% {\begingroup \def\currentbtxtag{#1}% \ignorespaces \fastsetup{\s!btx:\currentbtxalternative:\currentbtxcategory}% \removeunwantedspaces \endgroup} \unexpanded\def\completebtxrendering{\dodoubleempty\publ_place_list_complete} \unexpanded\def\placebtxrendering {\dodoubleempty\publ_place_list_standard} \let\completelistofpublications\completebtxrendering \let\placelistofpublications \placebtxrendering \def\publ_place_list_check_criterium {\edef\currentbtxcriterium{\btxrenderingparameter\c!criterium}% \v!cite will become \s!cite \ifx\currentbtxcriterium\empty \let\currentbtxcriterium\v!previous \else\ifx\currentbtxcriterium\v!cite \let\currentbtxcriterium\v!here \fi\fi} \def\publ_place_list_complete[#1][#2]% title might become obsolete, just headtext {\begingroup \edef\currentbtxrendering{#1}% \setupcurrentbtxrendering[#2]% \let\currentlist\s!btx \let\currentbtxlist\currentbtxrendering \publ_place_list_check_criterium \edef\currentbtxrenderingtitle{\btxrenderingparameter\c!title}% \ifx\currentbtxrenderingtitle\empty \normalexpanded{\startnamedsection[\v!chapter][\c!reference=\currentbtxrendering,\c!title={\headtext{\currentbtxrendering}}]}% \else \normalexpanded{\startnamedsection[\v!chapter][\c!reference=\currentbtxrendering,\c!title={\currentbtxrenderingtitle}]}% \fi \publ_place_list_indeed \stopnamedsection \endgroup} \def\publ_place_list_standard[#1][#2]% {\begingroup \edef\currentbtxrendering{#1}% \setupcurrentbtxrendering[#2]% \let\currentlist\s!btx \let\currentbtxlist\currentbtxrendering \publ_place_list_check_criterium \publ_place_list_indeed \endgroup} \def\publ_place_list_indeed {\startbtxrendering[\currentbtxrendering]% % \fastsetup{\btxrenderingparameter\c!setups}% specific initializations % \determinelistcharacteristics[\currentbtxrendering]% \btx_set_rendering_alternative \edef\currentbtxdataset{\btxrenderingparameter\c!dataset}% \let\currentlist\s!btx \let\currentbtxlist\currentbtxrendering \the\everysetupbtxlistplacement \forgetall % why not pass this with collect .. todo \startpacked[\v!blank]% % here we just collect items \ctxcommand{btxcollectlistentries { names = "btx", criterium = "\currentbtxcriterium", method = "\btxrenderingparameter\c!method", number = "\btxrenderingparameter\c!number", btxdataset = "\currentbtxdataset", keyword = "\btxrenderingparameter\c!keyword", sorttype = "\btxrenderingparameter\c!sorttype", repeated = "\btxrenderingparameter\c!repeat", }}% % next we analyze the width \ifx\currentbtxnumbering\empty \else \edef\p_width{\btxrenderingparameter\c!width}% \ifx\p_width\v!auto \scratchcounter\btxlistcounter \setbox\scratchbox\vbox \bgroup \settrialtypesetting \ctxcommand{btxfetchlistentries("\currentbtxdataset")}% \egroup \d_publ_number_width\wd\scratchbox \global\btxlistcounter\scratchcounter \letbtxlistparameter\c!width\d_publ_number_width \fi \fi % this actually typesets them \ctxcommand{btxflushlistentries("\currentbtxdataset")}% \stoppacked \stopbtxrendering \global\advance\btxblock\plusone} \def\currentbtxblock{\number\btxblock} \unexpanded\def\btxsetlanguage#1% {\def\currentbtxlanguage{#1}% \ifx\currentbtxlanguage\currentlanguage \else \setcurrentlanguage\currentmainlanguage\currentbtxlanguage \fi} % called at the lua end, for determining the width \unexpanded\def\btxchecklistentry {\begingroup % todo, switch to font \global\advance\btxlistcounter\plusone \hbox{\btx_reference_checked}% \par \endgroup} % called at the lua end, the real rendering \unexpanded\def\btxhandlelistentry {\begingroup \global\advance\btxlistcounter\plusone \let\currentlist\s!btx % probably obsolete here \startbtxlistentry\currentbtxrendering \btx_entry_inject \stopbtxlistentry \endgroup} \unexpanded\def\btxlistsetup#1% {\fastsetup{\s!btx:\s!list:#1}} \unexpanded\def\btx_reference_indeed {\begingroup \let\currentbtxlistvariant\currentbtxnumbering \btxlistvariantparameter\c!left \ctxcommand{btxlistvariant("\currentbtxdataset","\currentbtxblock","\currentbtxtag","\currentbtxnumbering","\number\btxlistcounter")}% some can go \btxlistvariantparameter\c!right \endgroup} \unexpanded\def\btx_reference_checked {\dontleavehmode\hbox\bgroup \btx_reference_indeed \egroup} \newcount\c_btx_list_reference \unexpanded\def\btx_list_reference_inject {\dontleavehmode\begingroup % no box \iftrialtypesetting\else \btx_list_reference_inject_now \fi \btx_reference_indeed \endgroup} \def\btx_list_reference_inject_now {\btx_trace_list_cross\empty\currentbtxbacktrace \global\advance\c_btx_list_reference\plusone \strc_references_direct_full_user {\s!btxset="\currentbtxdataset",\s!btxref="\currentbtxtag",\ifx\currentbtxbacklink\currentbtxbacktrace\s!btxint="\currentbtxbacklink"\else\s!btxbck="\currentbtxbacktrace"\fi}% {\s!btx::\v!list::\number\c_btx_list_reference}% {\number\btxlistcounter}} \unexpanded\def\btx_cite_reference_inject {\dontleavehmode \iftrialtypesetting \else \ifx\currentbtxbacklink\empty % can be made empty when combining author / year \else \btx_trace_list_cross\currentbtxbacklink\empty \normalexpanded{\writedatatolist[\s!btx][\s!btxset=\currentbtxdataset,\s!btxref=\currentbtxtag,\s!btxint=\number\currentbtxbacklink]}% % \c!location=\v!here \fi \fi} \let\btxcitereference\btx_cite_reference_inject \let\currentbtxnumbering\empty \appendtoks \edef\currentbtxnumbering{\btxrenderingparameter\c!numbering}% \letlistparameter\c!numbercommand\firstofoneargument % for the moment, no doubling needed \ifx\currentbtxnumbering\v!no \letlistparameter\c!textcommand\outdented % needed? we can use titlealign \letlistparameter\c!symbol \v!none \letlistparameter\c!aligntitle \v!yes \let\currentbtxnumbering\empty \else \letlistparameter\c!headnumber\v!always \fi \to \everysetupbtxlistplacement % \appendtoks % \edef\currentbtxcriterium{\btxrenderingparameter\c!criterium}% % \to \everysetupbtxlistplacement \unexpanded\def\btxflushauthor {\doifnextoptionalcselse\btx_flush_author_yes\btx_flush_author_nop} \def\btx_flush_author_yes[#1]{\btx_flush_author{#1}} \def\btx_flush_author_nop {\btx_flush_author{\btxlistvariantparameter\c!author}} \unexpanded\def\btx_flush_author#1#2% {\begingroup \edef\currentbtxfield{#2}% \let\currentbtxlistvariant\currentbtxfield \ctxcommand{btxauthor("\currentbtxdataset","\currentbtxtag","\currentbtxfield",{ combiner = "#1", kind = "list", % symbol = ".", etallimit = \number\btxlistvariantparameter\c!etallimit, etaldisplay = \number\btxlistvariantparameter\c!etaldisplay, })}% \endgroup} \unexpanded\def\btxflushauthorname {\btx_flush_author{name}} % #1 \unexpanded\def\btxflushauthornormal {\btx_flush_author{normal}} % #1 \unexpanded\def\btxflushauthornormalshort {\btx_flush_author{normalshort}} % #1 \unexpanded\def\btxflushauthorinverted {\btx_flush_author{inverted}} % #1 \unexpanded\def\btxflushauthorinvertedshort{\btx_flush_author{invertedshort}} % #1 \unexpanded\def\currentbtxciteauthor % always author {\begingroup \ctxcommand{btxauthor("\currentbtxdataset","\currentbtxtag","author",{ combiner = "\btxcitevariantparameter\c!authorconversion", kind = "cite", % symbol = ".", etallimit = \number\btxcitevariantparameter\c!etallimit, etaldisplay = \number\btxcitevariantparameter\c!etaldisplay, })}% \endgroup} \unexpanded\def\btxstartauthor{\begingroup} \unexpanded\def\btxstopauthor {\endgroup} \unexpanded\def\btxciteauthorsetup#1{\fastsetup{\s!btx:\s!cite:\s!author:#1}} \unexpanded\def\btxlistauthorsetup#1{\fastsetup{\s!btx:\s!list:\s!author:#1}} % \btxflushauthor{author} % \btxflushauthor{artauthor} % \btxflushauthor{editor} % % \btxflushauthor[name]{author} % \btxflushauthor[normal]{author} % \btxflushauthor[normalshort]{author} % \btxflushauthor[inverted]{author} % \btxflushauthor[invertedshort]{author} % \btxflushauthor{author} % \btxflushauthor{artauthor} % \btxflushauthor{editor} % % \btxflushauthor[name]{author} % \btxflushauthor[normal]{author} % \btxflushauthor[normalshort]{author} % \btxflushauthor[inverted]{author} % \btxflushauthor[invertedshort]{author} % Interaction: only list \newconditional\btxinteractive \unexpanded\def\btxdoifelseinteraction{\secondoftwoarguments} \appendtoks \iflocation \edef\p_interaction{\btxlistvariantparameter\c!interaction}% \ifx\p_interaction\v!stop \let\btxdoifelseinteraction\secondoftwoarguments \setfalse\btxinteractive \else \let\btxdoifelseinteraction\firstoftwoarguments \settrue\btxinteractive \fi \else \let\btxdoifelseinteraction\secondoftwoarguments \setfalse\btxinteractive \fi \to \everysetupbtxlistplacement \appendtoks \iflocation \edef\p_interaction{\btxcitevariantparameter\c!interaction}% \ifx\p_interaction\v!stop \let\btxdoifelseinteraction\secondoftwoarguments \setfalse\btxinteractive \else \let\btxdoifelseinteraction\firstoftwoarguments \settrue\btxinteractive \fi \else \let\btxdoifelseinteraction\secondoftwoarguments \setfalse\btxinteractive \fi \to \everysetupbtxciteplacement \appendtoks % for old times sake, for a while at least \let\maybeyear\gobbleoneargument \let\noopsort \gobbleoneargument \to \everysetupbtxlistplacement \appendtoks % for old times sake, for a while at least \let\maybeyear\gobbleoneargument \let\noopsort \gobbleoneargument \to \everysetupbtxciteplacement % till here \unexpanded\def\btxnumberedreference[#1]% \bibtexnumref (replaced by \cite[num]) {\dontleavehmode \begingroup \btxcitevariantparameter\v!left \penalty\plustenthousand % todo \ctxcommand{btxresolvelistreference("\currentbtxdataset","#1")}% todo: split dataset from #1, so another call \btxcitevariantparameter\v!right \endgroup} \appendtoks \doifnot{\btxrenderingparameter\c!continue}\v!yes {\global\btxlistcounter\zerocount}% \to \everysetupbtxlistplacement %D When a publication is cited, we need to signal that somehow. This is done with the %D following (not user) command. We could tag without injecting a node but this way %D we also store the location, which makes it possible to ask local lists. %D \macros{cite,nocite,citation,nocitation,usecitation} %D %D The inline \type {\cite} command creates a (often) short reference to a publication %D and for historic reasons uses a strict test for brackets. This means, at least %D in the default case that spaces are ignored in the argument scanner. The \type %D {\citation} commands is more liberal but also gobbles following spaces. Both %D commands insert a reference as well as a visual clue. %D %D The \type {no} commands all do the same (they are synonyms): they make sure that %D a reference is injected but show nothing. However, they do create a node so best %D attach them to some text in order to avoid spacing interferences. A slightly %D less efficient alternative is \type {\cite[none][tag]}. % [tags] % [settings|variant][tags] % [base::tags] % [settings|variant][base::tags] \unexpanded\def\btxcite {\dontleavehmode \begingroup \strictdoifnextoptionalelse\publ_cite_tags_options\publ_cite_tags_indeed} \unexpanded\def\publ_cite_tags_indeed#1% {\letinteractionparameter\c!style\empty \edef\currentbtxcitevariant{\btxcitevariantparameter\c!alternative}% \edef\currentbtxcitetag{#1}% \the\everysetupbtxciteplacement \publ_cite_variant \endgroup} \let\publ_citation_tags_indeed\publ_cite_tags_indeed \unexpanded\def\publ_cite_tags_options[#1]% {\strictdoifnextoptionalelse{\publ_cite_tags_options_indeed{#1}}{\publ_cite_tags_indeed{#1}}} \unexpanded\def\publ_cite_tags_options_indeed#1[#2]% {\edef\currentbtxcitetag{#2}% \doifassignmentelse{#1}\publ_cite_tags_settings_indeed\publ_cite_tags_variants_indeed{#1}} \def\publ_cite_tags_settings_indeed#1% {\letinteractionparameter\c!style\empty %\letinteractionparameter\c!color\empty \letdummyparameter\c!before \empty \letdummyparameter\c!after \empty \letdummyparameter\c!extras \empty \letdummyparameter\c!alternative\empty \getdummyparameters[#1]% \edef\p_alternative{\dummyparameter\c!alternative}% \ifx\p_alternative\empty \edef\currentbtxcitevariant{\btxcitevariantparameter\c!alternative}% \else \let\currentbtxcitevariant\p_alternative \fi \setupcurrentbtxcitevariant[#1]% \edef\p_extras{\dummyparameter\c!extras}% \ifx\p_extras\empty \else \edef\p_right{\btxcitevariantparameter\c!right}% \ifx\p_right\empty \else \setexpandedbtxcitevariantparameter\p_right{\p_extras\p_right}% \fi \fi \edef\p_before{\dummyparameter\c!before}% \edef\p_after {\dummyparameter\c!after}% \the\everysetupbtxciteplacement \ifx\p_before\empty \else \p_before \space \fi \publ_cite_variant \ifx\p_after\empty \else \optionalspace \p_after \fi \endgroup} \def\publ_cite_tags_variants_indeed#1% {\letinteractionparameter\c!style\empty \edef\currentbtxcitevariant{#1}% \the\everysetupbtxciteplacement \publ_cite_variant \endgroup} \newconditional\btxcitecompress \def\publ_cite_variant {\begingroup \publ_cite_handle_variant_indeed[\currentbtxcitetag]} \unexpanded\def\publ_cite_handle_variant#1% {\begingroup \edef\currentbtxcitevariant{#1}% \the\everysetupbtxciteplacement \dosingleargument\publ_cite_handle_variant_indeed} \def\publ_cite_handle_variant_indeed[#1]% {\usebtxcitevariantstyleandcolor\c!style\c!color \letbtxcitevariantparameter\c!alternative\currentbtxcitevariant \btxcitevariantparameter\v!left \ctxcommand{btxhandlecite{% dataset = "\currentbtxdataset",% reference = "#1",% markentry = \iftrialtypesetting false\else true\fi,% variant = "\currentbtxcitevariant",% sorttype = "\btxcitevariantparameter\c!sorttype",% compress = "\btxcitevariantparameter\c!compress",% author = "\btxcitevariantparameter\c!author",% }}% \btxcitevariantparameter\v!right \ctxcommand{flushmarked()}% \endgroup} \unexpanded\def\btxcitation {\dontleavehmode \begingroup \dodoubleempty\publ_citation} \def\publ_citation[#1][#2]% could be made more efficient but not now {\ifsecondargument \publ_cite_tags_options_indeed{#1}[#2]% \else \publ_cite_tags_indeed{#1}% \fi} \unexpanded\def\btxnocite {\dosingleempty\publ_cite_no} \unexpanded\def\publ_cite_no[#1]% {\iftrialtypesetting \else \ctxcommand{btxhandlenocite{% dataset = "\currentbtxdataset",% reference = "#1",% markentry = true,% }}% % \ctxcommand{flushmarked()}% \fi} \unexpanded\def\btxmissing#1% {{\tttf<#1>}} %D Compatibility: \let\cite \btxcite \let\citation \btxcitation \let\nocite \btxnocite \let\nocitation \btxnocite \let\usepublication\btxnocite %D Cite helpers: \unexpanded\def\btxcitesetup#1% {\fastsetup{\s!btx:\s!cite:#1}} % no \btxcitereset as we loose dataset and such \unexpanded\def\btxsetfirst {\def\currentbtxfirst} \unexpanded\def\btxsetsecond {\def\currentbtxsecond} \unexpanded\def\btxsettag {\def\currentbtxtag} \unexpanded\def\btxsetdataset {\def\currentbtxdataset} %unexpanded\def\btxsetlanguage {\def\currentbtxlanguage} \unexpanded\def\btxsetinternal {\def\currentbtxinternal} \unexpanded\def\btxsetcount #1{\setconstant\currentbtxcount #1\relax} \unexpanded\def\btxsetconcat #1{\setconstant\currentbtxconcat #1\relax} \unexpanded\def\btxsetoverflow #1{\setconstant\currentbtxoverflow#1\relax} \unexpanded\def\btxstartsubcite#1% #1 can go {\begingroup \btxcitereset % todo: limited set \def\currentbtxcitevariant{#1}% \btxcitevariantparameter\c!left \relax} \unexpanded\def\btxstopsubcite {\relax \btxcitevariantparameter\c!right \endgroup} \let\btxstartcite \begingroup \let\btxstopcite \endgroup \let\btxstartciteauthor\begingroup \let\btxstopciteauthor \endgroup %D Whatever helpers: \unexpanded\def\btxsingularplural#1{\ctxcommand{btxsingularorplural("\currentbtxdataset","\currentbtxtag","#1")}} \unexpanded\def\btxoneorrange #1{\ctxcommand{btxoneorrange("\currentbtxdataset","\currentbtxtag","#1")}} \unexpanded\def\btxfirstofrange #1{\ctxcommand{btxfirstofrange("\currentbtxdataset","\currentbtxtag","#1")}} \let\btxsingularorplural\btxsingularplural %D Loading variants: \let\currentbtxrenderingdefinition\empty \let\currentbtxalternative \empty \unexpanded\def\startbtxrenderingdefinitions[#1]% {\pushmacro\currentbtxrenderingdefinition \edef\currentbtxrenderingdefinition{#1}% \letvalue{\??btxrenderingdefinition\currentbtxrenderingdefinition}\currentbtxrenderingdefinition} \unexpanded\def\stopbtxrenderingdefinitions {\popmacro\currentbtxrenderingdefinition} \def\btx_set_rendering_alternative {\edef\currentbtxalternative{\btxrenderingparameter\c!alternative}% \ifcsname\??btxrenderingdefinition\currentbtxalternative\endcsname % maybe fall back on apa ? \else \showmessage\m!publications{14}{\currentbtxalternative}% \fi} \appendtoks \loadbtxdefinitionfile[\btxrenderingparameter\c!alternative] \to \everysetupbtxrendering \stopcontextdefinitioncode %D Defaults: \setupbtxrendering [\c!dataset=\v!standard, \c!repeat=\v!no, \c!continue=\v!no, \c!method=\v!global, % \c!setups=btx:\btxrenderingparameter\c!alternative:initialize, % not the same usage as cite ! \c!alternative=apa, \c!sorttype=, \c!criterium=\v!text, \c!refcommand=authoryears, % todo \c!numbering=\v!yes, % \c!autohang=\v!no, % not used \c!width=\v!auto, \c!separator={; }, \c!distance=1.5\emwidth] \definebtxrendering [\v!standard] \setupbtxcitevariant [\c!interaction=\v!start, % \c!setups=btx:cite:initialize, \c!alternative=num, \c!authorconversion=\v!normal, \c!andtext={ \btxlabeltext{and} }, \c!otherstext={ \btxlabeltext{others}}, \c!pubsep={, }, \c!lastpubsep={ \btxlabeltext{and} }, \c!finalpubsep={ \btxlabeltext{and} }, \c!compress=\v!no, \c!inbetween={ }, \c!range=\endash, \c!left=, \c!middle=, \c!right=] % \c!authorconversion=\v!normal \definebtxcitevariant [author] [%c!sorttype=, \c!left={(}, \c!middle={, }, \c!right={)}] \definebtxcitevariant [authornum] [author] [\c!inbetween={ }] \definebtxcitevariant [authoryear] [\c!compress=\v!yes, \c!inbetween={, }, \c!left={(}, \c!middle={, }, \c!right={)}] \definebtxcitevariant [authoryears] [authoryear] \definebtxcitevariant [author:num] [authornum] [\c!left={[}, \c!right={]}] \definebtxcitevariant [author:year] [authoryear] [\c!left=, \c!right=] % \definebtxcitevariant % [author:years] % [authoryears] % [\c!left=, % \c!right=] \definebtxcitevariant [author:years] [author:year] \definebtxcitevariant [year] [\c!left={(}, \c!middle={, }, % is middle used? \c!right={)}] \definebtxcitevariant [tag] [\c!left={[}, \c!middle={, }, \c!right={]}] \definebtxcitevariant [key] [tag] \definebtxcitevariant [serial] [\c!left={[}, \c!middle={, }, \c!right={]}] \definebtxcitevariant [page] [\c!left={[}, \c!middle={, }, \c!right={]}] \definebtxcitevariant [short] [\c!left={[}, \c!middle={, }, \c!right={]}] \definebtxcitevariant [category] [\c!left={[}, \c!middle={, }, \c!right={]}] \definebtxcitevariant [type] [category] \definebtxcitevariant [doi] [\c!left={[}, \c!middle={, }, \c!right={]}] \definebtxcitevariant [url] [\c!left={[}, \c!middle={, }, \c!right={]}] \definebtxcitevariant [page] [\c!left=, \c!middle={, }, \c!right=] \definebtxcitevariant [num] [\c!compress=\v!yes, \c!left={[}, \c!middle={, }, \c!right={]}] \setupbtxlistvariant [\c!namesep={, }, \c!lastnamesep={ \btxlabeltext{and} }, \c!finalnamesep={ \btxlabeltext{and} }, \c!firstnamesep={ }, \c!juniorsep={ }, \c!vonsep={ }, \c!initialsep={ }, \c!surnamesep={, }, \c!surnameinitialsep={, }, \c!surnamefirstnamesep={, }, \c!etallimit=5, \c!etaldisplay=5, \c!etaltext={ \btxlabeltext{others}}, \c!monthconversion=\v!number, \c!authorconversion=\v!normal] \definebtxlistvariant [author] [author=invertedshort] % we could also do this in the apa style itself \definebtxlistvariant [editor] [author] \definebtxlistvariant [artauthor] [author] % Not that efficient but ... \setupbtxcitevariant [\c!namesep=\btxlistvariantparameter\c!namesep, \c!lastnamesep=\btxlistvariantparameter\c!lastnamesep, \c!finalnamesep=\btxlistvariantparameter\c!finalnamesep, \c!firstnamesep=\btxlistvariantparameter\c!firstnamesep, \c!juniorsep=\btxlistvariantparameter\c!juniorsep, \c!vonsep=\btxlistvariantparameter\c!vonsep, \c!initialsep=\btxlistvariantparameter\c!initialsep, \c!surnamesep=\btxlistvariantparameter\c!surnamesep, \c!surnameinitialsep=\btxlistvariantparameter\c!surnameinitialsep, \c!surnamefirstnamesep=\btxlistvariantparameter\c!surnamefirstnamesep, \c!etallimit=\btxlistvariantparameter\c!etallimit, \c!etaldisplay=\btxlistvariantparameter\c!etaldisplay, \c!etaltext=\btxlistvariantparameter\c!etaltext, \c!monthconversion=\btxlistvariantparameter\c!monthconversion, \c!authorconversion=\v!name] % Do we want these in the format? Loading them delayed is somewhat messy. \loadbtxdefinitionfile[commands] \loadbtxdefinitionfile[definitions] \loadbtxdefinitionfile[cite] \loadbtxdefinitionfile[list] \loadbtxdefinitionfile[author] \loadbtxdefinitionfile[apa] \protect