Date: Fri, 2 Mar 90 18:54:04 EST >From: toms@ncifcrf.gov (Tom Schneider) Subject: BiBTeX Switches Keywords: BibTeX, switches > I read with interest Tom Scheider's article in TeXhax Vol 90, Issue 22 about > having a "flip switch" in BibTeX which you can invoke from the source file > with \nocite{TitlesOn}. I didn't know this was possible. Can Tom or someone > else post a short piece of BibTeX code fragment showing how it's implemented? > Charles Karney > Plasma Physics Laboratory E-mail: Karney@ccc.nmfecc.gov The basic idea is that, before doing anything else, BiBTeX can run through the references to find ones with special key strings like "TitlesOn". This is used to determine the state of a boolean variable, "givetitles". Then the printing of the titles becomes dependent on the state of this variable. Finally, one must avoid printing the article that has the citation key "TitlesOn"! I have cut out the relevant parts of the code and put them together below. (This is only to show how the method works.) *********************************************************** % Define the boolean variable, "givetitles" (along with others) INTEGERS { output.state before.all mid.sentence after.sentence after.block docomma givetitles } % Set the value of "givetitles" FUNCTION {init.toggle.switches} {% set switches for controlling the output! #0 'givetitles := % if it is 0 then don't give titles, otherwise do them. } *********************************************************** FUNCTION {check.for.titlecommand} % go through an entry and see if it has the key % 'TitlesOn'. If this is found, then do titles! { % "|" label "|" * * write$ newline$ % gives: |Arrhenius {\em et~al.}, 1986| % "|" cite$ "|" * * write$ newline$ % gives: |Arrhenius1986| % so cite$ is the thing I want to detect, not label$... cite$ "TitlesOn" = { % got it! "Titles Will Be Printed" warning$ #1 'givetitles := % give titles! } 'skip$ if$ } EXECUTE {init.toggle.switches} % initialize the toggle ITERATE {check.for.titlecommand} % see if it should be flipped *********************************************************** % In the actual title printing function, if givetitles is 1, % the title will be printed, otherwise not FUNCTION {format.title} { title empty$ { "" } { % decide whether to give the title or not givetitles #1 = { title "t" change.case$ } % produce the title { title pop$ "" } % don't produce the title if$ } if$ } *********************************************************** % When printing articles, avoid printing the TitlesOn article! FUNCTION {article} { cite$ "TitlesOn" = 'skip$ % Don't write out an article of this kind, it's a toggle switch! { % remainder of the article function continues here! } } *********************************************************** In the bibliography (.bib file) one has: @article{TitlesOn, author = "TitlesOn", title = "TitlesOn", journal = "TitlesOn", volume = "TitlesOn", year = "1900", comment = "If this is nocited, then titles will be turned on in JMB style"} *********************************************************** In the LaTeX file (.tex) one simply does: text text text \cite{TitlesOn}. *********************************************************** Notice that any citation of TitlesOn anywhere in the LaTeX file will turn titles on for all references. Tom Schneider National Cancer Institute Laboratory of Mathematical Biology Frederick, Maryland 21701-1013 toms@ncifcrf.gov