f

#### Using "#" in lstlisting environment breaks formating

Hi,

Im am creating a presnetation with the beamer package and want to
disply a shell script via the listings package. However with this code:

\lstset{language=csh,showstringspaces=false,basicstyle=\footnotesize}
\begin{lstlisting}
#!/bin/csh
if ( $#argv < 2 ) then echo "usage:$0 name age"
exit 1
endif
\end{lstlisting}

the formating following the hash in the second line of the code seems
to be broken. The rest of the line is slanted, including the closing
paren and "then". If I remove the hash everything is formatted
correctly. A similar problem occurs with a sh script for "language=sh".

I couldn't find anything about having to escape hashes in the
documentation.

Any ideas?

Thanks,

Loris
--
Dr. Loris Bennett
Computer Centre
Freie Universität Berlin
Berlin, Germany

 0
1/12/2010 9:55:12 AM
comp.text.tex 38838 articles. 1 followers.

6 Replies
2024 Views

Similar Articles

[PageSpeed] 4

On Jan 12, 9:55=A0am, Loris Bennett <loris.benn...@fu-berlin.de> wrote:
> Hi,
>
> Im am creating a presnetation with the beamer package and want to
> disply a shell script via the listings package. However with this code:
>
> =A0 =A0 =A0 =A0 =A0 \lstset{language=3Dcsh,showstringspaces=3Dfalse,basic=
style=3D\footnotesize}
> =A0 =A0 =A0 =A0 =A0 \begin{lstlisting}
> #!/bin/csh
> if ( $#argv < 2 ) then > =A0echo "usage:$0 name age"
> =A0exit 1
> endif
> =A0 =A0 =A0 =A0 =A0 \end{lstlisting}
>
> the formating following the hash in the second line of the code seems
> to be broken. The rest of the line is slanted, including the closing
> paren and "then". If I remove the hash everything is formatted
> correctly. A similar problem occurs with a sh script for "language=3Dsh".
>
> I couldn't find anything about having to escape hashes in the
> documentation.
>
> Any ideas?
>
> Thanks,
>
> Loris
> --
> Dr. Loris Bennett
> Computer Centre
> Freie Universit=E4t Berlin
> Berlin, Germany

Please post a full example. Are you using the "fragile" option for the
relevant frame?
--
Joseph Wright

 0
Joseph
1/12/2010 10:04:18 AM
Joseph Wright <joseph.wright@morningstar2.co.uk> writes:

> On Jan 12, 9:55 am, Loris Bennett <loris.benn...@fu-berlin.de> wrote:
>> Hi,
>>
>> Im am creating a presnetation with the beamer package and want to
>> disply a shell script via the listings package. However with this code:
>>
>>           \lstset{language=csh,showstringspaces=false,basicstyle=\footnotesize}
>>           \begin{lstlisting}
>> #!/bin/csh
>> if ( $#argv < 2 ) then >> echo "usage:$0 name age"
>>  exit 1
>> endif
>>           \end{lstlisting}
>>
>> the formating following the hash in the second line of the code seems
>> to be broken. The rest of the line is slanted, including the closing
>> paren and "then". If I remove the hash everything is formatted
>> correctly. A similar problem occurs with a sh script for "language=sh".
>>
>> I couldn't find anything about having to escape hashes in the
>> documentation.
>>
>> Any ideas?
>>
>> Thanks,
>>
>> Loris
>> --
>> Dr. Loris Bennett
>> Computer Centre
>> Freie Universität Berlin
>> Berlin, Germany
>
> Please post a full example. Are you using the "fragile" option for the
> relevant frame?
> --
> Joseph Wright

Sorry. Here is a full example:

\documentclass[t,smaller,compress]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}

\usepackage{listings}

\begin{document}

\begin{frame}[fragile]{A Simple Script}

\lstset{language=csh,showstringspaces=false,basicstyle=\footnotesize}
\begin{lstlisting}
#!/bin/csh
if ( $#argv < 2 ) then echo "usage:$0 name age"
exit 1
endif
\end{lstlisting}

\end{frame}

\end{document}

--
Dr. Loris Bennett
Computer Centre
Freie Universität Berlin
Berlin, Germany

 0
Loris
1/12/2010 10:58:32 AM
> Sorry. Here is a full example:
>
> \documentclass[t,smaller,compress]{beamer}
> \usepackage[utf8]{inputenc}
> \usepackage[ngerman]{babel}
>
> \usepackage{listings}
>
>
> \begin{document}
>
> \begin{frame}[fragile]{A Simple Script}
>
>   \lstset{language=csh,showstringspaces=false,basicstyle=\footnotesize}
>   \begin{lstlisting}
> #!/bin/csh
> if ( $#argv < 2 ) then > echo "usage:$0 name age"
>  exit 1
> endif
>   \end{lstlisting}
>
> \end{frame}
>
> \end{document}
>
>

# is registered as a comment char for csh language (see lstlang1.sty)

you could cheat and change the font for comments

or disable the # as a comment char (I don't know how to do that)

--

/daleif (remove RTFSIGNATURE from email address)

LaTeX FAQ:      http://www.tex.ac.uk/faq
LaTeX book:     http://www.imf.au.dk/system/latex/bog/    (in Danish)
Remember to post minimal examples, see URL below
http://www.tex.ac.uk/cgi-bin/texfaq2html?label=minxampl
http://www.minimalbeispiel.de/mini-en.html

 0
Lars
1/12/2010 11:29:15 AM
maybe test
\begin{lstlisting}[escapechar=ø]
ø#ø!/bin/csh
\end{lstlisting}

 0
leethiumd
1/22/2010 9:13:57 AM
leethiumd <user@compgroups.net/> wrote:

> maybe test
> \begin{lstlisting}[escapechar=ø]
> ø#ø!/bin/csh
> \end{lstlisting}

My newsreader and I couldn't find any encoding declaration in your
posting. Probably you are using a Unicode character (>7bit) as
escapechar. However listings doesn't support Unicode.

#' works with both the default language and language csh' directly.
If you are escaping, then you are inside TeX, there \# prints a #'.

\documentclass{article}
\usepackage{listings}
\begin{document}
\begin{lstlisting}[escapechar=\%]
#!/bin/csh
%\#%!/bin/csh
\end{lstlisting}
\begin{lstlisting}[language=csh]
#!/bin/csh
\end{lstlisting}
\end{document}

Yours sincerely
Heiko <oberdiek@uni-freiburg.de>

 1
Heiko
1/22/2010 9:50:21 AM
Heiko Oberdiek <oberdiek@uni-freiburg.de> writes:

> leethiumd <user@compgroups.net/> wrote:
>
>> maybe test
>> \begin{lstlisting}[escapechar=Ã¸]
>> Ã¸#Ã¸!/bin/csh
>> \end{lstlisting}
>
> My newsreader and I couldn't find any encoding declaration in your
> posting. Probably you are using a Unicode character (>7bit) as
> escapechar. However listings doesn't support Unicode.

It is the character "ø" which indeed works fine:

\documentclass{article}

\usepackage[latin1]{inputenc}
\usepackage{listings}

\begin{document}

\begin{lstlisting}[escapechar=ø, language=csh]
ø\#ø!/bin/csh
#abc
\end{lstlisting}

\end{document}

--
Change “LookInSig” to “tcalveu” to answer by mail.
`
 2
Philipp
1/22/2010 9:56:49 AM

Similar Artilces:

When to use "." and when to use "!"
I'm still confused about this and I can't find anywhere that explains it properly. I have the MS book "Access 2003" in front of me and I'm reading Part 5 about VB and so on. It's telling me about how to refer to a specific database and has the example:- Dim dbMyDb As DAO.Database Set dbMyDb = DBEngine.Workspaces(0).Databases(0) but, but, but, but - what do those dots (periods, full stops, call them what you will) mean? (OK, it appears to be the same usage as C/C++/Java when referring to class/structure members, but I wish it would tell me that somewhere) ...

Hi , Hope you are doing great. Please let me take this opportunity to introduce myself, Iam Karthik working with BhanInfo Inc, a NY based company. We have consultants on our bench on various technologies, my request is to add me to your distribution list and kindly do send me the requirements. i have the below list available 1. Mainframe 2. Java 3.. Financial Analyst 4. Data Architect If there is any vendor ship agreement which has to be signed then I would like to take an opportunity to represent my company and expect your cooperation... We look forward to build a ve...

Using "MM" Date Format in Query When Data is "M" format
I'm thinking this is easy but can't get it. I have a table with following: Table1 Date 1/1/2007 Table2 Type 0107 (This is MMYY of above) So I'm having trouble using a query to turn the date from Table 1 into the Type from Table 2. I know when the dates are >=10, I can just use Left,2 and Right, 2. I don't want to have to put a long condition that says "If month <10, then use '0'&Left,1, else use Left,2" Though I'd think this will work, it's a little awkward. Setting the format type in the query only changes the display, doesn't l...

When to use "document" and when to use "this"
Hello all, Can anyone explain when one should use the "document" object and when one should use the "this" object? Also, is the "self" object the same as the "document" or "this" object? ...

Hi , Hope you are doing great. Please let me take this opportunity to introduce myself, Iam Karthik working with BhanInfoi Inc, a NY based company. We have consultants on our bench on various technologies, my request is to add me to your distribution list and kindly do send me the requirements. i have the below list available 1. Mainframe 2. Java 3.. Financial Analyst 4. Data Architect If there is any vendor ship agreement which has to be signed then I would like to take an opportunity to represent my company and expect your cooperation... ...

What does r"""any text""" mean ?
.... as you can find in os.py at line 1 ? Regards Alexander Alexander Eisenhuth wrote: > ... as you can find in os.py at line 1 ? Please don't split your request between subject and body. String literals enclosed in triple quotes are multiline strings. String literals prefixed by "r" are raw strings. http://docs.python.org/ref/strings.html Regards, Bj�rn -- BOFH excuse #71: The file system is full of it Hi Alexander, Alexander Eisenhuth wrote: > ... as you can find in os.py at line 1 ? This is a raw string. Raw strings don't interpret the escape sequences...

when to use "conv2", when to use "fft"->"multiplication"->"ifft"?
Hi all, I am doing 2D image filtering with sometimes filter size larger than image size. I am wondering which of the following scheme is the fastest, using Matlab: 1) conv2, 2D convolution directly; 2) conv2, but decompose the filter into two separable filters and then conv2 will first convolve along X axis and then convolve along Y axis; 3) fft2, multiplication, ifft2, all in 2D domain; 4) fft, multiplication, ifft, all in 1D case and work on convolutions of separable filters along X axis and Y axis; (similar to 2, but do 1D convolution all in frequency domain). Images and filters are...

TEXTREAD: numeric formats choke on "NaN" and "" (quoted as text) in R13
When trying to read a CSV file with TEXTREAD that is the output of a spreadsheet, I've noticed the following. If you specify a numeric format for a field, and the field contains "NaN" or "", TEXTREAD returns an error. NaN (unquoted) is fine. I can't find a way to enter NaN as a numeric value into either Excel or Openoffice. Also, if any result of a vlookup is empty, "" will be output by both programs. So this is sort of a pain. A workaround is to read each field as text and then convert later to numeric using str2double. Does anyone have a...

Urgent Requirement in """""""""""""NEW YORK""""""""""""""""
Hello Partners, Please find the requirement below. Please send the updated resume along with rate and contact no. REQ#1: Title : Java Developer ( Rating Project) Duration : 6 months Rate : open Location : NY strong java, WebLogic 9.2, Web Services, Oracle REQ#2: Title : Java Developer Duration : 4 months Rate : open Location : NY Strong java, SQL REQ#3: Title : VB.Net Consultant Location : NY Duration : 4 months Rate : open Primarily looking at someone who has Excel, VB.net a...

Is there a "break" "continue" equivalent in the "for" or "while" statement in SKILL?
Thank you! madhero wrote, on 07/03/08 09:42: > Thank you! Not directly, but see: http://tinyurl.com/69wte8 http://tinyurl.com/6ycdbn for two related threads in this group. Regards, Andrew. ...

In tabular environment, is there anyway to set one column to use "lstlisting" environement?
In multiple column tabular environment, is there anyway to set one column to use the "lstlisting" environement without effecting other columns ? I guess if there is such a way, the way to set one column to use "bold" font will be the same. Thanks ...