Hang rest of paragraph after specific point (or token)
up vote
1
down vote
favorite
Say I have some point in a sentence that I want the rest of the paragraph to hang after; result like this:
PART / Long title that won't fit on one line that
we want hanged after the slash on the next line
I made this work ish by calculating the width of a box containing the PART /
prefix, like so:
documentclass{article}
% Prevent extra indent
setlengthparindent{0pt}
% Box to contain the stuff that the text will hang after
newboxpartprefixBox
% The stuff that the text will hang after
defpartprefix{Large PART /nobreakspace}
% Set part-header-prefix into the box
setboxpartprefixBox=hbox{partprefix}
begin{document}
bgroup
% Set the hangindent size (using the box width)
hangindent=wdpartprefixBox%
hangafter=1%
partprefix Long title that won't fit on one line that we want hanged after the slash on the next linepar
egroup
end{document}
I'm wondering if there is a more robust way of doing this, and whether there is a way to do it with centered text (i.e. if the text is not gonna break, then it should be centered).
Ideally something like a hanghere
command that would work like so:
PART / hanghere Long title that won't fit on one line that we want hanged after the slash on the next line
or this syntax would also work
hanghere{PART / }Long title that won't fit on one line that we want hanged after the slash on the next line
and produce the first mentioned result
Any ideas?
Help is very much appreciated.
horizontal-alignment indentation justification
add a comment |
up vote
1
down vote
favorite
Say I have some point in a sentence that I want the rest of the paragraph to hang after; result like this:
PART / Long title that won't fit on one line that
we want hanged after the slash on the next line
I made this work ish by calculating the width of a box containing the PART /
prefix, like so:
documentclass{article}
% Prevent extra indent
setlengthparindent{0pt}
% Box to contain the stuff that the text will hang after
newboxpartprefixBox
% The stuff that the text will hang after
defpartprefix{Large PART /nobreakspace}
% Set part-header-prefix into the box
setboxpartprefixBox=hbox{partprefix}
begin{document}
bgroup
% Set the hangindent size (using the box width)
hangindent=wdpartprefixBox%
hangafter=1%
partprefix Long title that won't fit on one line that we want hanged after the slash on the next linepar
egroup
end{document}
I'm wondering if there is a more robust way of doing this, and whether there is a way to do it with centered text (i.e. if the text is not gonna break, then it should be centered).
Ideally something like a hanghere
command that would work like so:
PART / hanghere Long title that won't fit on one line that we want hanged after the slash on the next line
or this syntax would also work
hanghere{PART / }Long title that won't fit on one line that we want hanged after the slash on the next line
and produce the first mentioned result
Any ideas?
Help is very much appreciated.
horizontal-alignment indentation justification
It would be easier withhangat{PART} Long title...
– egreg
Dec 6 at 15:04
@egreg that syntax would definitely work!
– Andreas Storvik Strauman
Dec 6 at 15:10
If you want to center the thing when it fits a line, then both parts should be passed as arguments.
– egreg
Dec 6 at 16:06
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
Say I have some point in a sentence that I want the rest of the paragraph to hang after; result like this:
PART / Long title that won't fit on one line that
we want hanged after the slash on the next line
I made this work ish by calculating the width of a box containing the PART /
prefix, like so:
documentclass{article}
% Prevent extra indent
setlengthparindent{0pt}
% Box to contain the stuff that the text will hang after
newboxpartprefixBox
% The stuff that the text will hang after
defpartprefix{Large PART /nobreakspace}
% Set part-header-prefix into the box
setboxpartprefixBox=hbox{partprefix}
begin{document}
bgroup
% Set the hangindent size (using the box width)
hangindent=wdpartprefixBox%
hangafter=1%
partprefix Long title that won't fit on one line that we want hanged after the slash on the next linepar
egroup
end{document}
I'm wondering if there is a more robust way of doing this, and whether there is a way to do it with centered text (i.e. if the text is not gonna break, then it should be centered).
Ideally something like a hanghere
command that would work like so:
PART / hanghere Long title that won't fit on one line that we want hanged after the slash on the next line
or this syntax would also work
hanghere{PART / }Long title that won't fit on one line that we want hanged after the slash on the next line
and produce the first mentioned result
Any ideas?
Help is very much appreciated.
horizontal-alignment indentation justification
Say I have some point in a sentence that I want the rest of the paragraph to hang after; result like this:
PART / Long title that won't fit on one line that
we want hanged after the slash on the next line
I made this work ish by calculating the width of a box containing the PART /
prefix, like so:
documentclass{article}
% Prevent extra indent
setlengthparindent{0pt}
% Box to contain the stuff that the text will hang after
newboxpartprefixBox
% The stuff that the text will hang after
defpartprefix{Large PART /nobreakspace}
% Set part-header-prefix into the box
setboxpartprefixBox=hbox{partprefix}
begin{document}
bgroup
% Set the hangindent size (using the box width)
hangindent=wdpartprefixBox%
hangafter=1%
partprefix Long title that won't fit on one line that we want hanged after the slash on the next linepar
egroup
end{document}
I'm wondering if there is a more robust way of doing this, and whether there is a way to do it with centered text (i.e. if the text is not gonna break, then it should be centered).
Ideally something like a hanghere
command that would work like so:
PART / hanghere Long title that won't fit on one line that we want hanged after the slash on the next line
or this syntax would also work
hanghere{PART / }Long title that won't fit on one line that we want hanged after the slash on the next line
and produce the first mentioned result
Any ideas?
Help is very much appreciated.
horizontal-alignment indentation justification
horizontal-alignment indentation justification
edited Dec 6 at 15:11
asked Dec 6 at 14:26
Andreas Storvik Strauman
2,368418
2,368418
It would be easier withhangat{PART} Long title...
– egreg
Dec 6 at 15:04
@egreg that syntax would definitely work!
– Andreas Storvik Strauman
Dec 6 at 15:10
If you want to center the thing when it fits a line, then both parts should be passed as arguments.
– egreg
Dec 6 at 16:06
add a comment |
It would be easier withhangat{PART} Long title...
– egreg
Dec 6 at 15:04
@egreg that syntax would definitely work!
– Andreas Storvik Strauman
Dec 6 at 15:10
If you want to center the thing when it fits a line, then both parts should be passed as arguments.
– egreg
Dec 6 at 16:06
It would be easier with
hangat{PART} Long title...
– egreg
Dec 6 at 15:04
It would be easier with
hangat{PART} Long title...
– egreg
Dec 6 at 15:04
@egreg that syntax would definitely work!
– Andreas Storvik Strauman
Dec 6 at 15:10
@egreg that syntax would definitely work!
– Andreas Storvik Strauman
Dec 6 at 15:10
If you want to center the thing when it fits a line, then both parts should be passed as arguments.
– egreg
Dec 6 at 16:06
If you want to center the thing when it fits a line, then both parts should be passed as arguments.
– egreg
Dec 6 at 16:06
add a comment |
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
Measure the natural width and decide:
documentclass{article}
newlength{partlength}
newcommand{perhapshang}[2]{%
parnoindent
sbox0{#1 / #2}%
ifdimwd0<linewidth
makebox[linewidth]{usebox0}%
else
settowidth{partlength}{#1mbox{ }/mbox{ }}%
hangafter 1
hangindentpartlength
#1mbox{ }/mbox{ }#2
fi
par
}
begin{document}
perhapshang{PART}{Long title that won't fit on one line
that we want hanged after the slash on the next line}
perhapshang{PART}{This is short}
end{document}
I use mbox{ }
in order to get rigid space.
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',
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%2f463522%2fhang-rest-of-paragraph-after-specific-point-or-token%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
up vote
2
down vote
accepted
Measure the natural width and decide:
documentclass{article}
newlength{partlength}
newcommand{perhapshang}[2]{%
parnoindent
sbox0{#1 / #2}%
ifdimwd0<linewidth
makebox[linewidth]{usebox0}%
else
settowidth{partlength}{#1mbox{ }/mbox{ }}%
hangafter 1
hangindentpartlength
#1mbox{ }/mbox{ }#2
fi
par
}
begin{document}
perhapshang{PART}{Long title that won't fit on one line
that we want hanged after the slash on the next line}
perhapshang{PART}{This is short}
end{document}
I use mbox{ }
in order to get rigid space.
add a comment |
up vote
2
down vote
accepted
Measure the natural width and decide:
documentclass{article}
newlength{partlength}
newcommand{perhapshang}[2]{%
parnoindent
sbox0{#1 / #2}%
ifdimwd0<linewidth
makebox[linewidth]{usebox0}%
else
settowidth{partlength}{#1mbox{ }/mbox{ }}%
hangafter 1
hangindentpartlength
#1mbox{ }/mbox{ }#2
fi
par
}
begin{document}
perhapshang{PART}{Long title that won't fit on one line
that we want hanged after the slash on the next line}
perhapshang{PART}{This is short}
end{document}
I use mbox{ }
in order to get rigid space.
add a comment |
up vote
2
down vote
accepted
up vote
2
down vote
accepted
Measure the natural width and decide:
documentclass{article}
newlength{partlength}
newcommand{perhapshang}[2]{%
parnoindent
sbox0{#1 / #2}%
ifdimwd0<linewidth
makebox[linewidth]{usebox0}%
else
settowidth{partlength}{#1mbox{ }/mbox{ }}%
hangafter 1
hangindentpartlength
#1mbox{ }/mbox{ }#2
fi
par
}
begin{document}
perhapshang{PART}{Long title that won't fit on one line
that we want hanged after the slash on the next line}
perhapshang{PART}{This is short}
end{document}
I use mbox{ }
in order to get rigid space.
Measure the natural width and decide:
documentclass{article}
newlength{partlength}
newcommand{perhapshang}[2]{%
parnoindent
sbox0{#1 / #2}%
ifdimwd0<linewidth
makebox[linewidth]{usebox0}%
else
settowidth{partlength}{#1mbox{ }/mbox{ }}%
hangafter 1
hangindentpartlength
#1mbox{ }/mbox{ }#2
fi
par
}
begin{document}
perhapshang{PART}{Long title that won't fit on one line
that we want hanged after the slash on the next line}
perhapshang{PART}{This is short}
end{document}
I use mbox{ }
in order to get rigid space.
answered Dec 6 at 16:16
egreg
704k8618763155
704k8618763155
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2f463522%2fhang-rest-of-paragraph-after-specific-point-or-token%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
It would be easier with
hangat{PART} Long title...
– egreg
Dec 6 at 15:04
@egreg that syntax would definitely work!
– Andreas Storvik Strauman
Dec 6 at 15:10
If you want to center the thing when it fits a line, then both parts should be passed as arguments.
– egreg
Dec 6 at 16:06