Editor breaks line within lstlisting
I'm using an editor that breaks lines after a line length of 80 characters. Whenever I use a long lstinline
at the end of a line and the editor continues in a new line I get the error message Package Listings: lstinline ended by EOL.
Consider following example:
documentclass{article}
usepackage{listings}
lstset{
breaklines=true,
breakatwhitespace=true,
language=c,
basicstyle=smallttfamily,
numbers=left,
numberstyle=tiny,
frame=tb,
keepspaces=true,
columns=fullflexible,
showstringspaces=false,
}
begin{document}
This is a text with a long function in lstinline|void some_func(int
some_argument)|, where the editor automatically adds a second line.
end{document}
The editor automatically adds a new line after void some_func(int
which results in the error message. Is there a way to span the lstlisting
command over multiple lines?
listings line-breaking lstlisting
add a comment |
I'm using an editor that breaks lines after a line length of 80 characters. Whenever I use a long lstinline
at the end of a line and the editor continues in a new line I get the error message Package Listings: lstinline ended by EOL.
Consider following example:
documentclass{article}
usepackage{listings}
lstset{
breaklines=true,
breakatwhitespace=true,
language=c,
basicstyle=smallttfamily,
numbers=left,
numberstyle=tiny,
frame=tb,
keepspaces=true,
columns=fullflexible,
showstringspaces=false,
}
begin{document}
This is a text with a long function in lstinline|void some_func(int
some_argument)|, where the editor automatically adds a second line.
end{document}
The editor automatically adds a new line after void some_func(int
which results in the error message. Is there a way to span the lstlisting
command over multiple lines?
listings line-breaking lstlisting
Why don't you just put the lstinline into a line by itself? With certain exceptions (like verbatim and lstinline) LaTeX converts newlines into spaces (and ignores extra spaces).
– John Kormylo
Feb 5 at 15:37
@JohnKormylo It's possible that a function name has more than 80 characters, so the editor would break lines anyways
– Mike van Dyke
Feb 6 at 9:20
add a comment |
I'm using an editor that breaks lines after a line length of 80 characters. Whenever I use a long lstinline
at the end of a line and the editor continues in a new line I get the error message Package Listings: lstinline ended by EOL.
Consider following example:
documentclass{article}
usepackage{listings}
lstset{
breaklines=true,
breakatwhitespace=true,
language=c,
basicstyle=smallttfamily,
numbers=left,
numberstyle=tiny,
frame=tb,
keepspaces=true,
columns=fullflexible,
showstringspaces=false,
}
begin{document}
This is a text with a long function in lstinline|void some_func(int
some_argument)|, where the editor automatically adds a second line.
end{document}
The editor automatically adds a new line after void some_func(int
which results in the error message. Is there a way to span the lstlisting
command over multiple lines?
listings line-breaking lstlisting
I'm using an editor that breaks lines after a line length of 80 characters. Whenever I use a long lstinline
at the end of a line and the editor continues in a new line I get the error message Package Listings: lstinline ended by EOL.
Consider following example:
documentclass{article}
usepackage{listings}
lstset{
breaklines=true,
breakatwhitespace=true,
language=c,
basicstyle=smallttfamily,
numbers=left,
numberstyle=tiny,
frame=tb,
keepspaces=true,
columns=fullflexible,
showstringspaces=false,
}
begin{document}
This is a text with a long function in lstinline|void some_func(int
some_argument)|, where the editor automatically adds a second line.
end{document}
The editor automatically adds a new line after void some_func(int
which results in the error message. Is there a way to span the lstlisting
command over multiple lines?
listings line-breaking lstlisting
listings line-breaking lstlisting
asked Feb 5 at 10:35
Mike van DykeMike van Dyke
1084
1084
Why don't you just put the lstinline into a line by itself? With certain exceptions (like verbatim and lstinline) LaTeX converts newlines into spaces (and ignores extra spaces).
– John Kormylo
Feb 5 at 15:37
@JohnKormylo It's possible that a function name has more than 80 characters, so the editor would break lines anyways
– Mike van Dyke
Feb 6 at 9:20
add a comment |
Why don't you just put the lstinline into a line by itself? With certain exceptions (like verbatim and lstinline) LaTeX converts newlines into spaces (and ignores extra spaces).
– John Kormylo
Feb 5 at 15:37
@JohnKormylo It's possible that a function name has more than 80 characters, so the editor would break lines anyways
– Mike van Dyke
Feb 6 at 9:20
Why don't you just put the lstinline into a line by itself? With certain exceptions (like verbatim and lstinline) LaTeX converts newlines into spaces (and ignores extra spaces).
– John Kormylo
Feb 5 at 15:37
Why don't you just put the lstinline into a line by itself? With certain exceptions (like verbatim and lstinline) LaTeX converts newlines into spaces (and ignores extra spaces).
– John Kormylo
Feb 5 at 15:37
@JohnKormylo It's possible that a function name has more than 80 characters, so the editor would break lines anyways
– Mike van Dyke
Feb 6 at 9:20
@JohnKormylo It's possible that a function name has more than 80 characters, so the editor would break lines anyways
– Mike van Dyke
Feb 6 at 9:20
add a comment |
1 Answer
1
active
oldest
votes
I couldn't find a key-value interface for this in listings.sty
, so here's here's a hard coded method. You have to change the macro lst@InlineM
:
deflst@InlineM#1{gdeflst@inlinechars{%
lst@Def{`#1}{lst@DeInitegroupgloballetlst@inlinechars@empty}%
lst@Def{13}{lst@DeInitegroup globalletlst@inlinechars@empty
PackageError{Listings}{lstinline ended by EOL}@ehc}}% <--- Error message
lst@inlinechars}
to something that doesn't produce an error. The default behaviour is to end the lstinline
(with lst@DeInitegroup
) then throw an error. To make the new line behave as a space you can do:
deflst@InlineM#1{gdeflst@inlinechars{%
lst@Def{`#1}{lst@DeInitegroupgloballetlst@inlinechars@empty}%
lst@Def{13}{lst@ProcessSpace}}% <---
lst@inlinechars}
MWE:
documentclass{article}
usepackage{listings}
lstset{
breaklines=true,
breakatwhitespace=true,
language=c,
basicstyle=smallttfamily,
numbers=left,
numberstyle=tiny,
frame=tb,
keepspaces=true,
columns=fullflexible,
showstringspaces=false,
}
makeatletter
deflst@InlineM#1{gdeflst@inlinechars{%
lst@Def{`#1}{lst@DeInitegroupgloballetlst@inlinechars@empty}%
lst@Def{13}{lst@ProcessSpace}}%
lst@inlinechars}
makeatother
begin{document}
This is a text with a long function in lstinline|void some_func(int
some_argument)|, where the editor automatically adds a second line.
end{document}
1
Imho it is rather dangerous: If you forget the closing delimiter in the lstinline it will eat up your document and you can get rather bewildering errors. I would change the input or the editor.
– Ulrike Fischer
Feb 5 at 12:04
@UlrikeFischer I completely agree. However many editors have a reasonable syntax highlighting which will make the mistake obvious. But if someone writesmakeatletter
they should be willing to pay the price ;)
– Phelype Oleinik
Feb 5 at 12:25
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f473457%2feditor-breaks-line-within-lstlisting%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I couldn't find a key-value interface for this in listings.sty
, so here's here's a hard coded method. You have to change the macro lst@InlineM
:
deflst@InlineM#1{gdeflst@inlinechars{%
lst@Def{`#1}{lst@DeInitegroupgloballetlst@inlinechars@empty}%
lst@Def{13}{lst@DeInitegroup globalletlst@inlinechars@empty
PackageError{Listings}{lstinline ended by EOL}@ehc}}% <--- Error message
lst@inlinechars}
to something that doesn't produce an error. The default behaviour is to end the lstinline
(with lst@DeInitegroup
) then throw an error. To make the new line behave as a space you can do:
deflst@InlineM#1{gdeflst@inlinechars{%
lst@Def{`#1}{lst@DeInitegroupgloballetlst@inlinechars@empty}%
lst@Def{13}{lst@ProcessSpace}}% <---
lst@inlinechars}
MWE:
documentclass{article}
usepackage{listings}
lstset{
breaklines=true,
breakatwhitespace=true,
language=c,
basicstyle=smallttfamily,
numbers=left,
numberstyle=tiny,
frame=tb,
keepspaces=true,
columns=fullflexible,
showstringspaces=false,
}
makeatletter
deflst@InlineM#1{gdeflst@inlinechars{%
lst@Def{`#1}{lst@DeInitegroupgloballetlst@inlinechars@empty}%
lst@Def{13}{lst@ProcessSpace}}%
lst@inlinechars}
makeatother
begin{document}
This is a text with a long function in lstinline|void some_func(int
some_argument)|, where the editor automatically adds a second line.
end{document}
1
Imho it is rather dangerous: If you forget the closing delimiter in the lstinline it will eat up your document and you can get rather bewildering errors. I would change the input or the editor.
– Ulrike Fischer
Feb 5 at 12:04
@UlrikeFischer I completely agree. However many editors have a reasonable syntax highlighting which will make the mistake obvious. But if someone writesmakeatletter
they should be willing to pay the price ;)
– Phelype Oleinik
Feb 5 at 12:25
add a comment |
I couldn't find a key-value interface for this in listings.sty
, so here's here's a hard coded method. You have to change the macro lst@InlineM
:
deflst@InlineM#1{gdeflst@inlinechars{%
lst@Def{`#1}{lst@DeInitegroupgloballetlst@inlinechars@empty}%
lst@Def{13}{lst@DeInitegroup globalletlst@inlinechars@empty
PackageError{Listings}{lstinline ended by EOL}@ehc}}% <--- Error message
lst@inlinechars}
to something that doesn't produce an error. The default behaviour is to end the lstinline
(with lst@DeInitegroup
) then throw an error. To make the new line behave as a space you can do:
deflst@InlineM#1{gdeflst@inlinechars{%
lst@Def{`#1}{lst@DeInitegroupgloballetlst@inlinechars@empty}%
lst@Def{13}{lst@ProcessSpace}}% <---
lst@inlinechars}
MWE:
documentclass{article}
usepackage{listings}
lstset{
breaklines=true,
breakatwhitespace=true,
language=c,
basicstyle=smallttfamily,
numbers=left,
numberstyle=tiny,
frame=tb,
keepspaces=true,
columns=fullflexible,
showstringspaces=false,
}
makeatletter
deflst@InlineM#1{gdeflst@inlinechars{%
lst@Def{`#1}{lst@DeInitegroupgloballetlst@inlinechars@empty}%
lst@Def{13}{lst@ProcessSpace}}%
lst@inlinechars}
makeatother
begin{document}
This is a text with a long function in lstinline|void some_func(int
some_argument)|, where the editor automatically adds a second line.
end{document}
1
Imho it is rather dangerous: If you forget the closing delimiter in the lstinline it will eat up your document and you can get rather bewildering errors. I would change the input or the editor.
– Ulrike Fischer
Feb 5 at 12:04
@UlrikeFischer I completely agree. However many editors have a reasonable syntax highlighting which will make the mistake obvious. But if someone writesmakeatletter
they should be willing to pay the price ;)
– Phelype Oleinik
Feb 5 at 12:25
add a comment |
I couldn't find a key-value interface for this in listings.sty
, so here's here's a hard coded method. You have to change the macro lst@InlineM
:
deflst@InlineM#1{gdeflst@inlinechars{%
lst@Def{`#1}{lst@DeInitegroupgloballetlst@inlinechars@empty}%
lst@Def{13}{lst@DeInitegroup globalletlst@inlinechars@empty
PackageError{Listings}{lstinline ended by EOL}@ehc}}% <--- Error message
lst@inlinechars}
to something that doesn't produce an error. The default behaviour is to end the lstinline
(with lst@DeInitegroup
) then throw an error. To make the new line behave as a space you can do:
deflst@InlineM#1{gdeflst@inlinechars{%
lst@Def{`#1}{lst@DeInitegroupgloballetlst@inlinechars@empty}%
lst@Def{13}{lst@ProcessSpace}}% <---
lst@inlinechars}
MWE:
documentclass{article}
usepackage{listings}
lstset{
breaklines=true,
breakatwhitespace=true,
language=c,
basicstyle=smallttfamily,
numbers=left,
numberstyle=tiny,
frame=tb,
keepspaces=true,
columns=fullflexible,
showstringspaces=false,
}
makeatletter
deflst@InlineM#1{gdeflst@inlinechars{%
lst@Def{`#1}{lst@DeInitegroupgloballetlst@inlinechars@empty}%
lst@Def{13}{lst@ProcessSpace}}%
lst@inlinechars}
makeatother
begin{document}
This is a text with a long function in lstinline|void some_func(int
some_argument)|, where the editor automatically adds a second line.
end{document}
I couldn't find a key-value interface for this in listings.sty
, so here's here's a hard coded method. You have to change the macro lst@InlineM
:
deflst@InlineM#1{gdeflst@inlinechars{%
lst@Def{`#1}{lst@DeInitegroupgloballetlst@inlinechars@empty}%
lst@Def{13}{lst@DeInitegroup globalletlst@inlinechars@empty
PackageError{Listings}{lstinline ended by EOL}@ehc}}% <--- Error message
lst@inlinechars}
to something that doesn't produce an error. The default behaviour is to end the lstinline
(with lst@DeInitegroup
) then throw an error. To make the new line behave as a space you can do:
deflst@InlineM#1{gdeflst@inlinechars{%
lst@Def{`#1}{lst@DeInitegroupgloballetlst@inlinechars@empty}%
lst@Def{13}{lst@ProcessSpace}}% <---
lst@inlinechars}
MWE:
documentclass{article}
usepackage{listings}
lstset{
breaklines=true,
breakatwhitespace=true,
language=c,
basicstyle=smallttfamily,
numbers=left,
numberstyle=tiny,
frame=tb,
keepspaces=true,
columns=fullflexible,
showstringspaces=false,
}
makeatletter
deflst@InlineM#1{gdeflst@inlinechars{%
lst@Def{`#1}{lst@DeInitegroupgloballetlst@inlinechars@empty}%
lst@Def{13}{lst@ProcessSpace}}%
lst@inlinechars}
makeatother
begin{document}
This is a text with a long function in lstinline|void some_func(int
some_argument)|, where the editor automatically adds a second line.
end{document}
answered Feb 5 at 10:54
Phelype OleinikPhelype Oleinik
22.9k54483
22.9k54483
1
Imho it is rather dangerous: If you forget the closing delimiter in the lstinline it will eat up your document and you can get rather bewildering errors. I would change the input or the editor.
– Ulrike Fischer
Feb 5 at 12:04
@UlrikeFischer I completely agree. However many editors have a reasonable syntax highlighting which will make the mistake obvious. But if someone writesmakeatletter
they should be willing to pay the price ;)
– Phelype Oleinik
Feb 5 at 12:25
add a comment |
1
Imho it is rather dangerous: If you forget the closing delimiter in the lstinline it will eat up your document and you can get rather bewildering errors. I would change the input or the editor.
– Ulrike Fischer
Feb 5 at 12:04
@UlrikeFischer I completely agree. However many editors have a reasonable syntax highlighting which will make the mistake obvious. But if someone writesmakeatletter
they should be willing to pay the price ;)
– Phelype Oleinik
Feb 5 at 12:25
1
1
Imho it is rather dangerous: If you forget the closing delimiter in the lstinline it will eat up your document and you can get rather bewildering errors. I would change the input or the editor.
– Ulrike Fischer
Feb 5 at 12:04
Imho it is rather dangerous: If you forget the closing delimiter in the lstinline it will eat up your document and you can get rather bewildering errors. I would change the input or the editor.
– Ulrike Fischer
Feb 5 at 12:04
@UlrikeFischer I completely agree. However many editors have a reasonable syntax highlighting which will make the mistake obvious. But if someone writes
makeatletter
they should be willing to pay the price ;)– Phelype Oleinik
Feb 5 at 12:25
@UlrikeFischer I completely agree. However many editors have a reasonable syntax highlighting which will make the mistake obvious. But if someone writes
makeatletter
they should be willing to pay the price ;)– Phelype Oleinik
Feb 5 at 12:25
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f473457%2feditor-breaks-line-within-lstlisting%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Why don't you just put the lstinline into a line by itself? With certain exceptions (like verbatim and lstinline) LaTeX converts newlines into spaces (and ignores extra spaces).
– John Kormylo
Feb 5 at 15:37
@JohnKormylo It's possible that a function name has more than 80 characters, so the editor would break lines anyways
– Mike van Dyke
Feb 6 at 9:20