natbib and references in TOC

natbib and references in TOC

Post by Mary Ellen Fost » Thu, 29 Jun 2000 04:00:00



I want to both use natbib and have the bibliography appear in the table of
contents... I know that tocbibind will put the bibliography into the TOC if
you put:
    \usepackage[nottoc,notlof,notlot]{tocbibind}
into the preamble. Of course, it does this by changing the bibliography
environment. Unfortunately, natbib does its own changes to the bibliography
environment too, and if I load them in the "wrong" order then the
bibliography changes won't happen.

Of course, you say, why not just load natbib and then tocbibind? Well, I
would if I could, but here's the situation:

- I'm working on a University of Edinburgh thesis class
- One of the university thesis regulations is that the bibliography must
  appear in the table of contents, so I'd like to build that into the class.
- However, if I put any sort of thebibliography-changing commands into the
  class itself, then my \usepackage{natbib} will stomp on those changes and
  renew the environment itself.

*sigh*. So as I see it, I've got two options:
- Explicitly RequirePackage natbib in the thesis class before loading
  tocbibind or otherwise altering thebibliography... but then if the user
  wants to load natbib again with different options, aren't they then
  screwed?
- Put an \addcontentsline... into a skeleton sample file that will be
  available with the class and hope that people don't take it out.

Anyone got any other suggestions?

Thanks,

MEF

--
Mary Ellen Foster, School of Cognitive Science, University of Edinburgh

--------------------- Law of Software Envelopment ---------------------
        Every program attempts to expand until it can read mail.

 
 
 

natbib and references in TOC

Post by Peter Wilso » Thu, 29 Jun 2000 04:00:00



> I want to both use natbib and have the bibliography appear in the table of
> contents... I know that tocbibind will put the bibliography into the TOC if
> you put:
>     \usepackage[nottoc,notlof,notlot]{tocbibind}
> into the preamble. Of course, it does this by changing the bibliography
> environment. Unfortunately, natbib does its own changes to the bibliography
> environment too, and if I load them in the "wrong" order then the
> bibliography changes won't happen.

> Of course, you say, why not just load natbib and then tocbibind? Well, I
> would if I could, but here's the situation:

> - I'm working on a University of Edinburgh thesis class
> - One of the university thesis regulations is that the bibliography must
>   appear in the table of contents, so I'd like to build that into the class.
> - However, if I put any sort of thebibliography-changing commands into the
>   class itself, then my \usepackage{natbib} will stomp on those changes and
>   renew the environment itself.

> *sigh*. So as I see it, I've got two options:
> - Explicitly RequirePackage natbib in the thesis class before loading
>   tocbibind or otherwise altering thebibliography... but then if the user
>   wants to load natbib again with different options, aren't they then
>   screwed?
> - Put an \addcontentsline... into a skeleton sample file that will be
>   available with the class and hope that people don't take it out.

> Anyone got any other suggestions?

    It appears that you are the author of the class, which does give you
some advantages. I think that this will work, without having to use
anything from tocbibind, and also hopefully apply to any bibliography
environment. I'll assume that the class supports chapters and the
bibliography heading is not numbered. In your class file put:
\AtBeginDocument{%

Quote:}

where Bibname is the heading text for the bibliography. (You might have
to throw in a \protect or two, but try it first). The incantation could
be initially put into the preamble of a test document to get it working
before adding it to the .cls file (don't forget \makeatletter, etc).

    The idea is that at the \begin{document}, after all packages have
been loaded, that the command \addcontentsline{toc}{chapter}{Bibname} is
appended to the then current definition of \bibliography. It should also
ensure that the ToC addition occurs on the same page as the start of the
bibliography.

    This is a trick I have only learned recently, but it is limited in
that you can only add stuff to a pre-existing macro, not change any

internal kernel command, and could be changed at any time. I am
contemplating producing a package for doing this kind of thing.

Peter W.


 
 
 

natbib and references in TOC

Post by Mary Ellen Fost » Fri, 30 Jun 2000 04:00:00



Quote:> I want to both use natbib and have the bibliography appear in the table of
> contents...

I realised that I got a bit too specific in asking this question. What I
should have asked was: is there a way to add some text to a macro without
just copying the standard definition from report.cls or whatever and adding
your bit onto it. The answer is: yes. :-)

Thanks to Peter Wilson, I got put on the right track. His suggestion of

nice with macros that take arguments. But when I searched dejanews, I came
across a technique that does work. In my class file, I put:

    \AtBeginDocument{%
        \expandafter\def\expandafter\thebibliography\expandafter%
            #\expandafter1\expandafter{\thebibliography{#1}%
            {\addcontentsline{toc}{chapter}{\bibname}}%
            \markboth{\bibname}{\bibname}}}

I didn't want to play with \bibliography because then this would only kick
in if the person using the class used bibtex; this way, if they explicitly
use a \begin{thebibliography}...\end{thebibliography} the commands will
still get added. So now the bibliography appears in the TOC and puts the
right marks in for the headers, however any other packages decide to futz
with the bibliography environment.

Here's a reference to the dejanews article that I got the above out of:
    http://www.deja.com/[ST_rn=ps]/getdoc.xp?AN=635095381

Thanks for the quick and helpful responses!

MEF

--
Mary Ellen Foster, School of Cognitive Science, University of Edinburgh

--------------------- Law of Software Envelopment ---------------------
        Every program attempts to expand until it can read mail.

 
 
 

1. custom-bib & natbib: Stop numbering of references list?

Hello,

I'd like to stop natbib from creating a numbered references (bibliography)
list.
I created a citation style with custom-bib 4.00 to use with natbib 7.0.
The natbib documentation does not state how to redefine thebibliography
environment to suppress the numbering of references as it is standard.

Can someone help me with that?

Thanks a lot,
Stefan

---
University of Karlsruhe, Germany
Institute of Information Engineering and Management

2. question on FS98

3. unable to number references using natbib

4. (Most of) you people deserve each other.....

5. NATBIB References

6. Cannot access iPAQ CF Sleeve with Windows Media player

7. reference list using natbib

8. Performance of Multithreading API:s

9. switching Bibliography->References under natbib

10. how to number references using natbib in BibTeX?

11. Cross-references with natbib/custbib/bibentry

12. Problem with natbib.sty and natbib.bst

13. References/ bibliography not included in TOC