Re: Difficulty with LyX-Code and Copystyle FIX FOUND

2008-07-29 Thread G. Milde
On 28.07.08, rgheck wrote:
 G. Milde wrote:
 On 27.07.08, Steve Litt wrote:

 Is there a simple way I can use CopyStyle with LyX-Code and not get this
 error?

 Yes. Overwrite the Preamble definiton by defining a replacement (maybe
 empty) in your copy.

 FYI: LyX 1.6 has a new AddToPreamble tag for cases where you don't  
 want to over-write but just want to add something. If I'm remembering  
 correctly, I found I needed the tag somewhere, so added it.

However, in the above case it is important to replace the Preamble.
Otherwise the double occurence of \newcommand{command}{...
triggers a LaTeX error.

Or is there a provision that the Preamble of Style A, referenced by
AddToPreamble in Style B is not repeated if both, A and B occure in a
document?

Günter


Re: Difficulty with LyX-Code and Copystyle FIX FOUND

2008-07-29 Thread rgheck



Yes. Overwrite the Preamble definiton by defining a replacement (maybe
empty) in your copy.
  


  
FYI: LyX 1.6 has a new AddToPreamble tag for cases where you don't  
want to over-write but just want to add something. If I'm remembering  
correctly, I found I needed the tag somewhere, so added it.



However, in the above case it is important to replace the Preamble.
Otherwise the double occurence of \newcommand{command}{...
triggers a LaTeX error.

  
Yes, sorry. I should have been clearer. I didn't mean this would have 
helped Steve, in this case.


rh



Re: Difficulty with LyX-Code and Copystyle FIX FOUND

2008-07-29 Thread G. Milde
On 28.07.08, rgheck wrote:
 G. Milde wrote:
 On 27.07.08, Steve Litt wrote:

 Is there a simple way I can use CopyStyle with LyX-Code and not get this
 error?

 Yes. Overwrite the Preamble definiton by defining a replacement (maybe
 empty) in your copy.

 FYI: LyX 1.6 has a new AddToPreamble tag for cases where you don't  
 want to over-write but just want to add something. If I'm remembering  
 correctly, I found I needed the tag somewhere, so added it.

However, in the above case it is important to replace the Preamble.
Otherwise the double occurence of \newcommand{command}{...
triggers a LaTeX error.

Or is there a provision that the Preamble of Style A, referenced by
AddToPreamble in Style B is not repeated if both, A and B occure in a
document?

Günter


Re: Difficulty with LyX-Code and Copystyle FIX FOUND

2008-07-29 Thread rgheck



Yes. Overwrite the Preamble definiton by defining a replacement (maybe
empty) in your copy.
  


  
FYI: LyX 1.6 has a new AddToPreamble tag for cases where you don't  
want to over-write but just want to add something. If I'm remembering  
correctly, I found I needed the tag somewhere, so added it.



However, in the above case it is important to replace the Preamble.
Otherwise the double occurence of \newcommand{command}{...
triggers a LaTeX error.

  
Yes, sorry. I should have been clearer. I didn't mean this would have 
helped Steve, in this case.


rh



Re: Difficulty with LyX-Code and Copystyle FIX FOUND

2008-07-28 Thread G. Milde
On 27.07.08, Steve Litt wrote:
 On Sunday 27 July 2008 17:09, Steve Litt wrote:
  ...
  if I create and use two LyX styles, Code1 and Code2, each of them
  with CopyStyle LyX-Code, then on conversion to PDF I get the following
  error message:
 
  LaXeX Error: Command \lyxcode already defined
 
  I can use all Code1, or all Code2, or all LyX-Code, but if I have any two
  of them in the document, I get an error like described above.
...
  Is there a simple way I can use CopyStyle with LyX-Code and not get this
  error?

Yes. Overwrite the Preamble definiton by defining a replacement (maybe
empty) in your copy.

 I found a fix I can use locally, and a fix that could be made with the LyX 
 distribution. Let me start with the latter...

 LyX-Code is defined in lyxdir/layouts/lyxmacros.inc thusly:

 Style LyX-Code
...
   Preamble
...
   EndPreamble
...
 End

 Notice that the LaTeX environment, lyxcode, is defined within the LyX 
 environment definition, so if LyX-Code is mentioned twice, \lyxcode is 
 defined twice, which is an error.

No.

If you use LyX-Code n times (with n = 1, ..., \infty) in your
document, exactly one Preamble code is inserted in the latex preamble.

Iy you do not use LyX-Code (i.e. n=0), the Preamble latex code is not
used.

 To fix the problem, the developers could remove everything from Preamble to 
 EndPreamble in the LyX-Code definition, and put it after the Format 4 and 
 before any LyX style definitions. 

In this case, every document that used this layout will have the \lyxcode
definition in the latex preamble. As most documents do not use LyX-Code,
this is not desired.

 It's nice and modular to put the LaTeX definition inside the LyX
 definition, but doing so greatly reduces the value of CopyStyle, so I'd
 recommend against it.

It also produces cleaner LaTeX sources, so I want it to stay.

All you have to remember is that the Styles that define their own
preamble need special care when copied with CopyStyle (i.e. a new
Preamble definition).

 In other words, I copied and pasted \lyxcode to \litt_lyxcode within my
 layout file, and copied and pasted LyX-Code (minus the
 Preamble/EndPreamble section) to litt_LyX-Code within my layout file,
 and then did CopyStyle on litt_LyX-Code. It worked perfectly!

If you need the lyxcode definition in several Styles, you can:

1. Copy the Preamble section from the original LyXCode to your layout
   file (as general Preamble code).
   
2. Redefine LyXCode:

   Style LyXCode
  Preamble
  EndPreamble
  
3. Copy the redefined one, e.g.

   Style MyLyXCode
  CopyStyle LyXCode
  LatexName  \mycode
  Preamble
\newcommand{\mycode}{Hi world!\\ \lyxcode}
  EndPreamble
   End
   
This is Untested, but you should get the general idea!

Günter


Re: Difficulty with LyX-Code and Copystyle FIX FOUND

2008-07-28 Thread rgheck

G. Milde wrote:

On 27.07.08, Steve Litt wrote:
  

Is there a simple way I can use CopyStyle with LyX-Code and not get this
error?
  


Yes. Overwrite the Preamble definiton by defining a replacement (maybe
empty) in your copy.

  
FYI: LyX 1.6 has a new AddToPreamble tag for cases where you don't 
want to over-write but just want to add something. If I'm remembering 
correctly, I found I needed the tag somewhere, so added it.


rh



Re: Difficulty with LyX-Code and Copystyle FIX FOUND

2008-07-28 Thread Abdelrazak Younes

rgheck wrote:

G. Milde wrote:

On 27.07.08, Steve Litt wrote:

Is there a simple way I can use CopyStyle with LyX-Code and not get
this
error?


Yes. Overwrite the Preamble definiton by defining a replacement (maybe
empty) in your copy.


FYI: LyX 1.6 has a new AddToPreamble tag for cases where you don't


LyX 1.6 _will_ have...

I just realized that we (me included) keep evangelizing how great 1.6 is 
(will be) but firt we should release it ;-)


Abdel.



Re: Difficulty with LyX-Code and Copystyle FIX FOUND

2008-07-28 Thread rgheck

Abdelrazak Younes wrote:

rgheck wrote:

G. Milde wrote:

On 27.07.08, Steve Litt wrote:

Is there a simple way I can use CopyStyle with LyX-Code and not get
this
error?


Yes. Overwrite the Preamble definiton by defining a replacement (maybe
empty) in your copy.


FYI: LyX 1.6 has a new AddToPreamble tag for cases where you don't


LyX 1.6 _will_ have...

I just realized that we (me included) keep evangelizing how great 1.6 
is (will be) but firt we should release it ;-)



True. And even I'm not using it for every day work yet

rh



Re: Difficulty with LyX-Code and Copystyle FIX FOUND

2008-07-28 Thread G. Milde
On 27.07.08, Steve Litt wrote:
 On Sunday 27 July 2008 17:09, Steve Litt wrote:
  ...
  if I create and use two LyX styles, Code1 and Code2, each of them
  with CopyStyle LyX-Code, then on conversion to PDF I get the following
  error message:
 
  LaXeX Error: Command \lyxcode already defined
 
  I can use all Code1, or all Code2, or all LyX-Code, but if I have any two
  of them in the document, I get an error like described above.
...
  Is there a simple way I can use CopyStyle with LyX-Code and not get this
  error?

Yes. Overwrite the Preamble definiton by defining a replacement (maybe
empty) in your copy.

 I found a fix I can use locally, and a fix that could be made with the LyX 
 distribution. Let me start with the latter...

 LyX-Code is defined in lyxdir/layouts/lyxmacros.inc thusly:

 Style LyX-Code
...
   Preamble
...
   EndPreamble
...
 End

 Notice that the LaTeX environment, lyxcode, is defined within the LyX 
 environment definition, so if LyX-Code is mentioned twice, \lyxcode is 
 defined twice, which is an error.

No.

If you use LyX-Code n times (with n = 1, ..., \infty) in your
document, exactly one Preamble code is inserted in the latex preamble.

Iy you do not use LyX-Code (i.e. n=0), the Preamble latex code is not
used.

 To fix the problem, the developers could remove everything from Preamble to 
 EndPreamble in the LyX-Code definition, and put it after the Format 4 and 
 before any LyX style definitions. 

In this case, every document that used this layout will have the \lyxcode
definition in the latex preamble. As most documents do not use LyX-Code,
this is not desired.

 It's nice and modular to put the LaTeX definition inside the LyX
 definition, but doing so greatly reduces the value of CopyStyle, so I'd
 recommend against it.

It also produces cleaner LaTeX sources, so I want it to stay.

All you have to remember is that the Styles that define their own
preamble need special care when copied with CopyStyle (i.e. a new
Preamble definition).

 In other words, I copied and pasted \lyxcode to \litt_lyxcode within my
 layout file, and copied and pasted LyX-Code (minus the
 Preamble/EndPreamble section) to litt_LyX-Code within my layout file,
 and then did CopyStyle on litt_LyX-Code. It worked perfectly!

If you need the lyxcode definition in several Styles, you can:

1. Copy the Preamble section from the original LyXCode to your layout
   file (as general Preamble code).
   
2. Redefine LyXCode:

   Style LyXCode
  Preamble
  EndPreamble
  
3. Copy the redefined one, e.g.

   Style MyLyXCode
  CopyStyle LyXCode
  LatexName  \mycode
  Preamble
\newcommand{\mycode}{Hi world!\\ \lyxcode}
  EndPreamble
   End
   
This is Untested, but you should get the general idea!

Günter


Re: Difficulty with LyX-Code and Copystyle FIX FOUND

2008-07-28 Thread rgheck

G. Milde wrote:

On 27.07.08, Steve Litt wrote:
  

Is there a simple way I can use CopyStyle with LyX-Code and not get this
error?
  


Yes. Overwrite the Preamble definiton by defining a replacement (maybe
empty) in your copy.

  
FYI: LyX 1.6 has a new AddToPreamble tag for cases where you don't 
want to over-write but just want to add something. If I'm remembering 
correctly, I found I needed the tag somewhere, so added it.


rh



Re: Difficulty with LyX-Code and Copystyle FIX FOUND

2008-07-28 Thread Abdelrazak Younes

rgheck wrote:

G. Milde wrote:

On 27.07.08, Steve Litt wrote:

Is there a simple way I can use CopyStyle with LyX-Code and not get
this
error?


Yes. Overwrite the Preamble definiton by defining a replacement (maybe
empty) in your copy.


FYI: LyX 1.6 has a new AddToPreamble tag for cases where you don't


LyX 1.6 _will_ have...

I just realized that we (me included) keep evangelizing how great 1.6 is 
(will be) but firt we should release it ;-)


Abdel.



Re: Difficulty with LyX-Code and Copystyle FIX FOUND

2008-07-28 Thread rgheck

Abdelrazak Younes wrote:

rgheck wrote:

G. Milde wrote:

On 27.07.08, Steve Litt wrote:

Is there a simple way I can use CopyStyle with LyX-Code and not get
this
error?


Yes. Overwrite the Preamble definiton by defining a replacement (maybe
empty) in your copy.


FYI: LyX 1.6 has a new AddToPreamble tag for cases where you don't


LyX 1.6 _will_ have...

I just realized that we (me included) keep evangelizing how great 1.6 
is (will be) but firt we should release it ;-)



True. And even I'm not using it for every day work yet

rh



Re: Difficulty with LyX-Code and Copystyle FIX FOUND

2008-07-27 Thread Steve Litt
On Sunday 27 July 2008 17:09, Steve Litt wrote:
 Hi all,

 I'm not calling this a bug because maybe it was never intended to work this
 way, but if I create and use two LyX styles, Code1 and Code2, each of them
 with CopyStyle LyX-Code, then on conversion to PDF I get the following
 error message:

 LaXeX Error: Command \lyxcode already defined

 I can use all Code1, or all Code2, or all LyX-Code, but if I have any two
 of them in the document, I get an error like described above.

 The attached mini document (1.5.3 produced) plus the mini-layout produce
 the symptom.

 Is there a simple way I can use CopyStyle with LyX-Code and not get this
 error?

 Thanks

 SteveT

 Steve Litt
 Recession Relief Package
 http://www.recession-relief.US

Hi all,

I found a fix I can use locally, and a fix that could be made with the LyX 
distribution. Let me start with the latter...

LyX-Code is defined in lyxdir/layouts/lyxmacros.inc thusly:

Style LyX-Code
MarginStatic
LatexType Environment
LatexName lyxcode
NextNoIndent  1
LeftMarginMMM
RightMargin   MMM
TopSep0.5
BottomSep 0.5
Align Left
AlignPossible Block, Left, Right, Center
LabelType No_Label
FreeSpacing   1
Preamble
\newenvironment{lyxcode}
{\begin{list}{}{
\setlength{\rightmargin}{\leftmargin}
\setlength{\listparindent}{0pt}% needed for AMS 
classes
\raggedright
\setlength{\itemsep}{0pt}
\setlength{\parsep}{0pt}
\normalfont\ttfamily}%
 \item[]}
{\end{list}}
EndPreamble
Font
  Family  Typewriter
EndFont
End

Notice that the LaTeX environment, lyxcode, is defined within the LyX 
environment definition, so if LyX-Code is mentioned twice, \lyxcode is 
defined twice, which is an error.

To fix the problem, the developers could remove everything from Preamble to 
EndPreamble in the LyX-Code definition, and put it after the Format 4 and 
before any LyX style definitions. While you're at it, you might as well pull 
the LaTeX definitions out of LyX environments Address and Right_Address, 
because those will have the same problems with CopyStyle. Obviously, there 
need be only a single Preamble/EndPreamble pair globally in this file.

It's nice and modular to put the LaTeX definition inside the LyX definition, 
but doing so greatly reduces the value of CopyStyle, so I'd recommend against 
it.

I didn't want to mess with the distribution, so I did the following locally, 
within my layout file...

#
Preamble
\newenvironment{litt_lyxcode}
{\begin{list}{}{
\setlength{\rightmargin}{\leftmargin}
\setlength{\listparindent}{0pt}% needed for AMS classes
\raggedright
\setlength{\itemsep}{0pt}
\setlength{\parsep}{0pt}
\normalfont\ttfamily}%
 \item[]}
{\end{list}}

 OTHER LATEX STUFF GOES HERE
EndPreamble

Style litt_LyX-Code
MarginStatic
LatexType Environment
LatexName litt_lyxcode
NextNoIndent  1
LeftMarginMMM
RightMargin   MMM
TopSep0.5
BottomSep 0.5
Align Left
AlignPossible Block, Left, Right, Center
LabelType No_Label
FreeSpacing   1
Preamble
EndPreamble
Font
  Family  Typewriter
EndFont
End

Style  Code
CopyStyle litt_LyX-Code
End


Style  Codeinbox
CopyStyle litt_LyX-Code
End


Style  Codetext
CopyStyle litt_LyX-Code
End
#

In other words, I copied and pasted \lyxcode to \litt_lyxcode within my layout 
file, and copied and pasted LyX-Code (minus the Preamble/EndPreamble section) 
to litt_LyX-Code within my layout file, and then did CopyStyle on 
litt_LyX-Code. It worked perfectly!

Thanks

SteveT

Steve Litt
Recession Relief Package
http://www.recession-relief.US



Re: Difficulty with LyX-Code and Copystyle FIX FOUND

2008-07-27 Thread Steve Litt
On Sunday 27 July 2008 17:09, Steve Litt wrote:
 Hi all,

 I'm not calling this a bug because maybe it was never intended to work this
 way, but if I create and use two LyX styles, Code1 and Code2, each of them
 with CopyStyle LyX-Code, then on conversion to PDF I get the following
 error message:

 LaXeX Error: Command \lyxcode already defined

 I can use all Code1, or all Code2, or all LyX-Code, but if I have any two
 of them in the document, I get an error like described above.

 The attached mini document (1.5.3 produced) plus the mini-layout produce
 the symptom.

 Is there a simple way I can use CopyStyle with LyX-Code and not get this
 error?

 Thanks

 SteveT

 Steve Litt
 Recession Relief Package
 http://www.recession-relief.US

Hi all,

I found a fix I can use locally, and a fix that could be made with the LyX 
distribution. Let me start with the latter...

LyX-Code is defined in lyxdir/layouts/lyxmacros.inc thusly:

Style LyX-Code
MarginStatic
LatexType Environment
LatexName lyxcode
NextNoIndent  1
LeftMarginMMM
RightMargin   MMM
TopSep0.5
BottomSep 0.5
Align Left
AlignPossible Block, Left, Right, Center
LabelType No_Label
FreeSpacing   1
Preamble
\newenvironment{lyxcode}
{\begin{list}{}{
\setlength{\rightmargin}{\leftmargin}
\setlength{\listparindent}{0pt}% needed for AMS 
classes
\raggedright
\setlength{\itemsep}{0pt}
\setlength{\parsep}{0pt}
\normalfont\ttfamily}%
 \item[]}
{\end{list}}
EndPreamble
Font
  Family  Typewriter
EndFont
End

Notice that the LaTeX environment, lyxcode, is defined within the LyX 
environment definition, so if LyX-Code is mentioned twice, \lyxcode is 
defined twice, which is an error.

To fix the problem, the developers could remove everything from Preamble to 
EndPreamble in the LyX-Code definition, and put it after the Format 4 and 
before any LyX style definitions. While you're at it, you might as well pull 
the LaTeX definitions out of LyX environments Address and Right_Address, 
because those will have the same problems with CopyStyle. Obviously, there 
need be only a single Preamble/EndPreamble pair globally in this file.

It's nice and modular to put the LaTeX definition inside the LyX definition, 
but doing so greatly reduces the value of CopyStyle, so I'd recommend against 
it.

I didn't want to mess with the distribution, so I did the following locally, 
within my layout file...

#
Preamble
\newenvironment{litt_lyxcode}
{\begin{list}{}{
\setlength{\rightmargin}{\leftmargin}
\setlength{\listparindent}{0pt}% needed for AMS classes
\raggedright
\setlength{\itemsep}{0pt}
\setlength{\parsep}{0pt}
\normalfont\ttfamily}%
 \item[]}
{\end{list}}

 OTHER LATEX STUFF GOES HERE
EndPreamble

Style litt_LyX-Code
MarginStatic
LatexType Environment
LatexName litt_lyxcode
NextNoIndent  1
LeftMarginMMM
RightMargin   MMM
TopSep0.5
BottomSep 0.5
Align Left
AlignPossible Block, Left, Right, Center
LabelType No_Label
FreeSpacing   1
Preamble
EndPreamble
Font
  Family  Typewriter
EndFont
End

Style  Code
CopyStyle litt_LyX-Code
End


Style  Codeinbox
CopyStyle litt_LyX-Code
End


Style  Codetext
CopyStyle litt_LyX-Code
End
#

In other words, I copied and pasted \lyxcode to \litt_lyxcode within my layout 
file, and copied and pasted LyX-Code (minus the Preamble/EndPreamble section) 
to litt_LyX-Code within my layout file, and then did CopyStyle on 
litt_LyX-Code. It worked perfectly!

Thanks

SteveT

Steve Litt
Recession Relief Package
http://www.recession-relief.US