[9c88d1e] | 1 | %% Author: Jose Alberto <alberto@cs.umd.edu> |
---|
| 2 | %% Original source: comp.text.tex <ALBERTO.91Sep7174145@yamuna.cs.umd.edu> |
---|
| 3 | %% Date: 7 Sep 91 21:41:45 GMT |
---|
| 4 | %% Text of accompanying post follows \endinput |
---|
| 5 | %% |
---|
| 6 | %% BIBUNITS.STY by Jose Alberto Fernandez (alberto@cs.umd.edu) |
---|
| 7 | %% |
---|
| 8 | %% BIBUNITS is a style to generate separate bibliographies for |
---|
| 9 | %% different units (parts) of the text (currently only one of |
---|
| 10 | %% chapters, sections or bibunit-environments). |
---|
| 11 | %% The style will separate the citations of each unit of text into a |
---|
| 12 | %% separate file to be processed by bibtex. The global bibliography |
---|
| 13 | %% section produced by LATEX also can appear in the document and |
---|
| 14 | %% citations can be placed in both at the same time. |
---|
| 15 | %% |
---|
| 16 | %% Use the \bibliographyunit[<unit>] (<unit> = \chapter, \section) to |
---|
| 17 | %% select how the references will be generated. (For every chapter or |
---|
| 18 | %% for every section). Use \bibliographyunit with no arguments to |
---|
| 19 | %% deactivate bibliographyunits. By default citations will only appear |
---|
| 20 | %% in the local bibliography. WARNING: By default \bibliographyunit is |
---|
| 21 | %% in a deactivated state. |
---|
| 22 | %% |
---|
| 23 | %% If \bibliographyunit is active the \bibliography{bibtex-files} and |
---|
| 24 | %% \bibliographystyle{style} commands also specify the bibtex-files |
---|
| 25 | %% and style to be used by default in the local units. The commands |
---|
| 26 | %% \bibliography*{<bibtex-files>} and \bibliographystyle*{<style>} |
---|
| 27 | %% specify the defaults for BIBUNITS and not generate any information |
---|
| 28 | %% for the global bibliography. WARNING: This values are taken as |
---|
| 29 | %% defaults only when executed after activate \bibliographyunit |
---|
| 30 | %% |
---|
| 31 | %% The environment \begin{bibunit}[<style>] .. \end{bibunit} allows |
---|
| 32 | %% the creation of a unit while \bibliographyunit is not active. The |
---|
| 33 | %% optional parameter <style> specifies a style for the biblography |
---|
| 34 | %% different from the default if any. WARNING: The use of this |
---|
| 35 | %% environment while \bibliographyunit is active can produce extrange |
---|
| 36 | %% results. Note that default style and bibtex-files only exist if |
---|
| 37 | %% specified while \bibliographyunit was active. |
---|
| 38 | %% |
---|
| 39 | %% Use \cite and \nocite to generate citations. \cite* and \nocite* |
---|
| 40 | %% can be use to generate citations to be added in both the local and |
---|
| 41 | %% global bibliography while inside a unit. |
---|
| 42 | %% |
---|
| 43 | %% You must insert the command \putbib[<bibtex-files>] before the end |
---|
| 44 | %% of each <unit> in the location where you want the bibliography to |
---|
| 45 | %% be inserted. If the optional argument is ommited, \putbib uses the |
---|
| 46 | %% default bibtex-files if any. |
---|
| 47 | %% |
---|
| 48 | %% BIBTEX processing: |
---|
| 49 | %% For each <unit>, in sequence, there is now a corresponding file |
---|
| 50 | %% \jobname.\the\@bibunitauxcnt.aux that need to be compiled though |
---|
| 51 | %% BIBTEX as well as the \jobname.aux that generates the global |
---|
| 52 | %% database. |
---|
| 53 | %% |
---|
| 54 | %% Suppose your document is foo.tex, you must now invoke bibtex not only |
---|
| 55 | %% on foo, but also on foo.1, ..., foo.n given that there are n |
---|
| 56 | %% different <units> with separate bibliography. |
---|
| 57 | |
---|
| 58 | \newwrite\@bibunitaux %File desc. |
---|
| 59 | \newcount\@bibunitauxcnt \@bibunitauxcnt = 0 %Units cnt. |
---|
| 60 | \newif\if@localcite %Local/Global cite |
---|
| 61 | \def\@localcitedflt{\@localcitetrue} \@localcitedflt |
---|
| 62 | % |
---|
| 63 | % \cite definition |
---|
| 64 | % |
---|
| 65 | \let\REALcite\cite |
---|
| 66 | \def\NEWcite{% |
---|
| 67 | \@ifstar{\@localcitefalse\REALcite}% |
---|
| 68 | {\@localcitetrue\REALcite}} |
---|
| 69 | % |
---|
| 70 | % \@cite new definition |
---|
| 71 | \let\REAL@citex\@citex |
---|
| 72 | \def\NEW@citex[#1]#2{\if@filesw |
---|
| 73 | \immediate\write\@bibunitaux{\string\citation{#2}}\fi |
---|
| 74 | \if@localcite |
---|
| 75 | \if@filesw |
---|
| 76 | \@fileswfalse\REAL@citex[#1]{#2}\@fileswtrue |
---|
| 77 | \else\REAL@citex[#1]{#2}\fi |
---|
| 78 | \else\REAL@citex[#1]{#2}\fi |
---|
| 79 | \@localcitedflt} |
---|
| 80 | % |
---|
| 81 | % \nocite definition |
---|
| 82 | % |
---|
| 83 | \let\REALnocite\nocite |
---|
| 84 | \def\NEWnocite{% |
---|
| 85 | \@ifstar{\@localcitefalse\@NEWnocite}% |
---|
| 86 | {\@localcitetrue\@NEWnocite}} |
---|
| 87 | \def\@NEWnocite#1{\@bsphack |
---|
| 88 | \if@filesw |
---|
| 89 | \immediate\write\@bibunitaux{\string\citation{#1}}\fi |
---|
| 90 | \@esphack |
---|
| 91 | \if@localcite\else\REALnocite{#1}\fi\@localcitedflt} |
---|
| 92 | % |
---|
| 93 | % \bibliography definition |
---|
| 94 | % |
---|
| 95 | \def\@bibdata{} %Data files store |
---|
| 96 | \let\REALbibliography\bibliography |
---|
| 97 | \def\NEWbibliography{% |
---|
| 98 | \@ifstar{\@localcitetrue\@NEWbibliography}% |
---|
| 99 | {\@localcitefalse\@NEWbibliography}} |
---|
| 100 | \def\@NEWbibliography#1{% |
---|
| 101 | \if@filesw |
---|
| 102 | \immediate\write\@auxout{\string\gdef\string\@bibdata{#1}}\fi |
---|
| 103 | \if@localcite\else\REALbibliography{#1}\fi\@localcitedflt} |
---|
| 104 | % |
---|
| 105 | % \bibliographystyle definition |
---|
| 106 | % |
---|
| 107 | \def\@bibstyle{} %Style store |
---|
| 108 | \let\REALbibliographystyle\bibliographystyle |
---|
| 109 | \def\NEWbibliographystyle{% |
---|
| 110 | \@ifstar{\@localcitetrue\@NEWbibliographystyle}% |
---|
| 111 | {\@localcitefalse\@NEWbibliographystyle}} |
---|
| 112 | \def\@NEWbibliographystyle#1{% |
---|
| 113 | \if@filesw |
---|
| 114 | \immediate\write\@auxout{\string\gdef\string\@bibstyle{#1}}\fi |
---|
| 115 | \if@localcite\else\REALbibliographystyle{#1}\fi\@localcitedflt} |
---|
| 116 | % |
---|
| 117 | % \begin{bibunit} .. \end{bibunit} definition |
---|
| 118 | % |
---|
| 119 | \def\bibunit{\global\advance\@bibunitauxcnt 1 |
---|
| 120 | \global\let\cite\NEWcite |
---|
| 121 | \global\let\@citex\NEW@citex |
---|
| 122 | \global\let\nocite\NEWnocite |
---|
| 123 | \if@filesw |
---|
| 124 | \immediate\openout\@bibunitaux \jobname.\the\@bibunitauxcnt.aux |
---|
| 125 | \fi\@ifnextchar[{\@bibunitx}{\@bibunitx[\@bibstyle]}% |
---|
| 126 | } |
---|
| 127 | \def\@bibunitx[#1]{\if@filesw |
---|
| 128 | \immediate\write\@bibunitaux{\string\bibstyle{#1}}\fi} |
---|
| 129 | \def\endbibunit{% |
---|
| 130 | \global\let\cite\REALcite |
---|
| 131 | \global\let\@citex\REAL@citex |
---|
| 132 | \global\let\nocite\REALnocite |
---|
| 133 | \if@filesw |
---|
| 134 | \immediate\closeout\@bibunitaux\fi} |
---|
| 135 | % |
---|
| 136 | % \chapter or \section substituting definition |
---|
| 137 | % |
---|
| 138 | \let\OLD@bibunit\@gobble |
---|
| 139 | \def\@bibunit{\endbibunit\bibunit\OLD@bibunit} |
---|
| 140 | \def\@endbibunit{} |
---|
| 141 | % |
---|
| 142 | % \bibliographyunit definition |
---|
| 143 | % |
---|
| 144 | \def\bibliographyunit{\@endbibunit |
---|
| 145 | \@ifnextchar[{\@bibliographyunit}{% |
---|
| 146 | \global\let\OLD@bibunit\@gobble |
---|
| 147 | \global\let\bibliography\REALbibliography |
---|
| 148 | \global\let\bibliographystyle\REALbibliographystyle |
---|
| 149 | \endbibunit |
---|
| 150 | \gdef\@endbibunit{}}} |
---|
| 151 | \def\@bibliographyunit[#1]{% |
---|
| 152 | \global\let\bibliography\NEWbibliography |
---|
| 153 | \global\let\bibliographystyle\NEWbibliographystyle |
---|
| 154 | \global\let\OLD@bibunit#1 |
---|
| 155 | \global\let#1\@bibunit |
---|
| 156 | \gdef\@endbibunit{\global\let#1\OLD@bibunit}} |
---|
| 157 | % |
---|
| 158 | % \putbib definition |
---|
| 159 | % |
---|
| 160 | \def\putbib{\@ifnextchar[{\@putbib}{\@putbib[\@bibdata]}} |
---|
| 161 | \def\@putbib[#1]{\if@filesw |
---|
| 162 | \immediate\write\@bibunitaux{\string\bibdata{#1}}\fi |
---|
| 163 | \@input{\jobname.\the\@bibunitauxcnt.bbl}} |
---|
| 164 | |
---|
| 165 | \endinput |
---|
| 166 | |
---|
| 167 | In article <1991Aug29.012118.8708@cs.cornell.edu> rjohnson@cs.cornell.edu (Richard C. Johnson) writes: |
---|
| 168 | |
---|
| 169 | Is there a way to make a multisection bibliography using LaTex and Bibtex? |
---|
| 170 | Ideally, I'd like to be able to do something like: |
---|
| 171 | |
---|
| 172 | \section{VLIW Architectures} |
---|
| 173 | \nocite{Colwell87} |
---|
| 174 | \nocite{ ...etc... |
---|
| 175 | |
---|
| 176 | \section{Trace Scheduling} |
---|
| 177 | \nocite{Fisher81} |
---|
| 178 | \nocite{ ...etc... |
---|
| 179 | |
---|
| 180 | and end up with a multisection bibliography. Any suggestions other than |
---|
| 181 | resorting to using \bibitem's out of the .bbl file? Thanks in advance. |
---|
| 182 | |
---|
| 183 | Richard Johnson rjohnson@cs.cornell.edu |
---|
| 184 | |
---|
| 185 | I created a style called bibunits.sty that allow that some other |
---|
| 186 | things more. You can specify if you want bibliografy by chapters, |
---|
| 187 | sections or by your own subdivision. You can also specify if you want |
---|
| 188 | that all the reference be callected ALSO in a global bibliography or |
---|
| 189 | not. |
---|
| 190 | |
---|
| 191 | Here is the style, have fun. |
---|
| 192 | |
---|
| 193 | -- |
---|
| 194 | :/ \ Jose Alberto Fernandez R | INTERNET: alberto@cs.umd.edu |
---|
| 195 | :| o o | Dept. of Computer Sc. | BITNET: alberto@cs.umd.edu |
---|
| 196 | :| ^ | University of Maryland | UUCP: {...}!mimsy!alberto |
---|
| 197 | :\ \_/ / College Park, MD 20742 | |
---|