Richard, Thanks a lot. I got this to work finally. I had initially tried something like that before writing this question, but quite naively. I simply said \def\tableofcontents{\indici} and that gave me a stack overflow. This is because indici calls \tableofcontents internally. I now redefined it by copying the code for indici and placing it in the definition of tableofcontents. This time, I replaced the \tableofcontents with \oldtoc. So now my definition looks like: \def\tableofcontents{ <loads of stuff before that....> \iffrontmatter\else\frontmattertrue\fi \oldtoc <loads of stuff after that....> }
When you replied to my email, I decided there has to be some way to do this only using this redefinition trick. I was stupid not to think of this earlier, but thanks a lot for your reply that guarantees that modifying Insets won't work for me. The more I thought it was possible to customize Insets, the more I was trying it. I had spent 16 hours modifying Insets and it didn't work. It took me just 2 mins to fix this though. I think I just needed someone to tell me that the solution is not in that route. Thanks, Balaji On Tue, Jan 13, 2009 at 9:18 AM, rgheck <rgh...@bobjweil.com> wrote: > Balaji wrote: > >> Hi, >> >> I have a LaTeX class called toptesi that has a special latex command >> \indici >> that produces the table of contents, list of figures and list of tables >> etc., in a specific format. I want to use this using the Inset features of >> LyX. Now I know that you can insert LaTeX commands in LyX, but this is >> more >> for my mother than for me, and so she cannot understand this. I want to >> create a layout file that will modify the CommandInset for the TOC to >> generate a different code. >> >> >> > This cannot be done without modifying the code. It was a natural idea to > try it with InsetLayout, but that only works with collapsable insets, like > ERT, footnotes, etc. > > The present CommandInset for TOC generates the following: >> \begin_inset CommandInset toc >> LatexCommand tableofcontents >> >> \end_inset >> >> Instead of producing this, I want LyX to generate the following code: >> >> \begin_inset CommandInset toc >> LatexCommand indici >> >> \end_inset >> >> >> > No, this isn't what you want to do. What you want is to change the LaTeX > export, not the LyX code. So where LyX generates: > \tableofcontents{} > you want what? Answer that and your solution will be to put this in the > preamble (which you can do in a layout file): > \let\oldtoc=\tableofcontents > \def\tableofcontents{NEW CODE} > This trick is used in the beamer layouts. > > Richard > >