Environment definition adds vertical space above
I already have found the solution to define a new environment without the additional space above the paragraph. But why does the "vanilla" way of defining this not work?
Pictures

MWE
documentclass[
fontsize=11pt,
DIV=12,
paper=a4,
]{scrartcl}
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage{amsmath}
%%% the GOOD definition
newenvironment{goodgood}{ignorespacesparcenteringbegin{minipage}{0.8linewidth}smallsffamily}{end{minipage}parignorespacesafterend}
%%% the PROBLEMATIC definition
newenvironment{asdf}{begin{center}begin{minipage}{0.8linewidth}smallsffamily}{end{minipage}end{center}}
begin{document}
ABC
begin{asdf}
bad vertical spacing
end{asdf}
DEF
begin{goodgood}
GOOD VERTICAL SPACING
end{goodgood}
AAA
end{document}
spacing environments
|
show 3 more comments
I already have found the solution to define a new environment without the additional space above the paragraph. But why does the "vanilla" way of defining this not work?
Pictures

MWE
documentclass[
fontsize=11pt,
DIV=12,
paper=a4,
]{scrartcl}
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage{amsmath}
%%% the GOOD definition
newenvironment{goodgood}{ignorespacesparcenteringbegin{minipage}{0.8linewidth}smallsffamily}{end{minipage}parignorespacesafterend}
%%% the PROBLEMATIC definition
newenvironment{asdf}{begin{center}begin{minipage}{0.8linewidth}smallsffamily}{end{minipage}end{center}}
begin{document}
ABC
begin{asdf}
bad vertical spacing
end{asdf}
DEF
begin{goodgood}
GOOD VERTICAL SPACING
end{goodgood}
AAA
end{document}
spacing environments
3
AFAIKbegin{center}...end{center}adds space. See tex.stackexchange.com/q/23650/35864. So if you don't want additional space (which together with aminipagecould add up),begin{center}...end{center}is probably not your weapon of choice.
– moewe
Dec 22 '18 at 20:21
2
As for the error: In the MWEsinglespacingis undefined. LaTeX throws an error (which should not be ignored!), but continues pretendingsinglespacingwasn't there.
– moewe
Dec 22 '18 at 20:24
1
I'm not sure if you need theignorespacesat the beginning of the environment definition. It seems somewhat pointless to suppress spaces there, since they would have to come from the macro definition itself and there aren't any. I'm also not sure if theignorespacesafterendis needed here.
– moewe
Dec 22 '18 at 20:36
3
It's a bit later for me now, but I will write up an answer tomorrow if no one complains about what I commented here.
– moewe
Dec 22 '18 at 20:56
2
alsoignorespacesparis the same asparas there are no spaces betweenignorespacesandpar.
– David Carlisle
Dec 22 '18 at 21:02
|
show 3 more comments
I already have found the solution to define a new environment without the additional space above the paragraph. But why does the "vanilla" way of defining this not work?
Pictures

MWE
documentclass[
fontsize=11pt,
DIV=12,
paper=a4,
]{scrartcl}
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage{amsmath}
%%% the GOOD definition
newenvironment{goodgood}{ignorespacesparcenteringbegin{minipage}{0.8linewidth}smallsffamily}{end{minipage}parignorespacesafterend}
%%% the PROBLEMATIC definition
newenvironment{asdf}{begin{center}begin{minipage}{0.8linewidth}smallsffamily}{end{minipage}end{center}}
begin{document}
ABC
begin{asdf}
bad vertical spacing
end{asdf}
DEF
begin{goodgood}
GOOD VERTICAL SPACING
end{goodgood}
AAA
end{document}
spacing environments
I already have found the solution to define a new environment without the additional space above the paragraph. But why does the "vanilla" way of defining this not work?
Pictures

MWE
documentclass[
fontsize=11pt,
DIV=12,
paper=a4,
]{scrartcl}
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage{amsmath}
%%% the GOOD definition
newenvironment{goodgood}{ignorespacesparcenteringbegin{minipage}{0.8linewidth}smallsffamily}{end{minipage}parignorespacesafterend}
%%% the PROBLEMATIC definition
newenvironment{asdf}{begin{center}begin{minipage}{0.8linewidth}smallsffamily}{end{minipage}end{center}}
begin{document}
ABC
begin{asdf}
bad vertical spacing
end{asdf}
DEF
begin{goodgood}
GOOD VERTICAL SPACING
end{goodgood}
AAA
end{document}
spacing environments
spacing environments
edited Dec 23 '18 at 10:14
henry
asked Dec 22 '18 at 20:20
henryhenry
2,85132367
2,85132367
3
AFAIKbegin{center}...end{center}adds space. See tex.stackexchange.com/q/23650/35864. So if you don't want additional space (which together with aminipagecould add up),begin{center}...end{center}is probably not your weapon of choice.
– moewe
Dec 22 '18 at 20:21
2
As for the error: In the MWEsinglespacingis undefined. LaTeX throws an error (which should not be ignored!), but continues pretendingsinglespacingwasn't there.
– moewe
Dec 22 '18 at 20:24
1
I'm not sure if you need theignorespacesat the beginning of the environment definition. It seems somewhat pointless to suppress spaces there, since they would have to come from the macro definition itself and there aren't any. I'm also not sure if theignorespacesafterendis needed here.
– moewe
Dec 22 '18 at 20:36
3
It's a bit later for me now, but I will write up an answer tomorrow if no one complains about what I commented here.
– moewe
Dec 22 '18 at 20:56
2
alsoignorespacesparis the same asparas there are no spaces betweenignorespacesandpar.
– David Carlisle
Dec 22 '18 at 21:02
|
show 3 more comments
3
AFAIKbegin{center}...end{center}adds space. See tex.stackexchange.com/q/23650/35864. So if you don't want additional space (which together with aminipagecould add up),begin{center}...end{center}is probably not your weapon of choice.
– moewe
Dec 22 '18 at 20:21
2
As for the error: In the MWEsinglespacingis undefined. LaTeX throws an error (which should not be ignored!), but continues pretendingsinglespacingwasn't there.
– moewe
Dec 22 '18 at 20:24
1
I'm not sure if you need theignorespacesat the beginning of the environment definition. It seems somewhat pointless to suppress spaces there, since they would have to come from the macro definition itself and there aren't any. I'm also not sure if theignorespacesafterendis needed here.
– moewe
Dec 22 '18 at 20:36
3
It's a bit later for me now, but I will write up an answer tomorrow if no one complains about what I commented here.
– moewe
Dec 22 '18 at 20:56
2
alsoignorespacesparis the same asparas there are no spaces betweenignorespacesandpar.
– David Carlisle
Dec 22 '18 at 21:02
3
3
AFAIK
begin{center}...end{center} adds space. See tex.stackexchange.com/q/23650/35864. So if you don't want additional space (which together with a minipage could add up), begin{center}...end{center} is probably not your weapon of choice.– moewe
Dec 22 '18 at 20:21
AFAIK
begin{center}...end{center} adds space. See tex.stackexchange.com/q/23650/35864. So if you don't want additional space (which together with a minipage could add up), begin{center}...end{center} is probably not your weapon of choice.– moewe
Dec 22 '18 at 20:21
2
2
As for the error: In the MWE
singlespacing is undefined. LaTeX throws an error (which should not be ignored!), but continues pretending singlespacing wasn't there.– moewe
Dec 22 '18 at 20:24
As for the error: In the MWE
singlespacing is undefined. LaTeX throws an error (which should not be ignored!), but continues pretending singlespacing wasn't there.– moewe
Dec 22 '18 at 20:24
1
1
I'm not sure if you need the
ignorespaces at the beginning of the environment definition. It seems somewhat pointless to suppress spaces there, since they would have to come from the macro definition itself and there aren't any. I'm also not sure if the ignorespacesafterend is needed here.– moewe
Dec 22 '18 at 20:36
I'm not sure if you need the
ignorespaces at the beginning of the environment definition. It seems somewhat pointless to suppress spaces there, since they would have to come from the macro definition itself and there aren't any. I'm also not sure if the ignorespacesafterend is needed here.– moewe
Dec 22 '18 at 20:36
3
3
It's a bit later for me now, but I will write up an answer tomorrow if no one complains about what I commented here.
– moewe
Dec 22 '18 at 20:56
It's a bit later for me now, but I will write up an answer tomorrow if no one complains about what I commented here.
– moewe
Dec 22 '18 at 20:56
2
2
also
ignorespacespar is the same as par as there are no spaces between ignorespaces and par.– David Carlisle
Dec 22 '18 at 21:02
also
ignorespacespar is the same as par as there are no spaces between ignorespaces and par.– David Carlisle
Dec 22 '18 at 21:02
|
show 3 more comments
1 Answer
1
active
oldest
votes
As explained in When should we use begin{center} instead of centering? begin{center}...end{center} is implemented via a list (trivlist) and causes vertical space before and after the centred text. centering on the other hand will not add additional vertical space.
That means that your asdf environment gets the 'usual' vertical spacing of a display environment, while goodgood just gets the spacing one gets when moving on to the next paragraph (due to the par).
You don't need the ignorespaces at the beginning of goodgood: ignorespacespar is the same as par as David Carlisle pointed out in the comments. Since the environment ends with a par I also don't think the ignorespacesafterend is required.
To add some evenly divided space above and below, is it good practice to simply addvspace{2.0ex}at the beginning and end? Like this: ->newenvironment{specialnote}{vspace{2ex}parcenteringbegin{minipage}{0.8linewidth}smallsffamily}{end{minipage}parvspace{2ex}}(You switchedasdfandgoodgood, btw.)
– henry
Dec 31 '18 at 16:18
@henry Thanks for catching the name confusion (I hope the edit fixed it). I'm not sure about best practices withvspace. I'd have thought it would be more natural to usetrivlistor alist, but I'm not sure what one would have to do to get what you wanted then. Maybe you should ask a new question about that.
– moewe
Dec 31 '18 at 16:36
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%2f467029%2fenvironment-definition-adds-vertical-space-above%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
As explained in When should we use begin{center} instead of centering? begin{center}...end{center} is implemented via a list (trivlist) and causes vertical space before and after the centred text. centering on the other hand will not add additional vertical space.
That means that your asdf environment gets the 'usual' vertical spacing of a display environment, while goodgood just gets the spacing one gets when moving on to the next paragraph (due to the par).
You don't need the ignorespaces at the beginning of goodgood: ignorespacespar is the same as par as David Carlisle pointed out in the comments. Since the environment ends with a par I also don't think the ignorespacesafterend is required.
To add some evenly divided space above and below, is it good practice to simply addvspace{2.0ex}at the beginning and end? Like this: ->newenvironment{specialnote}{vspace{2ex}parcenteringbegin{minipage}{0.8linewidth}smallsffamily}{end{minipage}parvspace{2ex}}(You switchedasdfandgoodgood, btw.)
– henry
Dec 31 '18 at 16:18
@henry Thanks for catching the name confusion (I hope the edit fixed it). I'm not sure about best practices withvspace. I'd have thought it would be more natural to usetrivlistor alist, but I'm not sure what one would have to do to get what you wanted then. Maybe you should ask a new question about that.
– moewe
Dec 31 '18 at 16:36
add a comment |
As explained in When should we use begin{center} instead of centering? begin{center}...end{center} is implemented via a list (trivlist) and causes vertical space before and after the centred text. centering on the other hand will not add additional vertical space.
That means that your asdf environment gets the 'usual' vertical spacing of a display environment, while goodgood just gets the spacing one gets when moving on to the next paragraph (due to the par).
You don't need the ignorespaces at the beginning of goodgood: ignorespacespar is the same as par as David Carlisle pointed out in the comments. Since the environment ends with a par I also don't think the ignorespacesafterend is required.
To add some evenly divided space above and below, is it good practice to simply addvspace{2.0ex}at the beginning and end? Like this: ->newenvironment{specialnote}{vspace{2ex}parcenteringbegin{minipage}{0.8linewidth}smallsffamily}{end{minipage}parvspace{2ex}}(You switchedasdfandgoodgood, btw.)
– henry
Dec 31 '18 at 16:18
@henry Thanks for catching the name confusion (I hope the edit fixed it). I'm not sure about best practices withvspace. I'd have thought it would be more natural to usetrivlistor alist, but I'm not sure what one would have to do to get what you wanted then. Maybe you should ask a new question about that.
– moewe
Dec 31 '18 at 16:36
add a comment |
As explained in When should we use begin{center} instead of centering? begin{center}...end{center} is implemented via a list (trivlist) and causes vertical space before and after the centred text. centering on the other hand will not add additional vertical space.
That means that your asdf environment gets the 'usual' vertical spacing of a display environment, while goodgood just gets the spacing one gets when moving on to the next paragraph (due to the par).
You don't need the ignorespaces at the beginning of goodgood: ignorespacespar is the same as par as David Carlisle pointed out in the comments. Since the environment ends with a par I also don't think the ignorespacesafterend is required.
As explained in When should we use begin{center} instead of centering? begin{center}...end{center} is implemented via a list (trivlist) and causes vertical space before and after the centred text. centering on the other hand will not add additional vertical space.
That means that your asdf environment gets the 'usual' vertical spacing of a display environment, while goodgood just gets the spacing one gets when moving on to the next paragraph (due to the par).
You don't need the ignorespaces at the beginning of goodgood: ignorespacespar is the same as par as David Carlisle pointed out in the comments. Since the environment ends with a par I also don't think the ignorespacesafterend is required.
edited Dec 31 '18 at 16:35
answered Dec 23 '18 at 10:00
moewemoewe
87.3k9110335
87.3k9110335
To add some evenly divided space above and below, is it good practice to simply addvspace{2.0ex}at the beginning and end? Like this: ->newenvironment{specialnote}{vspace{2ex}parcenteringbegin{minipage}{0.8linewidth}smallsffamily}{end{minipage}parvspace{2ex}}(You switchedasdfandgoodgood, btw.)
– henry
Dec 31 '18 at 16:18
@henry Thanks for catching the name confusion (I hope the edit fixed it). I'm not sure about best practices withvspace. I'd have thought it would be more natural to usetrivlistor alist, but I'm not sure what one would have to do to get what you wanted then. Maybe you should ask a new question about that.
– moewe
Dec 31 '18 at 16:36
add a comment |
To add some evenly divided space above and below, is it good practice to simply addvspace{2.0ex}at the beginning and end? Like this: ->newenvironment{specialnote}{vspace{2ex}parcenteringbegin{minipage}{0.8linewidth}smallsffamily}{end{minipage}parvspace{2ex}}(You switchedasdfandgoodgood, btw.)
– henry
Dec 31 '18 at 16:18
@henry Thanks for catching the name confusion (I hope the edit fixed it). I'm not sure about best practices withvspace. I'd have thought it would be more natural to usetrivlistor alist, but I'm not sure what one would have to do to get what you wanted then. Maybe you should ask a new question about that.
– moewe
Dec 31 '18 at 16:36
To add some evenly divided space above and below, is it good practice to simply add
vspace{2.0ex} at the beginning and end? Like this: -> newenvironment{specialnote}{vspace{2ex}parcenteringbegin{minipage}{0.8linewidth}smallsffamily}{end{minipage}parvspace{2ex}} (You switched asdf and goodgood, btw.)– henry
Dec 31 '18 at 16:18
To add some evenly divided space above and below, is it good practice to simply add
vspace{2.0ex} at the beginning and end? Like this: -> newenvironment{specialnote}{vspace{2ex}parcenteringbegin{minipage}{0.8linewidth}smallsffamily}{end{minipage}parvspace{2ex}} (You switched asdf and goodgood, btw.)– henry
Dec 31 '18 at 16:18
@henry Thanks for catching the name confusion (I hope the edit fixed it). I'm not sure about best practices with
vspace. I'd have thought it would be more natural to use trivlist or a list, but I'm not sure what one would have to do to get what you wanted then. Maybe you should ask a new question about that.– moewe
Dec 31 '18 at 16:36
@henry Thanks for catching the name confusion (I hope the edit fixed it). I'm not sure about best practices with
vspace. I'd have thought it would be more natural to use trivlist or a list, but I'm not sure what one would have to do to get what you wanted then. Maybe you should ask a new question about that.– moewe
Dec 31 '18 at 16:36
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%2f467029%2fenvironment-definition-adds-vertical-space-above%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
3
AFAIK
begin{center}...end{center}adds space. See tex.stackexchange.com/q/23650/35864. So if you don't want additional space (which together with aminipagecould add up),begin{center}...end{center}is probably not your weapon of choice.– moewe
Dec 22 '18 at 20:21
2
As for the error: In the MWE
singlespacingis undefined. LaTeX throws an error (which should not be ignored!), but continues pretendingsinglespacingwasn't there.– moewe
Dec 22 '18 at 20:24
1
I'm not sure if you need the
ignorespacesat the beginning of the environment definition. It seems somewhat pointless to suppress spaces there, since they would have to come from the macro definition itself and there aren't any. I'm also not sure if theignorespacesafterendis needed here.– moewe
Dec 22 '18 at 20:36
3
It's a bit later for me now, but I will write up an answer tomorrow if no one complains about what I commented here.
– moewe
Dec 22 '18 at 20:56
2
also
ignorespacesparis the same asparas there are no spaces betweenignorespacesandpar.– David Carlisle
Dec 22 '18 at 21:02