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 37561 articles. 0 followers. Post Follow

6 Replies
1543 Views

Similar Articles

[PageSpeed] 58
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

commentstyle=\normalfont\footnotesize

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
Reply:
Similar Artilces:

Re: proc report, id var, how to control where to break the page? #4
Dennis, You are right, I should have added 'display' for id. But this still wouldn't solve the problem. Actually, I have several vars as ID var, so I have to define them in the define statement: data xx; array vx x1-x10; do id=1 to 10; a=byte(id+64); do over vx; vx=ranuni(2); end; output; end; run; options ls=80; proc report nowd; column id a ('_X1-X5_' x1 x2 x3 x4 x5) id=id2 ('_X6-X10_' x6 x7 x8 x9 x10) ; define id / id display; define a / id display; define id2 / spacing=70; run; This won't work. If I get rid of the 'id' option in define s...

Re: Scope of macro variable using "call symput" #12
Perahps the way SAS calculates the scope of a macro variable created by CALL SYMPUT violates the principle of least astonishment. It might make more sense for CALL SYMPUT to create a new macro-level symbol table, rather than searching upwards to find one that already exists. Or maybe not. The SYMPUTX way, which lets you specify the scope, is slightly more work to use but can create results that don't require thought or knowledge of context. On Mon, 24 Mar 2008 09:48:11 -0400, "Chang Chung" <chang_y_chung@HOTMAIL.COM> said: > On Sun, 23 Mar 2008 02:05:16 -0700, Rola...

Is it possible to use an Object as value for a <html:select> (i'm using struts)
Hi, I'm having trouble with struts, well actually i don't know if the problem is struts or instead i'm assuming html to be capable of something it's not. I have a ValidatorForm, say VF and one of it's attibutes called organismo is an object of type Ob1, Ob1 being a bean definded in another file, Ob1 has just two attributes a and b and their respective setters and getters. I want that attribute to be filled with the value of a <html:select>, depending on what the user chooses from the options available. To get the options i'm using the next: <html:select pro...

Use a variable value in another variable's name
I'm trying to use the value of one variable in the name of another variable. I have a while loop which matches every table in my document and I want to record something for each table. I'm using one variable to count the tables my $tableCount++; I want to use the value of that variable in creating another variable. my $table_$tableCount_cols="5"; #I want to create a var called $table_2_cols I've messed around using {} to isolate each variable, but I don't think I have it quite right. I can't find anything in the FAQ's that cover this, and any help would b...

pginstaller
Log Message: ----------- Remove references to MSM since we don't use those any more Modified Files: -------------- pginst: README (r1.1 -> r1.2) (http://cvs.pgfoundry.org/cgi-bin/cvsweb.cgi/pginstaller/pginst/README.diff?r1=1.1&r2=1.2) Removed Files: ------------- pginst/msm: README (http://cvs.pgfoundry.org/cgi-bin/cvsweb.cgi/pginstaller/pginst/msm/README) ---------------------------(end of broadcast)--------------------------- TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org ...

using `use' : what is the best practice ?
Hi guys, Sorry with my annoying questions, but it's not easy to program in Ada after 20 years programming in asm / C ;-) Maybe a not so anecdotic question : when using the 'use' clause ? My first thought is that using 'use' is not good because it masks the package tree. For example, if I have 2 packages with procedures sharing the same name, example `P1.Foo' and `P2.Foo', my code won't be very readable if I only write the short name (`Foo') : with P1; use P1; with P2; use P2; procedure Main is My_Val : Integer; begin Foo(My_Val); ...

Re: Proc Format Question #8
Art , LOl it should work assuming he has the length of the Dollar format correct. All it does is simply nest a format for all value that arnt between 0 and 100. Toby Dunn To sensible men, every day is a day of reckoning. ~John W. Gardner The important thing is this: To be able at any moment to sacrifice that which we are for what we could become. ~Charles DuBois Don't get your knickers in a knot. Nothing is solved and it just makes you walk funny. ~Kathryn Carpenter From: Arthur Tabachneck <art297@NETSCAPE.NET> Reply-To: Arthur Tabachneck <art297@NETSCAPE.NET> To: ...

Re: Picture format
Looks like you are right: 73 proc format; 74 picture pic(round) 75 0 - < 1 = "009.0%)" ( prefix = "( " ) 76 1 - < 10 = "000.0%)" ( prefix = "( " ) 77 10 - < 100 = "000.0%)" ( prefix = "( " ) 78 100 - < 1000 = "000.0%)" ( prefix = "(" ) 79 other = " " 80 ; NOTE: Format PIC is already on the library. NOTE: Format PIC has been output. 81 run; NOTE: PROCEDURE FORMAT used: real time 0.00 seconds cpu time 0.00 seco...

RE: Ingres II 2.0 in a Citrix environment #3
Just to clarify something Gary said: We haven't certified any Ingres release against Citrix. We know that some customers are using it successfully with some minor issues. What 2.6+SP2 introduces is full support for Microsoft Terminal Services. Terminal Services and Citrix - though they perform a similar task, are not the same. There's been some confusion over this, especially when the terms are used interchangeably. As many of you will know, the symbol.tbl file disappearing is not limited to Citrix, or even Windows. However Citrix seems to exacerbate it by having more act...

Canon i860 Doesn't Use 3e Black Cartridge
I have a Canon i860 printer that has 5 ink tanks. Three color and two black. The larger of the blacks is the 3e. The printer never uses any ink out of the 3e. It's just full all the time. Do I have something set wrong that causes all black printing to come out of the smaller 6 tank? The BCI-3ebk is only used in plain paper mode. If you are printing with any of the other paper types specified, then it's understandable why you don't see any usage of the pigmented ink tank. -- Ron "Dick" <LeadWinger> wrote in message news:kvils114lueit31qbne2gvg3...

how to use 'spap2' to fit data
I am trying to use 'spap2' to cubic spline my data set which has error in the y-axis, and sometimes my data is not there ie the data set is not continuous for instance: 1 150 99 99 99 1 188 99 99 99 1 226 99 99 99 1 265 99 99 99 1 303 740904.761905 -17714.2857143 33923.8095238 1 342 1113428.57143 -22285.7142857 41133.3333333 1 380 1198285.71429 -18857.1428571 39933.3333333 1 418 1119809.52381 -15428.5714286 34996.8253968 1 457 962819.047619 -14657.1428571 23144.4444444 1 495 783295.238095 -6085.71428571 15194.4444444 1 534 635542.857143 -6028.57142857 14011.1111111 1 572 508561.90476...

[Uniface-L] retrieve
Hi Uli, thanks for hint, but one disadvantage. Filter <GOLD>|<GOLD>=> will stay in the field after retrieve :( David >Hi David, > >if uniface sees a complete PK, it goes straight to the record. > >If you want an additional filter, just append an "or NULL" <GOLD>|<GOLD>= >to a keyfield. > id = ""%%ln_id%%%|=" > >Success, Uli ...

Compiling using mcc #4
I am trying to create a stand alone executable of a matlab .m file. I use the command mcc -mv filename.m it creates filename_main.c, mccExcludedFiles.log, filename.ctf and filename_mcc_component_data.c but does not generate an executable. Is there a reason the executable isn't produced. the compiling also says perl is not recognised as an internal or external command, operable or batch file. I am running Matlab 7.0.1 on windows XP Cheers CHRIS "Chris" <cfox28@cox.net> wrote in message news:ef27c45.-1@webx.raydaftYaTP... >I am trying to create a stand alone executab...

FAQ Topic
----------------------------------------------------------------------- FAQ Topic - How do I access a property of an object using a string? ----------------------------------------------------------------------- There are two ways to access properties: the dot notation and the square bracket notation. What you are looking for is the square bracket notation in which the dot, and the identifier to its right, are replaced with a set of square brackets containing a string. The value of the string matches the identifier. For example:- //dot notation var bodyElement = document.body; //square b...

Re: What function to use
Kenneth M Lin wrote: "Are you sure you aren't getting error messages? What exactly do you think SAS is doing in the line below: input @01 @"SAK NR.:" ... I didn't test it but @ must be followed by a number to indicate column position." @ can be followed by a character string. SAS will scan lines until it finds the string: data _null_; input @'Name:' name $; put name; datalines; Name: John xxxx Name: Mary ; Log: 52 data _null_; 53 input @'Name:' name $; 54 put name; 55 datalines; John Mary NOTE: SAS went to a new line when INPUT @&#...

Re: PROC GPLOT: HAXIS won't recongnize my custom format #4
Thanks Ya! This worked, and here is the mods to my original code so that the whole example is in one place for posterity: --- SAS Code --- * Create all possible values for 15min measurements in a week And make a format out of it. An example label value should look like 'Wed 13:15'. ; data temp; retain fmtname 'wdt' type 'n' ; do time=0 to 85500 by 900; do wday=1 to 7; length dname $3; select (wday); when(1) dname = 'Sun'; when(2) dname = 'Mon'; ...

Using Windows IDL to access a UNIX database using DLM's
Hey All, I am relatively new to using IDL with very little knowledge of in-depth computer stuff (compilers/linkers/etc.). I am trying to access a database using DLM's written by someone else (in C). I have spent way too long trying to solve the problem by downloading different compilers, looking into different linking issues and I still haven't accomplished much. My major issue is trying to get IDL to load the DLM and use it. I have added a IDL_DLM_PATH to my environment variables so that when I type "help, /dlm" at the command line it shows that my DLM is there. I then...

how to use fonts? #3
hi there :-) I'm testing an HP48G (lent by a friend) in order to read a file. The file is written as .tgv (that causes xlib errors beacuse I found out .tgv is a HP48GX/49 format). Fortunately I've the editor to change the format in .eden or .xv by means of winhp and it works, but some symbol and bolt and underlined (very useful for a quick understanding on a small screen) don't look as they should do. I was able to send the supplied fonts in the same directory of the file (on the hp) but I don't know how tell to hp to use that fonts... Could someone post the procedure? Thank...

FAQ 1.3 Which version of Perl should I use? #15
This is an excerpt from the latest version perlfaq1.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest version of the complete perlfaq is at http://faq.perl.org . -------------------------------------------------------------------- 1.3: Which version of Perl should I use? (contributed by brian d foy) There is often a matter of opinion and taste, and there isn't any one answer that fits anyone. In general, you want to use either the cu...

Promotion of your business using Google #2
Pay Per Click Management Services Patt has 7 years undergo in doing exactly what it says,<a href=http://www.payperclickmanagementservices.co.uk/>The Best pay per click management services</a> As varied people be acquainted with, unceasing a Google Adwords campaign can be costly in both time and Money. You could obtain your unmixed days budget has been blown in story hour through paying droll amounts of filthy rich per click. Skilfully thats where we progress in to take away the burden away from you. -- que...

Compile GUI's & RAM Memory used
Hi There ! I have compiled a GUI created in R14. Its a very simply one GUI that calls to a function once you introduce some outputs. I have noticed that, when you call the GUI in a PC with no Matlab installed, it consumes a lot of RAM Memory, about 55Mb, and it takes many time when to appear when call it. Does anyboby knows if it's possible to reduce the RAM Memory used by the GUI ? The mcc command I execute to compile is: mcc -mv -B sgl MyGUI.m Thanks in advance. Regards, There is no way to reduce this memory requirement; it is a result of the decision to have Compiler 4.x support all...

FAQ 7.3 Do I always/never have to quote my strings or use semicolons and commas? #2 553618
This is an excerpt from the latest version perlfaq7.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest version of the complete perlfaq is at http://faq.perl.org . -------------------------------------------------------------------- 7.3: Do I always/never have to quote my strings or use semicolons and commas? Normally, a bareword doesn't need to be quoted, but in most cases probably should be (and must be under "use strict"). But ...

Re: Cost analyses using PROC GENMOD using link=log and dist=gamma #7
Amy: See http://www.ats.ucla.edu/STAT/sas/output/sas_negbin_output.htm , especially, >> As assumed for a negative binomial model our response variable is a count variable, and each subject has the same length of observation time. Had the observation time for subjects varied, the model would need to be adjusted to account for the varying length of observation time per subject. This point is discussed later in the page. Also, the negative binomial model, as compared to other count models (i.e., poisson or zero-inflated models), is assumed to be the appropriate model. In other words, we a...

Please teach me how to make the arrangement using Code Interface Node. #4
Please teach me how to make the arrangement of Sine-wave using Code Interface Node. Yoichiro wrote: > Please teach me how to make the arrangement of Sine-wave using Code > Interface Node. You can keep repeating this request, but it will not help you! Read the answers already given especially the one from JohnM which points to the earlier thread with answers by him and me. You need to bother to read those documents pointed out to you and then come back with more specific and detailed questions. As it stands now we just have to assume that you know absolutely nothing based on the ty...

Re: Using SCANOVER #5
There is no bug. See description of LOSTCARD statement. The message from SAS NOTE: LOST CARD. is "saying" SAS is executing a LOSTCARD statement when the SCANOVER reached end of file. It is a typical condition when a data step is still trying to read when EOF is reached. Another example that produces the LOST CARD message. 10 data; 11 do i = 1 to 3; 12 input y @; 13 output; 14 end; 15 datalines; NOTE: LOST CARD. RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+--- 17 ;;;; i=3 y=2 _ERROR_=1 _N_=1 N...