COMPGROUPS.NET | Post | Groups | Users | Stream | Browse | About | |

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

• Email
• Follow

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

See related articles to this posting

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 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

> 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

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

 0

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 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
 comp.text.tex 37270 articles. 72 followers.

6 Replies
1459 Views

Similar Articles

[PageSpeed] 25

• Email
• Follow

Similar Artilces:

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 c...

How to use 'verbatim' environment when construct a new environment
Hi, all I want to create a new environment called 'code' whose content is smaller than normal text, and is verbatim. Intuitively, I can do following: \begin{small} \begin{verbatim} code code code... \end{verbatim} \end{small} I want to make these two environment into one by writing: \newenvironment{code}% {\begin{small}\begin{verbatim} }% {\end{verbatim}\end{small}} But it seems LaTeX can not do such encapsulation. When use \begin{code} and \end{code}, LaTeX reports 'verbatim' environment encounters file end. Anyone knows how to constructs such '...

Re: Using formatted variable (format values) as class/group #2
On Tue, 24 Jan 2006 00:30:18 -0800, GuidoT <cymraeg_erict@HOTMAIL.COM> wrote: >Hi, > >Unfortunately the code as written doesn't work, it doesn't summarise >the data, ok it does, it just outputs the summay for each of the >records. Can you be precise; does it or doesn't it? I'm not sure what you mean when you say it doesn't summarize. Does the code not group by week? >Well, that's what I tried first, adding a "calculated" to the >group by. This gave what I thought was the correct, summarised >results. But Dubravko mentioned ef...

Re: Using formatted variable (format values) as class/group #3
On Tue, 24 Jan 2006 02:51:28 -0800, GuidoT <cymraeg_erict@HOTMAIL.COM> wrote: >Hi s, > >Sorry, it was my confusion about what the WEEKV format does. WEEKV is >a SAS 9 format. It gives a 1 to 1 match for input date and output week >string (Week and day number). I'm running SAS 8.2 and I had >(incorrectly) assumed that WEEKV was a private format that resulted in >a week number - So 7 days go to one output string. With this >assumption, the SQL without the CALCULATED gives a summary by week for >each of the input records. WIth CALCULATED (or 1) it produc...

Re: Use format file to format large number of variables #3
oh, yeah, been there, done that wrote a tool: http://www.sascommunity.org/wiki/Image:Writattr.sas Here is an example of the output: http://www.sascommunity.org/wiki/Image:Demo_c-attrib.sas Ron Fehd the module/routine/subroutine maven CDC Atlanta GA USA RJF2 at cdc dot gov > -----Original Message----- > From: owner-sas-l@listserv.uga.edu > [mailto:owner-sas-l@listserv.uga.edu] On Behalf Of Herbert Morley A > Sent: Monday, December 29, 2008 1:33 PM > To: 'SAS Listserv' > Subject: Use format file to format large number of variables > > I have two datasets th...

Re: Using formatted variable (format values) as class/group #4
Why not use PROC SUMMARY? It's tuned for performance. Try proc summary data=test nway; class datum; output out=result(drop=_type_ rename=(datum=datum_c _freq_=n) ); run; On Mon, 23 Jan 2006 23:07:43 -0800, Dubro <dubro@DOLIC.DE> wrote: >Dear Group, > >I have a date variable which is formatted to give the week values >(weekv5.). Now I want to count another variable by this one. Is there a >more efficient way than the one given in the following example? > >data test; > infile datalines; > input datum date9. user $; > for... Re: Use format file to format large number of variables #2 Thanks to everyone's suggestions. Turned out problem was when the dataset = was created, a few variables were referred to a format that was numeric, wh= en the defined format was character. I had to define a new numeric format f= or those few variables and use it for them. The rest did fine (I already ha= d defiined fmtsearch- but that turned out not to be the problem). Best wishes Morley Herbert ... Re: Which format to use? #2 On Fri, 7 Nov 2008 21:00:45 -1000, Joanne Mor <jmor@HAWAII.EDU> wrote: >SAS-L gurus, > >I am converting a file containing cost data in the w.d format to a flat file to send to a vendor. Their required format has an implied decimal (e.g., 163.99 = 000016399). Does SAS have a format or do I need to create my own? > >TIA. I believe you will have to develop a picture format to do this. > On Fri, 7 Nov 2008 21:00:45 -1000, Joanne Mor <j...@HAWAII.EDU> wrote: > >SAS-L gurus, > > >I am converting a file containing cost data in the w.d format to a flat &... formatting in equation environment #2 Hello Can anybody tell me how to customize the equation environment? I would like to change the left, right, top and bottom margins for the equations, and also the line gap between equations. Thankyou Shreyas. shreyas7@hotmail.com (shreyas) writes: > Can anybody tell me how to customize the equation environment? > I would like to change the left, right, top and bottom margins for the > equations, and also the line gap between equations. The top and bottom margins are \abovedisplayskip, \abovedisplayshortskip, \belowdisplayskip, and \belowdisplayshortskip, where the "short&q... Re: Which format to use? #4 I did forget to post the picture. I see that PUT with 2 decimal places fixed your program. proc format; picture z0d(round) other = '999999999' (mult=1e2) ; run; On 11/11/08, karma <dorjetarap@googlemail.com> wrote: > On 11 Nov, 12:49, iebup...@GMAIL.COM ("./ ADD NAME=Data _null_,") > wrote: > > I think the OP wanted two decimal places, but I don't think your > > method is doing that. Using Howard's suggestion this PICTURE seems to > > work using your example data. > > > > 1261 data _null_; > > 1... Re: Which format to use? #3 I think the OP wanted two decimal places, but I don't think your method is doing that. Using Howard's suggestion this PICTURE seems to work using your example data. 1261 data _null_; 1262 input x @@; 1263 y = put(input(x,commax12.),z9.); 1264 z = x; 1265 put 'NOTE: Results ' @; 1266 put (_all_)(/= 'NOTE- '); 1267 format z z0d.; 1268 cards; NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column). 1263:18 NOTE: Results x=123.44 y=000012344 z=000012344 NOTE: Results ... Re: help using formats #2 Meg , Okay, lets back up and ask the all important question that should have been asked from the get go: What are you trying to do? Toby Dunn When everything is coming at you all at once, your in the wrong lane. A truly happy person is someone who can smile and enjoy the scenery on a detour. From: Meg <napu1975@HOTMAIL.COM> Reply-To: Meg <napu1975@HOTMAIL.COM> To: SAS-L@LISTSERV.UGA.EDU Subject: Re: help using formats Date: Thu, 31 Aug 2006 11:39:55 -0700 Thanks...maybe I should be more specific. I don't need to change it into a character variable, i just want t... Problem using 'break' Hi, For some reason MALTLAB wont let me use 'break' to get out of a 'for' loop, below is the snippet of code which I keep getting the following error... "Expression or statement is incomplete or incorrect." - refering to the line with the 'break' statement for i=1:image_dim if (stack_coord(1,i)<image_dim) if stack(stack_coord(1,i),stack_coord(2,i),stack_coord(3,i))==255 pix_count(div_count)=pix_count(div_count)+1; else break end end end Shouldnt this code pop me out of the &... Re: help using formats #3 Meg , Let me get this striaght, you have a numeric variable which already has a format associated with it. Howeevr, you dont like the groups of theis format because it doesnt roll the variable values up to a high enough abstraction for you. So you want SAS to magically read your mind as to what formatted value goes to what abstracted group. NPot gonna happen, you have to tell SAS one way or the other what groups you want. Well simplest thing is create another format that uses the unformatted values of the variable and simply use that one instead. While a variable may very well have a on... Re: help using formats #4 On Thu, 31 Aug 2006 18:02:52 -0700, Meg <napu1975@HOTMAIL.COM> wrote: >okay here is exactly what I have. I have Clinic, which is numeric >three digit variable (ie 101=ER, 350=Geriatric care)... > >below is a formated freq of the clinics (shortened). I want to do >something like this >if >clinic in ('Geriatric Medicine','Prime/med', etc) then care='Primary >care'; Notice that you capitalized the first letter in "Medicine", whereas in the list below it is not capitalized. Consequently, you will not get the match you expect. Peop... Re: using format in SQL #2 Try the following and the output is at the end: data recip_id_info; input els_race$ @@ ; cards; 1 2 1 1 2 2 3 4 6 2 1 2 1 0 ; ; proc format; value $race '1'='White' '2'='Black' other='Others'; proc sql; select race, count(race) as RaceCount from (select put(els_race,$race.) as race, A.* from recip_id_info A) group by race; quit; ***** Output ***** The SAS System 18:10 Monday, January 16, 2006 1 race RaceCount ...

Re: Using Clipboard with my own format #2
What I don't understand is how the GetData give back the data in clipboard, so I thought only in declaring a variable and allocating memory so as the GetData method would call my GetDataHere in order to give back the data to the struct that I only allocated. If I had to pass each value of the float *clipboard it wouldn't work, because I would be doing something like this : for (int i = 0; i < size; i++) clipboard[i] = m_clipboard.m_samples[i]; But my m_clipboard would be empty (just declare a clipContainer data(clipSize, clp, true) in order to fill the...

Re: using format in SQL #4
Hi, Sigurd: Thank you for the detail explianation, your code works very well. Also, thank all others for the response. baogong On 1/16/06, Sigurd Hermansen <HERMANS1@westat.com> wrote: > > Baogong: > Your program is working up to a point. I wonder about that. I would have > thought that 'format $race.' would generate a syntax error. > > The difficulty that you are encountering comes about because the GROUP > BY column variable really does have six states (els_race in > (0,1,2,3,4,6)). SAS SQL forms six bins for the six groups and adds one > to the ... Re: using format in SQL #3 Baogong: Your program is working up to a point. I wonder about that. I would have thought that 'format$race.' would generate a syntax error. The difficulty that you are encountering comes about because the GROUP BY column variable really does have six states (els_race in (0,1,2,3,4,6)). SAS SQL forms six bins for the six groups and adds one to the appropriate bin total as it processes each row of data in recip_id_info. SAS SQL does not form groups of formatted values. You did not ask it to do that. I would be surprised to learn that the SAS SQL compiler is substituting formatted valu...

Very useful... 'break' accepts an argument
Greetings, I just discovered undocumented but very useful syntax: break <expression> The expression seems to add a useful feature to a 'while', 'until' or 'for' control structure. For example: result = while <condition> ... break <something> ... end 'result' is nil if the loop exits with <condition> and is <something> if the break is executed. Very useful and provides an cool addition to an already elegant collection of iterator constructs! Tom Agnew3 Tom Agnew wrote: > Greetings, > > I just discovere...

How can a use formating with the print #1 command
I am writing to a cvs file using the print #1 command. My problem is with one number that is to big and it comes in a char format from de data base. The number is like thi one: 91801456321456 and it ends up in excel like this: 8.1302E+13 When I change the cell format from general tu number i works fin So the question is, how can I format the number before send it to excel? Thanks a lot, Lina On 26 Apr 2006 20:38:30 -0700, lina.manjarres@gmail.com wrote: >I am writing to a cvs file using the print #1 command. >My problem is with one number that is to big and it comes in a char >...

Skip an item to WRITE using a FORMAT #2
> Is it possible to skip the WRITE'ing of an item in an output list by > modifying the FORMAT? For example, to print elements [1,2,4] of array > ivec(1:4) I can just write write (*,"(100i6)") ivec((/1,2,4/)) > but I would like to do it as write (*,fmt_skip) ivec > where fmt_skip tells the compiler to skip printing ivec(3). I want to > be able to change the output of a program by changing the format > string, which can be read from a text file, rather than changing the > source code. It would be nice if something like write (*,"(2i6,-,100i6)...

Formating equation for the use of 'roots'
I need to find out the roots of a polynomial, but the problem is that is not in canonical form. To be more clear, I need to find the roots of (a0 + a1*x + a2*x?)^n * (b0 + b1*x + b2*x?)^m + (c0 + c1*x + c2*x?)^p = 0 and I'm trying to format this expression in order to use the 'roots' function. To do it so I've been using the multinomial theorem and trying to create the vector input for the 'roots' function, but I'm pretty sure something is not right. Anye suggestions on how to approach such problem? "Manuel " <reychiquito@excite.com.remove.this> ...

Re: formatting titles when using bodytitle #3
On Tue, 11 Apr 2006, Terjeson, Mark (IM&R) wrote: Mark and Ya - Thanks for your comments. I can't replicate your example, Ya - I don't know why. I thought bobytitle had been introduced with version 9. When I use bc in my title statement, I don't get an error but I also don't get any background color! Mark for sharing this elegant code! However, it's well beyond what I'm capable of doing now with this new (to me) RTF stuff. After reading & experimenting some more, I don't think I can do what I wanted to do. I was assuming that the option bodytitle cr...

Using GDG's in an CICS environment.
Respected gentlemen, Can any one of you please tell me whether is it possible to use GDG's (Generation Data Groups) in CICS ? If yes how ? Thanx in advance, Ace. -- Posted via http://dbforums.com On Wed, 27 Aug 2003 11:25:37 -0400 Ace11 <member25371@dbforums.com> wrote: :>Can any one of you please tell me whether is it possible to use GDG's :>(Generation Data Groups) in CICS ? If yes how ? Yes. What do you want to do with them? CICS system programmers do not take kindly to CICS programmers who use QSAM to access files. -- Binyamin Dissen <bdissen@disse...