Environment definition adds vertical space above












0














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



enter image description here



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}









share|improve this question




















  • 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








  • 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






  • 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








  • 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 ignorespacespar is the same as par as there are no spaces between ignorespaces and par.
    – David Carlisle
    Dec 22 '18 at 21:02
















0














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



enter image description here



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}









share|improve this question




















  • 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








  • 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






  • 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








  • 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 ignorespacespar is the same as par as there are no spaces between ignorespaces and par.
    – David Carlisle
    Dec 22 '18 at 21:02














0












0








0







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



enter image description here



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}









share|improve this question















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



enter image description here



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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 23 '18 at 10:14







henry

















asked Dec 22 '18 at 20:20









henryhenry

2,85132367




2,85132367








  • 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








  • 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






  • 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








  • 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 ignorespacespar is the same as par as there are no spaces between ignorespaces and par.
    – David Carlisle
    Dec 22 '18 at 21:02














  • 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








  • 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






  • 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








  • 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 ignorespacespar is the same as par as there are no spaces between ignorespaces and par.
    – 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










1 Answer
1






active

oldest

votes


















1














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.






share|improve this answer























  • 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













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
});


}
});














draft saved

draft discarded


















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









1














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.






share|improve this answer























  • 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


















1














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.






share|improve this answer























  • 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
















1












1








1






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.






share|improve this answer














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.







share|improve this answer














share|improve this answer



share|improve this answer








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 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




















  • 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


















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




















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

How to send String Array data to Server using php in android

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

Is anime1.com a legal site for watching anime?