Re: new lines disappearing in program listings

2008-03-05 Thread Michael Grubb

Daniel,
Thanks for your post, it's helped me with the problem I've been having  
as well.
I was trying to create a new environment that used the lstlisting  
latex environment.
This was to be able to easily create consistent program listings (as  
well as making it easy for users who have no latex experience) and not  
having to use ERT.
The other goal was to be able to get floating listings with captions/ 
labels.  The big problem I was having was that lyx was inserting extra  
newlines in the output.
My next thought was to hack the source of LyX to add an option for the  
layouts of 'IsVerbatim' to better support environments that are  
supposed to be verbatim environments.  But I quickly found that I was  
out of my depth, as I couldn't even find where to start for this ;)
If I don't find a solution to getting the layout method to work, at  
least your post has given me an acceptable workaround.


Thanks again,

Michael

On Mar 5, 2008, at 1:39 AM, Daniel Lohmann wrote:



On 05.03.2008, at 05:55, Bo Peng wrote:

Have you checked out the support for lstlisting in LyX 1.5.x?  I  
gather
from the wiki that Bo Peng is responsible for it (props to Bo).   
It's

not on the environment roster; you get it with Insert - Program
Listing.  Right click the widget handle to see all the  
controllable stuff.


I know the mentioned problems with listings but they are not easy to
solve. I also recommend using a listings child document for long
listings.


I have been using the listings package quite a lot. Since LyX 1.4 it  
works perfectly if used in ERT boxes (pre 1.4 versions added an  
extra new-line after every hard line break, which required some  
trickery with negative linkeskip values to yield a good result.)


I never used the new listings inset, though. In my opinion, ERT  
boxes are just perfect for in-text listings of code. Listings  
clearly is one of the best documented packages available in the  
LaTeX world and has a very convenient interface, so hand coding  
listings options is not at all painful. All one should do is to  
define a listings style with all necessary default settings in the  
preamble (a good practice anyway). Then only two actual LaTeX lines  
have to be in each ERT box:


\begin{lstlisting}[style=ac]
#include Win32Error.h
aspect ThrowWin32Errors {
 advice call( win32::Win32API() ) : after() {
   if( win32::IsError( *tjp-result() ) {
 throw win32::Exception();
   }
 }
};
\end{lstlisting}

Keeping (short) listings in ERT boxes this way has a some clear  
advantages:


- The on-screen formatting is easy, as within ERT a typewriter font  
is used.
- The spell checker skips ERT boxes, hence the listings do not get  
spell checked (that always annoyed me with LyxCode)
- Extra options can easily be passed as additional optional  
parameters in the square brackets.


For longer listings I recommend to not input them as  LyX child  
documents, but keep them in ordinary  text files  using the  
\lstinputlisting command in ERT:


\lstinputlisting[style=aclisting]{../src/win32eh-app.cpp}


Just my two cents,

Daniel




Re: new lines disappearing in program listings

2008-03-05 Thread Michael Grubb

Daniel,
Thanks for your post, it's helped me with the problem I've been having  
as well.
I was trying to create a new environment that used the lstlisting  
latex environment.
This was to be able to easily create consistent program listings (as  
well as making it easy for users who have no latex experience) and not  
having to use ERT.
The other goal was to be able to get floating listings with captions/ 
labels.  The big problem I was having was that lyx was inserting extra  
newlines in the output.
My next thought was to hack the source of LyX to add an option for the  
layouts of 'IsVerbatim' to better support environments that are  
supposed to be verbatim environments.  But I quickly found that I was  
out of my depth, as I couldn't even find where to start for this ;)
If I don't find a solution to getting the layout method to work, at  
least your post has given me an acceptable workaround.


Thanks again,

Michael

On Mar 5, 2008, at 1:39 AM, Daniel Lohmann wrote:



On 05.03.2008, at 05:55, Bo Peng wrote:

Have you checked out the support for lstlisting in LyX 1.5.x?  I  
gather
from the wiki that Bo Peng is responsible for it (props to Bo).   
It's

not on the environment roster; you get it with Insert - Program
Listing.  Right click the widget handle to see all the  
controllable stuff.


I know the mentioned problems with listings but they are not easy to
solve. I also recommend using a listings child document for long
listings.


I have been using the listings package quite a lot. Since LyX 1.4 it  
works perfectly if used in ERT boxes (pre 1.4 versions added an  
extra new-line after every hard line break, which required some  
trickery with negative linkeskip values to yield a good result.)


I never used the new listings inset, though. In my opinion, ERT  
boxes are just perfect for in-text listings of code. Listings  
clearly is one of the best documented packages available in the  
LaTeX world and has a very convenient interface, so hand coding  
listings options is not at all painful. All one should do is to  
define a listings style with all necessary default settings in the  
preamble (a good practice anyway). Then only two actual LaTeX lines  
have to be in each ERT box:


\begin{lstlisting}[style=ac]
#include Win32Error.h
aspect ThrowWin32Errors {
 advice call( win32::Win32API() ) : after() {
   if( win32::IsError( *tjp-result() ) {
 throw win32::Exception();
   }
 }
};
\end{lstlisting}

Keeping (short) listings in ERT boxes this way has a some clear  
advantages:


- The on-screen formatting is easy, as within ERT a typewriter font  
is used.
- The spell checker skips ERT boxes, hence the listings do not get  
spell checked (that always annoyed me with LyxCode)
- Extra options can easily be passed as additional optional  
parameters in the square brackets.


For longer listings I recommend to not input them as  LyX child  
documents, but keep them in ordinary  text files  using the  
\lstinputlisting command in ERT:


\lstinputlisting[style=aclisting]{../src/win32eh-app.cpp}


Just my two cents,

Daniel




Re: new lines disappearing in program listings

2008-03-05 Thread Michael Grubb

Daniel,
Thanks for your post, it's helped me with the problem I've been having  
as well.
I was trying to create a new environment that used the lstlisting  
latex environment.
This was to be able to easily create consistent program listings (as  
well as making it easy for users who have no latex experience) and not  
having to use ERT.
The other goal was to be able to get floating listings with captions/ 
labels.  The big problem I was having was that lyx was inserting extra  
newlines in the output.
My next thought was to hack the source of LyX to add an option for the  
layouts of 'IsVerbatim' to better support environments that are  
supposed to be verbatim environments.  But I quickly found that I was  
out of my depth, as I couldn't even find where to start for this ;)
If I don't find a solution to getting the layout method to work, at  
least your post has given me an acceptable workaround.


Thanks again,

Michael

On Mar 5, 2008, at 1:39 AM, Daniel Lohmann wrote:



On 05.03.2008, at 05:55, Bo Peng wrote:

Have you checked out the support for lstlisting in LyX 1.5.x?  I  
gather
from the wiki that Bo Peng is responsible for it (props to Bo).   
It's

not on the environment roster; you get it with Insert -> Program
Listing.  Right click the widget handle to see all the  
controllable stuff.


I know the mentioned problems with listings but they are not easy to
solve. I also recommend using a listings child document for long
listings.


I have been using the listings package quite a lot. Since LyX 1.4 it  
works perfectly if used in ERT boxes (pre 1.4 versions added an  
extra new-line after every hard line break, which required some  
trickery with negative linkeskip values to yield a good result.)


I never used the new listings inset, though. In my opinion, ERT  
boxes are just perfect for in-text listings of code. Listings  
clearly is one of the best documented packages available in the  
LaTeX world and has a very convenient interface, so "hand coding"  
listings options is not at all painful. All one should do is to  
define a listings style with all necessary default settings in the  
preamble (a good practice anyway). Then only two actual LaTeX lines  
have to be in each ERT box:


\begin{lstlisting}[style=ac]
#include "Win32Error.h"
aspect ThrowWin32Errors {
 advice call( win32::Win32API() ) : after() {
   if( win32::IsError( *tjp->result() ) {
 throw win32::Exception();
   }
 }
};
\end{lstlisting}

Keeping (short) listings in ERT boxes this way has a some clear  
advantages:


- The on-screen formatting is easy, as within ERT a typewriter font  
is used.
- The spell checker skips ERT boxes, hence the listings do not get  
spell checked (that always annoyed me with LyxCode)
- Extra options can easily be passed as additional optional  
parameters in the square brackets.


For longer listings I recommend to not input them as  LyX child  
documents, but keep them in ordinary  text files  using the  
\lstinputlisting command in ERT:


\lstinputlisting[style=aclisting]{../src/win32eh-app.cpp}


Just my two cents,

Daniel




Re: technical documents

2008-02-27 Thread Michael Grubb

Thanks for the tip.
However, I have some questions.

Using Insert-Program Listing  is great if you only need one or two  
listings but keeping consistency throughout a large document is a pain.
So I decided to try and create a new layout using the listings  
package, but I'm getting some unwanted newlines in my output.


I have this in my layout file:

Style CodeBlock
LatexType   Environment
LatexName   lstlisting
OptionalArgs0
InTitle 0
Margin  Static
NextNoIndent0
ParIndent   
Newline 0
PassThru1
FreeSpacing 1
End


(I added the Newline, PassThru, and FreeSpacing options as  
experimentation to try to get the spurious newlines eaten, to no  
effect but I left them in this listing in the

interest of full disclosure ;)

If I give input in lyx (using the CodeBlock environment above) of:

some line of code 1
some line of code 2
some line of code 3

I get output such as:

some line of code 1

some line of code 2

some line of code 3

However, when I use the Insert-Program Listing option, it generates  
the exact same latex code as my environment, except that I don't get  
all the extra newlines.


So my question is how do I get LyX to not pass those extra newlines  
and behave with the environment similar to the Inset?



On Feb 26, 2008, at 9:16 AM, Jürgen Spitzmüller wrote:


Michael Grubb wrote:

First these are the features that I'm really interested in (or
alternatives/compromises to these):

Ability to have short code/command examples in-line with normal text,
preferably set off with a monospaced font.
Ability to have longer code/command examples in a verbatim  
environment

(possible surrounded by a box and a shaded background)
Ability to have longer code/command examples labled and indexed
(similar to figures and tables)


As of 1.5.0, LyX supports the listings package. It has both an  
inline and a
displayed listings inset which should provide what you're looking  
for.


Jürgen




Re: technical documents

2008-02-27 Thread Michael Grubb

Thanks for the tip.
However, I have some questions.

Using Insert-Program Listing  is great if you only need one or two  
listings but keeping consistency throughout a large document is a pain.
So I decided to try and create a new layout using the listings  
package, but I'm getting some unwanted newlines in my output.


I have this in my layout file:

Style CodeBlock
LatexType   Environment
LatexName   lstlisting
OptionalArgs0
InTitle 0
Margin  Static
NextNoIndent0
ParIndent   
Newline 0
PassThru1
FreeSpacing 1
End


(I added the Newline, PassThru, and FreeSpacing options as  
experimentation to try to get the spurious newlines eaten, to no  
effect but I left them in this listing in the

interest of full disclosure ;)

If I give input in lyx (using the CodeBlock environment above) of:

some line of code 1
some line of code 2
some line of code 3

I get output such as:

some line of code 1

some line of code 2

some line of code 3

However, when I use the Insert-Program Listing option, it generates  
the exact same latex code as my environment, except that I don't get  
all the extra newlines.


So my question is how do I get LyX to not pass those extra newlines  
and behave with the environment similar to the Inset?



On Feb 26, 2008, at 9:16 AM, Jürgen Spitzmüller wrote:


Michael Grubb wrote:

First these are the features that I'm really interested in (or
alternatives/compromises to these):

Ability to have short code/command examples in-line with normal text,
preferably set off with a monospaced font.
Ability to have longer code/command examples in a verbatim  
environment

(possible surrounded by a box and a shaded background)
Ability to have longer code/command examples labled and indexed
(similar to figures and tables)


As of 1.5.0, LyX supports the listings package. It has both an  
inline and a
displayed listings inset which should provide what you're looking  
for.


Jürgen




Re: technical documents

2008-02-27 Thread Michael Grubb

Thanks for the tip.
However, I have some questions.

Using Insert->Program Listing  is great if you only need one or two  
listings but keeping consistency throughout a large document is a pain.
So I decided to try and create a new layout using the listings  
package, but I'm getting some unwanted newlines in my output.


I have this in my layout file:

Style CodeBlock
LatexType   Environment
LatexName   lstlisting
OptionalArgs0
InTitle 0
Margin  Static
NextNoIndent0
ParIndent   
Newline 0
PassThru1
FreeSpacing 1
End


(I added the Newline, PassThru, and FreeSpacing options as  
experimentation to try to get the spurious newlines eaten, to no  
effect but I left them in this listing in the

interest of full disclosure ;)

If I give input in lyx (using the CodeBlock environment above) of:

some line of code 1
some line of code 2
some line of code 3

I get output such as:

some line of code 1

some line of code 2

some line of code 3

However, when I use the Insert->Program Listing option, it generates  
the exact same latex code as my environment, except that I don't get  
all the extra newlines.


So my question is how do I get LyX to not pass those extra newlines  
and behave with the environment similar to the Inset?



On Feb 26, 2008, at 9:16 AM, Jürgen Spitzmüller wrote:


Michael Grubb wrote:

First these are the features that I'm really interested in (or
alternatives/compromises to these):

Ability to have short code/command examples in-line with normal text,
preferably set off with a monospaced font.
Ability to have longer code/command examples in a verbatim  
environment

(possible surrounded by a box and a shaded background)
Ability to have longer code/command examples labled and indexed
(similar to figures and tables)


As of 1.5.0, LyX supports the listings package. It has both an  
inline and a
displayed listings "inset" which should provide what you're looking  
for.


Jürgen




technical documents

2008-02-26 Thread Michael Grubb

Greetings all!

I'm fairly new to LyX, but I've heard lots of great things about it.   
I'm wanting to start using LyX to write all my technical documents but  
I have a few questions.


First these are the features that I'm really interested in (or  
alternatives/compromises to these):


Ability to have short code/command examples in-line with normal text,  
preferably set off with a monospaced font.
Ability to have longer code/command examples in a verbatim environment  
(possible surrounded by a box and a shaded background)
Ability to have longer code/command examples labled and indexed  
(similar to figures and tables)


If I have to I'll create my own layout/style to do these but before I  
went down that long road I wanted to query the community to see what  
other people may be using, or if someone had already done some/all of  
this and I just haven't been able to find it.


Any guidance/advice is welcome and appreciated!

Thanks,

Michael


technical documents

2008-02-26 Thread Michael Grubb

Greetings all!

I'm fairly new to LyX, but I've heard lots of great things about it.   
I'm wanting to start using LyX to write all my technical documents but  
I have a few questions.


First these are the features that I'm really interested in (or  
alternatives/compromises to these):


Ability to have short code/command examples in-line with normal text,  
preferably set off with a monospaced font.
Ability to have longer code/command examples in a verbatim environment  
(possible surrounded by a box and a shaded background)
Ability to have longer code/command examples labled and indexed  
(similar to figures and tables)


If I have to I'll create my own layout/style to do these but before I  
went down that long road I wanted to query the community to see what  
other people may be using, or if someone had already done some/all of  
this and I just haven't been able to find it.


Any guidance/advice is welcome and appreciated!

Thanks,

Michael


technical documents

2008-02-26 Thread Michael Grubb

Greetings all!

I'm fairly new to LyX, but I've heard lots of great things about it.   
I'm wanting to start using LyX to write all my technical documents but  
I have a few questions.


First these are the features that I'm really interested in (or  
alternatives/compromises to these):


Ability to have short code/command examples in-line with normal text,  
preferably set off with a monospaced font.
Ability to have longer code/command examples in a verbatim environment  
(possible surrounded by a box and a shaded background)
Ability to have longer code/command examples labled and indexed  
(similar to figures and tables)


If I have to I'll create my own layout/style to do these but before I  
went down that long road I wanted to query the community to see what  
other people may be using, or if someone had already done some/all of  
this and I just haven't been able to find it.


Any guidance/advice is welcome and appreciated!

Thanks,

Michael