Listings breaklines at predefined placeslstlisting line wrappinglistings breaklines not workingLong lines...
Reading Mishnayos without understanding
Word for something that's always reliable, but never the best?
Is Screenshot Time-tracking Common?
What species should be used for storage of human minds?
Plausible reason for gold-digging ant
Caron Accent v{a} doesn't render without usepackage{xeCJK}
What is a good way to explain how a character can produce flames from their body?
How to write cases in LaTeX?
How do I avoid the "chosen hero" feeling?
Taking an academic pseudonym?
Should a new user just default to LinearModelFit (vs Fit)
Can me and my friend spend the summer in Canada (6 weeks) at 16 years old without an adult?
Does the US government have any planning in place to ensure there's no shortages of food, fuel, steel and other commodities?
Possible issue with my W4 and tax return
Renting a 2CV in France
Sharepoint metadata URL
Charging phone battery with a lower voltage, coming from a bike charger?
Modern Algebraic Geometry and Analytic Number Theory
Icon at Subject-line scrlttr2
"Starve to death" Vs. "Starve to the point of death"
Why does typing a variable (or expression) print the value to stdout?
Is there a non trivial covering of the Klein bottle by the Klein bottle
Coworker asking me to not bring cakes due to self control issue. What should I do?
Why did Mr. Elliot have to decide whose boots were thickest in "Persuasion"?
Listings breaklines at predefined places
lstlisting line wrappinglistings breaklines not workingLong lines when using listingsWhy doesn't listings' breaklines work, here?tex4ht and listings: lines don't break when using escapeinsidelistings breaking line despite breaklines=falseAllowing hyphenation of words containing commandsPrint text on the left margin aligned with a given linelstnewenvironment/lstset : using colors conditionally emph/emphstyle - SAS: (in=_x) versus if x in (1,2)Listing breaklines not workinglistings breaklines and escapeinside vs marginnote
The code lines I write within a lstlisting sometimes are too long. So at the end a line break occurs. But sometimes these breaks are not well chosen and can make the code much more unreadable.
Is there a way to predefine the places where a break should appear if it is necessary?
My document:
documentclass{book}
usepackage[utf8]{inputenc}
usepackage[english]{babel}
usepackage{listings}
lstdefinestyle{General} {
basicstyle=smallttfamily,
breaklines=true
}
lstset{style=General}
begin{document}
begin{lstlisting}
This is a very long listing which eventually needs a break at the end of this beautiful line.
end{lstlisting}
end{document}
In this case the line break occurs after "break". It would be great to define the break after "listing" for example. Or maybe a second one after "beautiful" if there is enough space (maybe after changing some document settings as borders or format). In that case the first one should be ignored.
listings line-breaking
add a comment |
The code lines I write within a lstlisting sometimes are too long. So at the end a line break occurs. But sometimes these breaks are not well chosen and can make the code much more unreadable.
Is there a way to predefine the places where a break should appear if it is necessary?
My document:
documentclass{book}
usepackage[utf8]{inputenc}
usepackage[english]{babel}
usepackage{listings}
lstdefinestyle{General} {
basicstyle=smallttfamily,
breaklines=true
}
lstset{style=General}
begin{document}
begin{lstlisting}
This is a very long listing which eventually needs a break at the end of this beautiful line.
end{lstlisting}
end{document}
In this case the line break occurs after "break". It would be great to define the break after "listing" for example. Or maybe a second one after "beautiful" if there is enough space (maybe after changing some document settings as borders or format). In that case the first one should be ignored.
listings line-breaking
add a comment |
The code lines I write within a lstlisting sometimes are too long. So at the end a line break occurs. But sometimes these breaks are not well chosen and can make the code much more unreadable.
Is there a way to predefine the places where a break should appear if it is necessary?
My document:
documentclass{book}
usepackage[utf8]{inputenc}
usepackage[english]{babel}
usepackage{listings}
lstdefinestyle{General} {
basicstyle=smallttfamily,
breaklines=true
}
lstset{style=General}
begin{document}
begin{lstlisting}
This is a very long listing which eventually needs a break at the end of this beautiful line.
end{lstlisting}
end{document}
In this case the line break occurs after "break". It would be great to define the break after "listing" for example. Or maybe a second one after "beautiful" if there is enough space (maybe after changing some document settings as borders or format). In that case the first one should be ignored.
listings line-breaking
The code lines I write within a lstlisting sometimes are too long. So at the end a line break occurs. But sometimes these breaks are not well chosen and can make the code much more unreadable.
Is there a way to predefine the places where a break should appear if it is necessary?
My document:
documentclass{book}
usepackage[utf8]{inputenc}
usepackage[english]{babel}
usepackage{listings}
lstdefinestyle{General} {
basicstyle=smallttfamily,
breaklines=true
}
lstset{style=General}
begin{document}
begin{lstlisting}
This is a very long listing which eventually needs a break at the end of this beautiful line.
end{lstlisting}
end{document}
In this case the line break occurs after "break". It would be great to define the break after "listing" for example. Or maybe a second one after "beautiful" if there is enough space (maybe after changing some document settings as borders or format). In that case the first one should be ignored.
listings line-breaking
listings line-breaking
edited 3 hours ago
S-Man
asked 3 hours ago
S-ManS-Man
1534
1534
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
- Maybe I misunderstand your question, "sometimes these breaks are not well chosen" does not make much sense for typical listing material.
- The content of a listing is treated a
verbatim
(aka: literally, as it is). - Therefore you can add manual line breaks where ever you want.
- In addition, the
listings
package offers automatic line breaks (you enabled it). I marked the automatic line break with an$hookrightarrow$
in addition the default indention. - in addition, you can change the
linewidth
as an option (not shown).
BTW: I do not know why I need to use
mbox
in
mbox{{$hookrightarrow$}space}
. Also~
instead ofspace
caused an error.
documentclass{book}
usepackage{listings}
lstdefinestyle{myListingStyle}
{
basicstyle = smallttfamily,
breaklines = true,
postbreak = mbox{{$hookrightarrow$}space} % See https://tex.stackexchange.com/questions/116534 for example
}
begin{document}
begin{lstlisting}[
style = myListingStyle,
caption = {Natural/Automatic line break.}
]
This is a very long listing which eventually needs a break at the end of this beautiful line.
end{lstlisting}
begin{lstlisting}[
style = myListingStyle,
caption = {Manual line break.}
]
This is a very long listing which eventually
needs a break at the end of this beautiful line.
end{lstlisting}
end{document}
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%2f476572%2flistings-breaklines-at-predefined-places%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
- Maybe I misunderstand your question, "sometimes these breaks are not well chosen" does not make much sense for typical listing material.
- The content of a listing is treated a
verbatim
(aka: literally, as it is). - Therefore you can add manual line breaks where ever you want.
- In addition, the
listings
package offers automatic line breaks (you enabled it). I marked the automatic line break with an$hookrightarrow$
in addition the default indention. - in addition, you can change the
linewidth
as an option (not shown).
BTW: I do not know why I need to use
mbox
in
mbox{{$hookrightarrow$}space}
. Also~
instead ofspace
caused an error.
documentclass{book}
usepackage{listings}
lstdefinestyle{myListingStyle}
{
basicstyle = smallttfamily,
breaklines = true,
postbreak = mbox{{$hookrightarrow$}space} % See https://tex.stackexchange.com/questions/116534 for example
}
begin{document}
begin{lstlisting}[
style = myListingStyle,
caption = {Natural/Automatic line break.}
]
This is a very long listing which eventually needs a break at the end of this beautiful line.
end{lstlisting}
begin{lstlisting}[
style = myListingStyle,
caption = {Manual line break.}
]
This is a very long listing which eventually
needs a break at the end of this beautiful line.
end{lstlisting}
end{document}
add a comment |
- Maybe I misunderstand your question, "sometimes these breaks are not well chosen" does not make much sense for typical listing material.
- The content of a listing is treated a
verbatim
(aka: literally, as it is). - Therefore you can add manual line breaks where ever you want.
- In addition, the
listings
package offers automatic line breaks (you enabled it). I marked the automatic line break with an$hookrightarrow$
in addition the default indention. - in addition, you can change the
linewidth
as an option (not shown).
BTW: I do not know why I need to use
mbox
in
mbox{{$hookrightarrow$}space}
. Also~
instead ofspace
caused an error.
documentclass{book}
usepackage{listings}
lstdefinestyle{myListingStyle}
{
basicstyle = smallttfamily,
breaklines = true,
postbreak = mbox{{$hookrightarrow$}space} % See https://tex.stackexchange.com/questions/116534 for example
}
begin{document}
begin{lstlisting}[
style = myListingStyle,
caption = {Natural/Automatic line break.}
]
This is a very long listing which eventually needs a break at the end of this beautiful line.
end{lstlisting}
begin{lstlisting}[
style = myListingStyle,
caption = {Manual line break.}
]
This is a very long listing which eventually
needs a break at the end of this beautiful line.
end{lstlisting}
end{document}
add a comment |
- Maybe I misunderstand your question, "sometimes these breaks are not well chosen" does not make much sense for typical listing material.
- The content of a listing is treated a
verbatim
(aka: literally, as it is). - Therefore you can add manual line breaks where ever you want.
- In addition, the
listings
package offers automatic line breaks (you enabled it). I marked the automatic line break with an$hookrightarrow$
in addition the default indention. - in addition, you can change the
linewidth
as an option (not shown).
BTW: I do not know why I need to use
mbox
in
mbox{{$hookrightarrow$}space}
. Also~
instead ofspace
caused an error.
documentclass{book}
usepackage{listings}
lstdefinestyle{myListingStyle}
{
basicstyle = smallttfamily,
breaklines = true,
postbreak = mbox{{$hookrightarrow$}space} % See https://tex.stackexchange.com/questions/116534 for example
}
begin{document}
begin{lstlisting}[
style = myListingStyle,
caption = {Natural/Automatic line break.}
]
This is a very long listing which eventually needs a break at the end of this beautiful line.
end{lstlisting}
begin{lstlisting}[
style = myListingStyle,
caption = {Manual line break.}
]
This is a very long listing which eventually
needs a break at the end of this beautiful line.
end{lstlisting}
end{document}
- Maybe I misunderstand your question, "sometimes these breaks are not well chosen" does not make much sense for typical listing material.
- The content of a listing is treated a
verbatim
(aka: literally, as it is). - Therefore you can add manual line breaks where ever you want.
- In addition, the
listings
package offers automatic line breaks (you enabled it). I marked the automatic line break with an$hookrightarrow$
in addition the default indention. - in addition, you can change the
linewidth
as an option (not shown).
BTW: I do not know why I need to use
mbox
in
mbox{{$hookrightarrow$}space}
. Also~
instead ofspace
caused an error.
documentclass{book}
usepackage{listings}
lstdefinestyle{myListingStyle}
{
basicstyle = smallttfamily,
breaklines = true,
postbreak = mbox{{$hookrightarrow$}space} % See https://tex.stackexchange.com/questions/116534 for example
}
begin{document}
begin{lstlisting}[
style = myListingStyle,
caption = {Natural/Automatic line break.}
]
This is a very long listing which eventually needs a break at the end of this beautiful line.
end{lstlisting}
begin{lstlisting}[
style = myListingStyle,
caption = {Manual line break.}
]
This is a very long listing which eventually
needs a break at the end of this beautiful line.
end{lstlisting}
end{document}
edited 11 mins ago
answered 42 mins ago
Dr. Manuel KuehnerDr. Manuel Kuehner
9,08732769
9,08732769
add a comment |
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%2f476572%2flistings-breaklines-at-predefined-places%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