Function and usage of leavevmode












70














I am beginner of LaTeX. From many examples I found, I notice that it's very common to use command leavevmode. I can't find any information about this command. Could anyone tell me what's the function of it and how to use it?










share|improve this question















migrated from stackoverflow.com Jul 12 '11 at 10:42


This question came from our site for professional and enthusiast programmers.















  • Related: Do I need leavevmode for centering figures? and Use case for pdfTeX's quitvmode.
    – Martin Scharrer
    Jul 12 '11 at 10:58
















70














I am beginner of LaTeX. From many examples I found, I notice that it's very common to use command leavevmode. I can't find any information about this command. Could anyone tell me what's the function of it and how to use it?










share|improve this question















migrated from stackoverflow.com Jul 12 '11 at 10:42


This question came from our site for professional and enthusiast programmers.















  • Related: Do I need leavevmode for centering figures? and Use case for pdfTeX's quitvmode.
    – Martin Scharrer
    Jul 12 '11 at 10:58














70












70








70


13





I am beginner of LaTeX. From many examples I found, I notice that it's very common to use command leavevmode. I can't find any information about this command. Could anyone tell me what's the function of it and how to use it?










share|improve this question















I am beginner of LaTeX. From many examples I found, I notice that it's very common to use command leavevmode. I can't find any information about this command. Could anyone tell me what's the function of it and how to use it?







boxes






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 12 '11 at 10:43









Martin Scharrer

199k45632815




199k45632815










asked Jul 11 '11 at 21:02









Jason Xu

7083914




7083914




migrated from stackoverflow.com Jul 12 '11 at 10:42


This question came from our site for professional and enthusiast programmers.






migrated from stackoverflow.com Jul 12 '11 at 10:42


This question came from our site for professional and enthusiast programmers.














  • Related: Do I need leavevmode for centering figures? and Use case for pdfTeX's quitvmode.
    – Martin Scharrer
    Jul 12 '11 at 10:58


















  • Related: Do I need leavevmode for centering figures? and Use case for pdfTeX's quitvmode.
    – Martin Scharrer
    Jul 12 '11 at 10:58
















Related: Do I need leavevmode for centering figures? and Use case for pdfTeX's quitvmode.
– Martin Scharrer
Jul 12 '11 at 10:58




Related: Do I need leavevmode for centering figures? and Use case for pdfTeX's quitvmode.
– Martin Scharrer
Jul 12 '11 at 10:58










1 Answer
1






active

oldest

votes


















84














The leavevmode is defined by LaTeX and plainTeX and ensures that the vertical mode is ended and horizontal mode is entered. In vertical mode, TeX stacks horizontal boxes vertically, whereas in horizontal mode, they are taken as part of the text line.



For example mbox{..} is defined as leavevmodehbox{..} to ensure that horizontal mode is entered if it is used at the beginning of a paragraph. If you only use hbox{ } it is stacked above the following paragraph instead.



Compare:



Textparhbox{Hello} World


Result:



  Text
Hello
World


with:



Textparmbox{Hello} World


Result:



  Text
Hello World


You see that in the first case the hbox is stacked with the two paragraphs vertically (but without paragraph indention) because it is processed in vertical mode. In the second case horizontal mode is entered first and so Hello is processed as part of the second paragraph.




Use leavevmode for all macros which could be used at the begin of the paragraph and add horizontal boxes by themselves (e.g. in form of text).






For further reading about leavevmode please see "The TeXBook" by Donald E. Knuth, Appendix A, section 13.1, page 313 as well Appendix B, page 356.






share|improve this answer























  • Where can I read up about leavevmode? Why don't I have to write leavevmode in the beginning of a paragraph, but do have to write it within a macro that is in the beginning of a paragraph? Also, I don't see the problems you describe when I omit leavevmode in tex.stackexchange.com/a/49913 - why not?
    – root
    11 hours ago










  • @root: leavevmode is described in "The TeXBook" by Donald E. Knuth. It is defined as unhboxvoidb@x. This unboxes an empty horizontal box, which is similar to usebox but removes the outer box and inserts its content directly. It works because the TeX engine needs to switch to horizontal mode to unbox an horizontal box. Normal text starts horizontal mode automatically, that is how the TeX engine got programmed. You need to add leavevmode manually on hboxs as TeX does not know if this box is just part of the paragraph or a whole paragraph (which is a hbox as well internally)
    – Martin Scharrer
    22 mins ago












  • @root: I added now a reference to The TeXBook to my answer.
    – Martin Scharrer
    15 mins ago











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%2f22852%2ffunction-and-usage-of-leavevmode%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









84














The leavevmode is defined by LaTeX and plainTeX and ensures that the vertical mode is ended and horizontal mode is entered. In vertical mode, TeX stacks horizontal boxes vertically, whereas in horizontal mode, they are taken as part of the text line.



For example mbox{..} is defined as leavevmodehbox{..} to ensure that horizontal mode is entered if it is used at the beginning of a paragraph. If you only use hbox{ } it is stacked above the following paragraph instead.



Compare:



Textparhbox{Hello} World


Result:



  Text
Hello
World


with:



Textparmbox{Hello} World


Result:



  Text
Hello World


You see that in the first case the hbox is stacked with the two paragraphs vertically (but without paragraph indention) because it is processed in vertical mode. In the second case horizontal mode is entered first and so Hello is processed as part of the second paragraph.




Use leavevmode for all macros which could be used at the begin of the paragraph and add horizontal boxes by themselves (e.g. in form of text).






For further reading about leavevmode please see "The TeXBook" by Donald E. Knuth, Appendix A, section 13.1, page 313 as well Appendix B, page 356.






share|improve this answer























  • Where can I read up about leavevmode? Why don't I have to write leavevmode in the beginning of a paragraph, but do have to write it within a macro that is in the beginning of a paragraph? Also, I don't see the problems you describe when I omit leavevmode in tex.stackexchange.com/a/49913 - why not?
    – root
    11 hours ago










  • @root: leavevmode is described in "The TeXBook" by Donald E. Knuth. It is defined as unhboxvoidb@x. This unboxes an empty horizontal box, which is similar to usebox but removes the outer box and inserts its content directly. It works because the TeX engine needs to switch to horizontal mode to unbox an horizontal box. Normal text starts horizontal mode automatically, that is how the TeX engine got programmed. You need to add leavevmode manually on hboxs as TeX does not know if this box is just part of the paragraph or a whole paragraph (which is a hbox as well internally)
    – Martin Scharrer
    22 mins ago












  • @root: I added now a reference to The TeXBook to my answer.
    – Martin Scharrer
    15 mins ago
















84














The leavevmode is defined by LaTeX and plainTeX and ensures that the vertical mode is ended and horizontal mode is entered. In vertical mode, TeX stacks horizontal boxes vertically, whereas in horizontal mode, they are taken as part of the text line.



For example mbox{..} is defined as leavevmodehbox{..} to ensure that horizontal mode is entered if it is used at the beginning of a paragraph. If you only use hbox{ } it is stacked above the following paragraph instead.



Compare:



Textparhbox{Hello} World


Result:



  Text
Hello
World


with:



Textparmbox{Hello} World


Result:



  Text
Hello World


You see that in the first case the hbox is stacked with the two paragraphs vertically (but without paragraph indention) because it is processed in vertical mode. In the second case horizontal mode is entered first and so Hello is processed as part of the second paragraph.




Use leavevmode for all macros which could be used at the begin of the paragraph and add horizontal boxes by themselves (e.g. in form of text).






For further reading about leavevmode please see "The TeXBook" by Donald E. Knuth, Appendix A, section 13.1, page 313 as well Appendix B, page 356.






share|improve this answer























  • Where can I read up about leavevmode? Why don't I have to write leavevmode in the beginning of a paragraph, but do have to write it within a macro that is in the beginning of a paragraph? Also, I don't see the problems you describe when I omit leavevmode in tex.stackexchange.com/a/49913 - why not?
    – root
    11 hours ago










  • @root: leavevmode is described in "The TeXBook" by Donald E. Knuth. It is defined as unhboxvoidb@x. This unboxes an empty horizontal box, which is similar to usebox but removes the outer box and inserts its content directly. It works because the TeX engine needs to switch to horizontal mode to unbox an horizontal box. Normal text starts horizontal mode automatically, that is how the TeX engine got programmed. You need to add leavevmode manually on hboxs as TeX does not know if this box is just part of the paragraph or a whole paragraph (which is a hbox as well internally)
    – Martin Scharrer
    22 mins ago












  • @root: I added now a reference to The TeXBook to my answer.
    – Martin Scharrer
    15 mins ago














84












84








84






The leavevmode is defined by LaTeX and plainTeX and ensures that the vertical mode is ended and horizontal mode is entered. In vertical mode, TeX stacks horizontal boxes vertically, whereas in horizontal mode, they are taken as part of the text line.



For example mbox{..} is defined as leavevmodehbox{..} to ensure that horizontal mode is entered if it is used at the beginning of a paragraph. If you only use hbox{ } it is stacked above the following paragraph instead.



Compare:



Textparhbox{Hello} World


Result:



  Text
Hello
World


with:



Textparmbox{Hello} World


Result:



  Text
Hello World


You see that in the first case the hbox is stacked with the two paragraphs vertically (but without paragraph indention) because it is processed in vertical mode. In the second case horizontal mode is entered first and so Hello is processed as part of the second paragraph.




Use leavevmode for all macros which could be used at the begin of the paragraph and add horizontal boxes by themselves (e.g. in form of text).






For further reading about leavevmode please see "The TeXBook" by Donald E. Knuth, Appendix A, section 13.1, page 313 as well Appendix B, page 356.






share|improve this answer














The leavevmode is defined by LaTeX and plainTeX and ensures that the vertical mode is ended and horizontal mode is entered. In vertical mode, TeX stacks horizontal boxes vertically, whereas in horizontal mode, they are taken as part of the text line.



For example mbox{..} is defined as leavevmodehbox{..} to ensure that horizontal mode is entered if it is used at the beginning of a paragraph. If you only use hbox{ } it is stacked above the following paragraph instead.



Compare:



Textparhbox{Hello} World


Result:



  Text
Hello
World


with:



Textparmbox{Hello} World


Result:



  Text
Hello World


You see that in the first case the hbox is stacked with the two paragraphs vertically (but without paragraph indention) because it is processed in vertical mode. In the second case horizontal mode is entered first and so Hello is processed as part of the second paragraph.




Use leavevmode for all macros which could be used at the begin of the paragraph and add horizontal boxes by themselves (e.g. in form of text).






For further reading about leavevmode please see "The TeXBook" by Donald E. Knuth, Appendix A, section 13.1, page 313 as well Appendix B, page 356.







share|improve this answer














share|improve this answer



share|improve this answer








edited 15 mins ago

























answered Jul 12 '11 at 10:50









Martin Scharrer

199k45632815




199k45632815












  • Where can I read up about leavevmode? Why don't I have to write leavevmode in the beginning of a paragraph, but do have to write it within a macro that is in the beginning of a paragraph? Also, I don't see the problems you describe when I omit leavevmode in tex.stackexchange.com/a/49913 - why not?
    – root
    11 hours ago










  • @root: leavevmode is described in "The TeXBook" by Donald E. Knuth. It is defined as unhboxvoidb@x. This unboxes an empty horizontal box, which is similar to usebox but removes the outer box and inserts its content directly. It works because the TeX engine needs to switch to horizontal mode to unbox an horizontal box. Normal text starts horizontal mode automatically, that is how the TeX engine got programmed. You need to add leavevmode manually on hboxs as TeX does not know if this box is just part of the paragraph or a whole paragraph (which is a hbox as well internally)
    – Martin Scharrer
    22 mins ago












  • @root: I added now a reference to The TeXBook to my answer.
    – Martin Scharrer
    15 mins ago


















  • Where can I read up about leavevmode? Why don't I have to write leavevmode in the beginning of a paragraph, but do have to write it within a macro that is in the beginning of a paragraph? Also, I don't see the problems you describe when I omit leavevmode in tex.stackexchange.com/a/49913 - why not?
    – root
    11 hours ago










  • @root: leavevmode is described in "The TeXBook" by Donald E. Knuth. It is defined as unhboxvoidb@x. This unboxes an empty horizontal box, which is similar to usebox but removes the outer box and inserts its content directly. It works because the TeX engine needs to switch to horizontal mode to unbox an horizontal box. Normal text starts horizontal mode automatically, that is how the TeX engine got programmed. You need to add leavevmode manually on hboxs as TeX does not know if this box is just part of the paragraph or a whole paragraph (which is a hbox as well internally)
    – Martin Scharrer
    22 mins ago












  • @root: I added now a reference to The TeXBook to my answer.
    – Martin Scharrer
    15 mins ago
















Where can I read up about leavevmode? Why don't I have to write leavevmode in the beginning of a paragraph, but do have to write it within a macro that is in the beginning of a paragraph? Also, I don't see the problems you describe when I omit leavevmode in tex.stackexchange.com/a/49913 - why not?
– root
11 hours ago




Where can I read up about leavevmode? Why don't I have to write leavevmode in the beginning of a paragraph, but do have to write it within a macro that is in the beginning of a paragraph? Also, I don't see the problems you describe when I omit leavevmode in tex.stackexchange.com/a/49913 - why not?
– root
11 hours ago












@root: leavevmode is described in "The TeXBook" by Donald E. Knuth. It is defined as unhboxvoidb@x. This unboxes an empty horizontal box, which is similar to usebox but removes the outer box and inserts its content directly. It works because the TeX engine needs to switch to horizontal mode to unbox an horizontal box. Normal text starts horizontal mode automatically, that is how the TeX engine got programmed. You need to add leavevmode manually on hboxs as TeX does not know if this box is just part of the paragraph or a whole paragraph (which is a hbox as well internally)
– Martin Scharrer
22 mins ago






@root: leavevmode is described in "The TeXBook" by Donald E. Knuth. It is defined as unhboxvoidb@x. This unboxes an empty horizontal box, which is similar to usebox but removes the outer box and inserts its content directly. It works because the TeX engine needs to switch to horizontal mode to unbox an horizontal box. Normal text starts horizontal mode automatically, that is how the TeX engine got programmed. You need to add leavevmode manually on hboxs as TeX does not know if this box is just part of the paragraph or a whole paragraph (which is a hbox as well internally)
– Martin Scharrer
22 mins ago














@root: I added now a reference to The TeXBook to my answer.
– Martin Scharrer
15 mins ago




@root: I added now a reference to The TeXBook to my answer.
– Martin Scharrer
15 mins ago


















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%2f22852%2ffunction-and-usage-of-leavevmode%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

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

Calculate evaluation metrics using cross_val_predict sklearn

Insert data from modal to MySQL (multiple modal on website)