Opened 22 years ago
Closed 16 years ago
#19 closed defect (fixed)
Better support for user pre-amble
Reported by: | levon | Owned by: | lasgouttes |
---|---|---|---|
Priority: | low | Milestone: | 1.6.0 |
Component: | tex2lyx | Version: | 1.2.1 |
Severity: | normal | Keywords: | testcase |
Cc: | j.spitzmueller@…, uwestoehr@… |
Description
All the packages loaded automatically by lyx (e.g.
a4, babel) will appear
in the user preamble. Also the \makeatletter ..
\makeatother commands will
appear in the user preamble.
Additionally, packages in the user preamble will be
duplicated in the lyx preamble if they are needed by lyx,
even overriding user options.
Attachments (9)
Change History (48)
comment:1 by , 22 years ago
blocked: | → 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28 |
---|
comment:2 by , 22 years ago
op_sys: | Linux → All |
---|---|
Priority: | high → low |
rep_platform: | PC → All |
comment:3 by , 22 years ago
comment:4 by , 22 years ago
I don't follow the first paragraph either. But isn't the second true:
if a user wants a non-standard option on a package lyx decides it needs itself,
lyx will use its own options overriding the users ?
Obviously I don't know this stuff ...
comment:5 by , 22 years ago
Component: | latex export → relyx |
---|
this is about relyx import btw. The component is wrong I think.
comment:7 by , 22 years ago
Version: | 1.2.0cvs → 1.2.0 |
---|
Mass move to 1.2.0 - grep out the bugspam with "Dharma ex one+one"
comment:8 by , 22 years ago
Keywords: | testcase added |
---|
Here's an example of the first problem. LyX generated the use of graphicx,
but when you import it, it appears in the /user/ preamble.
comment:9 by , 19 years ago
Component: | relyx → tex2lyx |
---|
Same problem with tex2lyx. Changing component, since reLyX is unmaintained.
comment:10 by , 19 years ago
Milestone: | → 1.5.0 |
---|---|
Severity: | normal → enhancement |
Status: | new → assigned |
tex2lyx takes care of all the packages in the preamble as well as the
language. And it also takes care of graphics (see #22, closed yesterday).
Now the only thing that remains to do is to remove the lyx generated comments.
Since this is a small issue I classify the issue as an enhancement and I will
set 1.5.0 as target to this bug and I will assign the bug to me.
comment:13 by , 18 years ago
blocked: | → 2438 |
---|
comment:14 by , 18 years ago
I is a bit more than an enhancement, since it prevents round-trip in french
(#2438).
A work around would be, if we are in a part of preamble generated by LyX, to
just drop lines we do not interpret instead of copying them in preamble.
comment:15 by , 18 years ago
Severity: | enhancement → normal |
---|
comment:16 by , 18 years ago
I added a comment in dependent #2438, I reproduce it here:
Another example is a roundtrip with a document using the geometry package:
it comes back with an inserted preamble which contains the exported
geometry stuff, so that any change in geometry from theDocument->Settings->Page
layout is not taken into account, as it is exported before the preamble.
The problem is not only with round trip I guess, should not
tex2lyx remove from the preamble the settings it can convert as
lyx commands which are exported in the preamble ?
Unless tex2lyx doe not try to convert as lyx commands at all ?
In which case, it might be better to drop the commands in the preamble
which are natively exported by lyx and to leave the user with the task
to re-set these commands, but this seems worse to me than lo leave him
the task to delete them him(her)self.
comment:17 by , 18 years ago
Milestone: | 1.4.2 → 1.4.x |
---|
comment:18 by , 17 years ago
Keywords: | patch added |
---|
comment:19 by , 17 years ago
attachments.description: | Tentative patch → Tentative patch for 1.4 |
---|
comment:20 by , 17 years ago
I'v tested the patch of comment #14 on lyx-1.4.3/Solaris,
on a test file that I will attach next.
This test file includes French guillemets (see #2438),
geometry package, a plain figure.
The result works fine, however looking at the preamble, there is an exra
\makeatother command, which is swallowed by the latex export function.
comment:21 by , 17 years ago
Cc: | added |
---|
comment:22 by , 17 years ago
Owner: | changed from | to
---|---|
Status: | assigned → new |
comment:24 by , 17 years ago
Cc: | removed |
---|
comment:25 by , 16 years ago
Keywords: | fixedintrunk added |
---|
comment:26 by , 16 years ago
Keywords: | fixedintrunk removed |
---|
I still think that my patches (that I never committed for a reason I do not
understand) make sense and should be applied. The code added by LyX should
be automatically discarded to improve roundtrip.
comment:27 by , 16 years ago
Cc: | added |
---|
Jean-Marc, if you think your patches make sense, just go ahead and commit them.
comment:28 by , 16 years ago
Cc: | added |
---|
The code added by LyX should be automatically discarded to improve roundtrip.
How will you do this? People might have slightly adopt it. Furthermore the code
LyX adds to the preamble has been changed from time to time due to bugfixes,
optimizations, etc.
comment:29 by , 16 years ago
attachments.isobsolete: | 0 → 1 |
---|
comment:30 by , 16 years ago
The principle of this patch is to omit from LyX-generated .tex files ("%% LyX .*
created this file") all the preamble snippets that are before
%%%%%%%% User specified LaTeX commands
The reason I did not put it in at the time is that LyX should also output a
%%%%%%%% End user specified LaTeX commands
and tex2lyx should act on it if it is present.
Concerning the ugly things that users may have been doing to their tex files,
note that every file starts with
%% Do not edit unless you really know what you are doing.
What I have to do next is test (but I'd appreciate independent testing) and
maybe implement the `End user specified LaTeX commands' thing.
comment:31 by , 16 years ago
attachments.isobsolete: | 0 → 1 |
---|
comment:32 by , 16 years ago
I updated your patch to latest trunk (I also changed some whitespace). I tested
it and it works well, except of this issue:
Take the LyX file attachment 2571 and export it as LaTeX, the result is
attachment 2572. When you import it to LyX, you get the \makeatother in the
preamble, but the original preamble didn't have that.
This could be fixed the following way: When the current \makeatother is the last
entry in the file before \begin{document}, it must be omitted as LyX sets it
again. So the structure is something like
else if (t.cs() == "makeatother") {
if ( (!is_lyx_file !in_lyx_preamble p.getCatCode('@') != catOther) && (p.next_token().asInput() == "
begin{document}") )
h_preamble << "
makeatother";
p.setCatCode('@', catOther);
}
Concerning the ugly things that users may have been doing to their tex files,
note that every file starts with
%% Do not edit unless you really know what you are doing.
This doesn't count. I know what I am doing and I often modify the TeX output of
LyX files to be able to send it to colleagues. I normally left LyX's comment
lines like
%%%%%%%% User specified LaTeX commands
intact.
But OK, for a round trip support we must assume that e.g. the
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
section is not changed by the user - I think we can do this. So the patch is
fine with me and should go in when the \makeatother issue is fixed as described.
What I have to do next is test (but I'd appreciate independent testing) and
maybe implement the `End user specified LaTeX commands' thing.
I don't think this is needed.
comment:34 by , 16 years ago
Sorry to be so slow. I did not forget about it and will eventually (!) commit it.
comment:35 by , 16 years ago
I did not forget about it and will eventually (!) commit it.
Please put it in. I've been working with your patch included since months now
and it is stable.
comment:36 by , 16 years ago
Keywords: | fixedintrunk added |
---|
Please put it in. I've been working with your patch included since months now
and it is stable.
@JMarc: As the patch is really stable and you didn't reply, I put it in. I hope
this is OK with you.
fixedintrunk: http://www.lyx.org/trac/changeset/26603
comment:37 by , 16 years ago
You did the right ting, thanks. I just committed a few whitespace problems.
comment:38 by , 16 years ago
Keywords: | patch removed |
---|
comment:39 by , 16 years ago
Keywords: | fixedintrunk removed |
---|---|
Resolution: | → fixed |
Status: | new → closed |
I think I do not understand this bug report :)