[texhax] Reverse numbering Bibliography

Steve Schwartz s.schwartz at imperial.ac.uk
Tue Sep 25 17:49:41 CEST 2007


Sonny,

I had to do something similar recently, namely to count the number of
names and use that count in my text. The names were in an inputted file,
each introduced by a command that incremented a counter (you have
biblabel). All that was then needed was to get the final value of that
counter into the .aux file and it became available for use for the next
latex pass.

Here's what I did, which (a) may not be elegant and (b) would need to be
modified for your use:

Firstly, to get things out into the aux file requires a command, in the
preamble of the main .tex file (or you could just use @auxout surrounded
by \makeatletter, etc. where you need/use it - I like to keep anything
potentially dangerous like this in my preamble where I can see it):

%%%%%%%%%%%%%%% preamble material %%%%%%%%%%%%%%%%%
\newcounter{nnames}   % my counter

% define a command to write to your auxfile available for your use
\makeatletter
  \def\writetoaux#1{\protected at write\@auxout{}{#1}}
\makeatother

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

then where the file is input:

% note: at the top of signatures.tex is a 
% \setcounter{nnames}{0}
% to restart the count for each pass

\input{signatures.tex}  % each name has a command that increments nnames
\writetoaux{\protect\setcounter{nnames}{\arabic{nnames}}}

This generates a line like:

\setcounter {nnames}{372}

in my .aux file.

With the above, your entire latex document knows about a counter nnames
that has one of two values:

Before signatures.tex is input, it's the count it had from the previous
pass.

After signatures.tex it will be the count from the current pass.

So, I THINK you could achieve what you need by 

1  allocating  new counter, say totalbibcount, in your preamble
Then in your code fragment below
2  set your pointnumber equal to totalbibcount
3  reset totalbibcount to zero
4  renew your biblabel to increment totalbibcount as well as decrement
pointnumber
5  input your bbl
6  write out totalbibcount to the aux file.

Theoretically speaking, this should work :-)

HTH
Steve

On Tue, 2007-09-25 at 22:39 +0800, Duc Son Pham wrote:
> Solution: Suppose the total number of references in myfile.bbl is 100,
> then
> 
> ===================================================
> \newcounter{pointnumber}
> \setcounter{pointnumber}{101}
> \makeatletter
> \renewcommand*{\@biblabel}[1]{[\thepointnumber
> \addtocounter{pointnumber}{-1}]}
> \makeatother
> \input{myfile.bbl}
> ====================================================
> 
> The only disadvantage is that I need to supply the number 101
> manually.
> 
> Someone out there might have a better solution? 
-- 
+-------------------------------------------------------------------+
Professor Steven J Schwartz      Phone: +44-(0)20-7594-7660
Space and Atmospheric Physics    Fax:   +44-(0)20-7594-7772
The Blackett Laboratory          E-mail: s.schwartz at imperial.ac.uk
Imperial College London          Office: Huxley 6M70 
London SW7 2BW, U.K.             Web: http://www.sp.ph.ic.ac.uk/~sjs
+-------------------------------------------------------------------+



More information about the texhax mailing list