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)

newfile10.tex (543 bytes ) - added by levon 22 years ago.
testcase
trtr_orig.lyx (1.1 KB ) - added by jeanpierre.chretien@… 17 years ago.
Lyx test file for roudtrip test
bug19-15x.2.diff (6.1 KB ) - added by lasgouttes 16 years ago.
update of attachment 1341 for branch
bug19-15x.diff (5.9 KB ) - added by lasgouttes 16 years ago.
Tentative patch for 1.5
bug19.diff (5.5 KB ) - added by lasgouttes 16 years ago.
Tentative patch for 1.4
test-insets-2.lyx (1.9 KB ) - added by Uwe Stöhr 16 years ago.
LyX testfile for the \makebox issue
test-insets-2.tex (911 bytes ) - added by Uwe Stöhr 16 years ago.
TeX output of attachment 2571
bug19-16x.diff (6.0 KB ) - added by lasgouttes 16 years ago.
same patch for trunk
bug19.2.diff (5.5 KB ) - added by Uwe Stöhr 16 years ago.
actualized patch

Download all attachments as: .zip

Change History (48)

comment:1 by levon, 22 years ago

blocked: 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28

comment:2 by Lars Gullik Bjønnes, 22 years ago

op_sys: LinuxAll
Priority: highlow
rep_platform: PCAll

comment:3 by lasgouttes, 22 years ago

I think I do not understand this bug report :)

comment:4 by levon, 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 levon, 22 years ago

Component: latex exportrelyx

this is about relyx import btw. The component is wrong I think.

comment:6 by levon, 22 years ago

Owner: changed from nobody@… to kayvan@…

Re-assigning relyx bugs to Kayvan

comment:7 by levon, 22 years ago

Version: 1.2.0cvs1.2.0

Mass move to 1.2.0 - grep out the bugspam with "Dharma ex one+one"

by levon, 22 years ago

Attachment: newfile10.tex added

testcase

comment:8 by levon, 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 Juergen Spitzmueller, 19 years ago

Component: relyxtex2lyx

Same problem with tex2lyx. Changing component, since reLyX is unmaintained.

comment:10 by José Matos, 19 years ago

Milestone: 1.5.0
Severity: normalenhancement
Status: newassigned

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:11 by levon, 19 years ago

Milestone: 1.5.01.4.1

Could consider earlier (1.4.1)

comment:12 by lasgouttes, 18 years ago

Milestone: 1.4.11.4.2

not going to happen in 1.4.1, it seems.

comment:13 by lasgouttes, 18 years ago

blocked: 2438

comment:14 by lasgouttes, 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 Uwe Stöhr, 18 years ago

Severity: enhancementnormal

comment:16 by jeanpierre.chretien@…, 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 lasgouttes, 18 years ago

Milestone: 1.4.21.4.x

comment:18 by lasgouttes, 17 years ago

Keywords: patch added

comment:19 by lasgouttes, 17 years ago

attachments.description: Tentative patchTentative patch for 1.4

comment:20 by jeanpierre.chretien@…, 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.

by jeanpierre.chretien@…, 17 years ago

Attachment: trtr_orig.lyx added

Lyx test file for roudtrip test

comment:21 by jeanpierre.chretien@…, 17 years ago

Cc: Georg.Baum@… added

comment:22 by lasgouttes, 17 years ago

Owner: changed from kayvan@… to lasgouttes
Status: assignednew

comment:23 by Richard Heck, 17 years ago

Milestone: 1.4.x1.6.0

Resetting target from 1.4.x to 1.6.0.

comment:24 by Georg Baum, 17 years ago

Cc: georg.baum@… removed

comment:25 by Uwe Stöhr, 16 years ago

Keywords: fixedintrunk added

I fixed the extra \makeatother command problematic and the guillemets issue a
while ago. #2438 is fixedintrunk, so the only missing thing is support for
the geometry settings that is now #4826.

Marking this as fixedintrunk.

comment:26 by lasgouttes, 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 Juergen Spitzmueller, 16 years ago

Cc: j.spitzmueller@… added

Jean-Marc, if you think your patches make sense, just go ahead and commit them.

comment:28 by Uwe Stöhr, 16 years ago

Cc: uwestoehr@… 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.

by lasgouttes, 16 years ago

Attachment: bug19-15x.2.diff added

update of attachment 1341 for branch

by lasgouttes, 16 years ago

Attachment: bug19.diff added

Tentative patch for 1.5

comment:29 by lasgouttes, 16 years ago

attachments.isobsolete: 01

comment:30 by lasgouttes, 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.

by Uwe Stöhr, 16 years ago

Attachment: test-insets-2.lyx added

LyX testfile for the \makebox issue

by Uwe Stöhr, 16 years ago

Attachment: test-insets-2.tex added

TeX output of attachment 2571

by lasgouttes, 16 years ago

Attachment: bug19-16x.diff added

same patch for trunk

by Uwe Stöhr, 16 years ago

Attachment: bug19.2.diff added

actualized patch

comment:31 by Uwe Stöhr, 16 years ago

attachments.isobsolete: 01

comment:32 by Uwe Stöhr, 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:33 by Uwe Stöhr, 16 years ago

Ping, JMarc?

comment:34 by lasgouttes, 16 years ago

Sorry to be so slow. I did not forget about it and will eventually (!) commit it.

comment:35 by Uwe Stöhr, 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 Uwe Stöhr, 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 lasgouttes, 16 years ago

You did the right ting, thanks. I just committed a few whitespace problems.

comment:38 by Uwe Stöhr, 16 years ago

Keywords: patch removed

comment:39 by Juergen Spitzmueller, 16 years ago

Keywords: fixedintrunk removed
Resolution: fixed
Status: newclosed

comment:40 by Juergen Spitzmueller, 16 years ago

LyX 1.6.0 is released.

Note: See TracTickets for help on using tickets.