Bonhôte, André wrote:
Hi LyX Users!

I am trying the whole day to create a nice style for SQL. Up to now, I have manage to create some semi-nice output. My .layout file looks about like this:


\usepackage{listings}

[...]

Style SQL
  CopyStyle             LyX-Code
  LatexType             Environment
  LatexName             sql_1
  Preamble
        \lstnewenvironment{sql_1}
{ \lstset{ language=SQL, basicstyle=\small, keywordstyle=\color{blue}, commentstyle=\color{red}, numbers=left, numberstyle=\tiny, stepnumber=2, numbersep=5pt}
                }
                {}
  EndPreamble
End

Now, I have tried to use my layout. It looks quite nice on the screen, but not very much like it should in the output files. I have created a very simple and stupid query:

SELECT * FROM bla, fasel WHERE bla = 0

Highlighted it, chose the "SQL" param style from the dropdown. LyX formatted it like it does when using the LyX-Code style. Fine so far. Exporting it to pdf shows something weird:

1 SELECT ~ { * } ~FROM~ b l a , ~ f a s e l ~WHERE~ b l a ~= ~0

Wonderfully colored, but spoiled with tilde and brackets. Bad.

ehat do you expect? It is the correct output, just like verbatim.
If you do not want to see the ~, then don't insert them.

I really can't tell what went wrong. Another thing I noticed that when using newlines, LyX seems to insert double newlines. So, something looking like this on the screen:

SELECT * FROM bla, fasel
WHERE bla = 0

turns out to look like

1 SELECT ~ { ∗ } ~FROM~ b l a , ~ f a s e l ~
[big space here]
3 WHERE~ b l a ~= ~0

a _long_ standing bug in LyX. You need to hit ctrl-return
at the end of every line, otherwise LyX inserts an additional
linebreak.

Herbert

Reply via email to