Memoir and Table of Contents

I am trying to learn my way around Scrivener, MMD and Latex enough to put together my dissertation. I’ve almost got it the way I want it but I’m a bit confused about the table of contents.

I am using an xslt tree that I’ve hodge-podged together from customising the memoir-natbib.xslt.

This seems to call the memoir.xslt, which seems to have an option I can un-comment in order to get a table of contents. Only it doesn’t work. I’ve unflagged it but at no point does that section seem to get called and inserted in the final latex.

I can just put my own table of contents in manually in xhtml2latex.xslt and that seems to work, but it’s a bit of a bodge-job. It also means that my table of contents appears before my abstract, as I can’t figure out where to put it so it appears after. I can’t figure out why the toc Fletcher has already included doesn’t get called. Is anyone able to suggest what I’m doing wrong?

With thanks

Hi Lusule,

I looked at the xslt files on my machine, and I think I see what your problem is. When xslt imports a file with a command like <xsl:import href=“xhtml2latex.xslt”/> it loads all the templates therein. If a template is defined more than once, the last one loaded is the one that counts.

What is see happening is this

  1. First, memoir-natbib.xslt loads memoir.xslt
  2. memoir.xslt loads xhtml2latex.xslt
  3. xhtml2latex defines a latex-begin-body template which does basically nothing.
  4. This is overridden by memoir.xslt which redefines latex-begin-body to include the \tableofcontents that you want.
  5. But then, memoir-natbib.xslt loads natbib-support.xslt which
  6. loads xhtml2latex.xslt again (apparently unnecessarily)
  7. which causes xhtml2latex.xslt to redefine the latex-begin-body back to the do-nothing version.

There’s a number of ways to fix this, but perhaps the most straightforward is to reverse the order of the two import statements in the stylesheet that you have been customizing – so that natbib-support.xslt is loaded before memoir.xslt. If this causes other problems to occur with your citations – try removing the second import of xhtml2latex.xslt.

Hope this works.

Thanks for the help whaynes, it seems that because of that little thing I was missing out on a lot more than just the ToC!

I’ve flipped it around, and just that simple copy/paste has activated a whole tranche of settings I was missing - a lot of which I’d had to put in manually in a much more messy way, so I’m starting again from scratch to clean it all up properly.

Unfortunately, it still seems to place my abstract after the ToC but that’s easy enough to switch around manually after compiling.

It also seems to cause problems with numbering for some reason - \setcounter{secnumdepth}{4} doesn’t seem to stick in the final compile but that looks like a latex problem rather than an MMD problem so I’m still working on it.

Thanks again!

Glad that helped. Just be careful, because it looks like some of the custom citation templates in natbib-support will be overridden by the second call to xhtml2latex, which may or may not be an issue for you.

Did you see this discussion regarding getting abstracts before the TOC?

http://groups.google.com/group/multimarkdown/browse_thread/thread/1cb9cad02a80f95e?fwc=2

I did see that discussion. In the end I have decided just to move the abstract manually in the completed tex file. It’s easy enough.

I haven’t noticed any issues with citations but I shall be sure to check carefully.

With regard to the issue of numbering sections, in theory you should be able change the numbering depth by adding:

\setcounter{secnumdepth}{4}

or whatever depth is required. This is what is recommended on the majority of help pages, and according to the memoir documentation it should work. However I was unable to get it to work. Instead I was able to resolve the problem by using:

\setsecnumdepth{subsubsection}

Which does the same thing. You specify the lowest section type wanted by word instead of using the number.

Thanks again

Lusule