RE: How to use short dashes in program listings?

2011-08-06 Thread Helge Hafting

>I don't understand why the minus sign "-" isn't properly converted by latex.
>Is there a way to correct this without escaping to latex, as you suggested?

This does not happen with program listings when I try.
The "--" construct becomes a long dash only in plain text, not in listings.

There are several ways of writing program code in LyX:

* Listings inset:

"Insert->Program Listing"
You get a box where you can write program code, where minus signs will
be left alone. Even when there are several in a row. Right-click the
box to get settings where you can change the font and even turn on advanced 
features
like syntax highlighting for the programming language you use.

* Using the program source files directly:

"Insert->File->Child document" Set "include type" to "program listing"
Basically the same setup as the above mentioned inset, but it refers
directly to the source file. So docs and source never get out of sync,
because they are the same! You can specify from/to lines, if
you don't want to print the entire source file.

* Using the paragraph type "LyX code". 
This is more limited, you get the typewriter font and
no options for syntax highlightling. 

* Using the text style "code", provided by the "logical markup" module
This one seems to merge minus signs, so try the listings inset instead.
May be useful for code in languages that doesn't have "--".

Helge Hafting
Helge Hafting


Re: How to use short dashes in program listings?

2011-08-04 Thread Rodrigo Fresneda
Hi,

I don't understand why the minus sign "-" isn't properly converted by latex.
Is there a way to correct this without escaping to latex, as you suggested?

best regards,
rodrigo.


On Sat, Dec 11, 2010 at 3:26 PM, Paul A. Rubin  wrote:

> Nikos Chantziaras  arcor.de> writes:
>
> >
> > When inserting a program listing, all "-" characters in the source code
> > are converted to long dashes.  This results in the C operator "--"
> > looking more like a single long line rather than two dashes.  (There is
> > some space between each dash, but it's so small it only becomes obvious
> > when zooming in.)
> >
> > Is there a way around this?
>
> The only way I know is a PITA.  Pick an escape character you will not use
> in the
> listing (I'll use a tilde for explanatory purposes).  Right click the
> listing,
> select Settings, and in the Advanced tab type 'escapechar=~' (without the
> quotes) and apply the change. Now whenever you want the decrement operator
> in
> the listing, type '~-\,-\,~' (without the quotes).  The \, is a thin space;
> you
> can play around with alternative spacing if you like.
>
> /Paul
>
>
>


Re: How to use short dashes in program listings?

2010-12-11 Thread Paul A . Rubin
Nikos Chantziaras  arcor.de> writes:

> 
> When inserting a program listing, all "-" characters in the source code 
> are converted to long dashes.  This results in the C operator "--" 
> looking more like a single long line rather than two dashes.  (There is 
> some space between each dash, but it's so small it only becomes obvious 
> when zooming in.)
> 
> Is there a way around this?

The only way I know is a PITA.  Pick an escape character you will not use in the
listing (I'll use a tilde for explanatory purposes).  Right click the listing,
select Settings, and in the Advanced tab type 'escapechar=~' (without the
quotes) and apply the change. Now whenever you want the decrement operator in
the listing, type '~-\,-\,~' (without the quotes).  The \, is a thin space; you
can play around with alternative spacing if you like.

/Paul