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 14343 times
-
- code1.png (5.89 KiB) Viewed 14343 times
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
- Stefan Kottwitz
- Site Admin
- Posts: 10324
- 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 14321 times
-
- break1.png (7.66 KiB) Viewed 14324 times
- Stefan Kottwitz
- Site Admin
- Posts: 10324
- 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 14318 times
-
- showspacefalse.png (6.25 KiB) Viewed 14319 times
- Stefan Kottwitz
- Site Admin
- Posts: 10324
- 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: 10324
- Joined: Mon Mar 10, 2008 9:44 pm
Re: Creating a line break in a code sample

Stefan