Function and usage of leavevmode
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
migrated from stackoverflow.com Jul 12 '11 at 10:42
This question came from our site for professional and enthusiast programmers.
add a comment |
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
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
add a comment |
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
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
boxes
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
add a comment |
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
add a comment |
1 Answer
1
active
oldest
votes
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.
Where can I read up aboutleavevmode
? Why don't I have to writeleavevmode
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 omitleavevmode
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 asunhboxvoidb@x
. This unboxes an empty horizontal box, which is similar tousebox
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 addleavevmode
manually onhbox
s 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
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%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
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.
Where can I read up aboutleavevmode
? Why don't I have to writeleavevmode
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 omitleavevmode
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 asunhboxvoidb@x
. This unboxes an empty horizontal box, which is similar tousebox
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 addleavevmode
manually onhbox
s 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
add a comment |
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.
Where can I read up aboutleavevmode
? Why don't I have to writeleavevmode
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 omitleavevmode
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 asunhboxvoidb@x
. This unboxes an empty horizontal box, which is similar tousebox
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 addleavevmode
manually onhbox
s 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
add a comment |
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.
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.
edited 15 mins ago
answered Jul 12 '11 at 10:50
Martin Scharrer♦
199k45632815
199k45632815
Where can I read up aboutleavevmode
? Why don't I have to writeleavevmode
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 omitleavevmode
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 asunhboxvoidb@x
. This unboxes an empty horizontal box, which is similar tousebox
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 addleavevmode
manually onhbox
s 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
add a comment |
Where can I read up aboutleavevmode
? Why don't I have to writeleavevmode
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 omitleavevmode
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 asunhboxvoidb@x
. This unboxes an empty horizontal box, which is similar tousebox
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 addleavevmode
manually onhbox
s 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 hbox
s 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 hbox
s 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
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%2f22852%2ffunction-and-usage-of-leavevmode%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
Related: Do I need leavevmode for centering figures? and Use case for pdfTeX's quitvmode.
– Martin Scharrer♦
Jul 12 '11 at 10:58