General ⇒ Creating a line break in a code sample
- tripwire45
- Posts: 129
- Joined: Thu Apr 10, 2008 4:35 am
Creating a line break in a code sample
The one bad thing that happens is that very long lines of code run off the right side of the page. I know there is a special symbol that you can include to indicate when an otherwise single line of code is broken, usually for vertical space, but I can't find out how to insert it in LaTeX...particular within two verbatim tags. I'm attaching part of the code sample and the PDF output to show you the issue at hand (I don't think this one needs a minimal working example).
The standard texts and Googling aren't yielding results this time. Can you help out here? Thanks.
-Trip
- Attachments
-
- code2.png (13.8 KiB) Viewed 15242 times
-
- code1.png (5.89 KiB) Viewed 15242 times
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
- Stefan Kottwitz
- Site Admin
- Posts: 10359
- Joined: Mon Mar 10, 2008 9:44 pm
Creating a line break in a code sample
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Creating a line break in a code sample
Best regards
Thorsten¹
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
- tripwire45
- Posts: 129
- Joined: Thu Apr 10, 2008 4:35 am
Re: Creating a line break in a code sample
-Trip
- tripwire45
- Posts: 129
- Joined: Thu Apr 10, 2008 4:35 am
Creating a line break in a code sample
Code: Select all
\usepackage{color,listings}
\lstset{breaklines=true,breakindent=0pt,
prebreak=\mbox{\tiny$\searrow$},
postbreak=\mbox{{\color{blue}\tiny$\rightarrow$}}}
Code: Select all
Response.Write(WebResp.StatusCode & "<br />")
- Attachments
-
- symbol1.png (6.56 KiB) Viewed 15220 times
-
- break1.png (7.66 KiB) Viewed 15223 times
- Stefan Kottwitz
- Site Admin
- Posts: 10359
- Joined: Mon Mar 10, 2008 9:44 pm
Re: Creating a line break in a code sample
it looks like a visible space. Did you set showspaces=true? Or try to set it to false.
Stefan
- tripwire45
- Posts: 129
- Joined: Thu Apr 10, 2008 4:35 am
Creating a line break in a code sample
Code: Select all
\usepackage{color,listings}
\lstset{showspaces=true,breaklines=true,breakindent=0pt,
prebreak=\mbox{\tiny$\searrow$},
postbreak=\mbox{{\color{blue}\tiny$\rightarrow$}}}
- Attachments
-
- showspacetrue.png (6.51 KiB) Viewed 15217 times
-
- showspacefalse.png (6.25 KiB) Viewed 15218 times
- Stefan Kottwitz
- Site Admin
- Posts: 10359
- Joined: Mon Mar 10, 2008 9:44 pm
Creating a line break in a code sample
Stefan
- tripwire45
- Posts: 129
- Joined: Thu Apr 10, 2008 4:35 am
Re: Creating a line break in a code sample

- Stefan Kottwitz
- Site Admin
- Posts: 10359
- Joined: Mon Mar 10, 2008 9:44 pm
Re: Creating a line break in a code sample

Stefan