Kevin Paunovic wrote:

On Feb 7, 2007, at 12:00 PM, Jean-Marc Lasgouttes wrote:

"Kevin" == Kevin Paunovic <[EMAIL PROTECTED]> writes:

Kevin> The problem now is that LyX automatically adds things like:
Kevin> \usepackage[T1]{fontenc} \usepackage[latin1]{inputenc}
Kevin> \usepackage{graphicx} \usepackage{babel}

Kevin> so, as you might expect, this leads to crashes at compilation.

Kevin> How to get rid of all those things LyX adds?

I am not sure I understand. Do you really need to keep the things that
are included in the preamble? Why?


I would prefer, in my case, to have an option to tell LyX to stop putting things in the preamble except for the documentclass.

LyX is smart enough to add required packages (ex. graphicx when a graphic is included) but unfortunatly, it can't see if a package was (or will be) already loaded by the user.

In my case, I have a mystyle.sty file that contains:
%% mystyle.sty
    \RequirePackage[pdftex]{graphicx}
    \RequirePackage[cmyk,fixpdftex,pdftex]{xcolor}
%%

Since you seem to like doing weird stuff . . .

Lyx can do things differently depending on what kind
of latex compiler you use.
"latex" or "pdflatex"  (view/export->latex, or view/export->pdflatex)

I don't know if the layout files support this, but the "external inset"
definitely support it, so that graphichs formats can be included
in different ways for latex and pdflatex. The reason is that
these two simply support different formats. pdflatex takes png
which latex don't understand, and so on.

So I think you can get this part working the way you want by
inputting your graphichs as external insets - even if they
happen to be in a supported format.  You can then write your
own file external_insets that will generate
different \usepackage commands depending on wether
pdflatex or latex is used.
You can then have "pdf-ish" options and packages for pdf
generation, and "dvips-ish" options and packages for
ordinary latex. If you have no "plain" graphichs in the document, then
lyx won't include "graphicx" on its own.  So if your
external inset want "graphics" instead, or some obscure option,
then you will get that.

Clearly, the external inset way won't solve all such problems,
but you can at least have nice graphichs that work the way
_you_ want with both pdflatex and dvips. Set the external
inset up right and you will even get a view of the graphics inside
the lyx editor. All this without editing the lyx executable. :-)
Yep, I appreciate this feature, really. It will be perfect if one can have a checkbox that enable or disable this feature, and if the package names are written in a config file (and not hard-coded in the executable). For example, LyX uses "graphicx". You know that there is also a package called "graphics". What if one prefer using this one? And what if a new package called "gfx" is released on CTAN and improve greatly the old graphicx? This only is a suggestion, but giving a customization method here would be great.
These cases are solvable by using a custom external inset that
specifies "graphics" or "gfx", and then you don't use any
"plain" graphics in the document so that LyX leaves out "graphicx".

The external inset is just as easy to use as plain graphics - after the one-time
job of customizing .lyx/external_templates

Helge Hafting


Reply via email to