cannot align text in a simple table
I can not simply align the text by using p{xxlinewidth}
and color
in the same tabular.
The result is very awful... a conflicting package problem ?
anyone who has an idea is welcome ;)
sample:
source:
documentclass[a4paper,12pt]{book}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{color}
begin{document}
begin{table}
begin{tabular}{p{0.2linewidth}p{0.2linewidth}p{0.2linewidth}}
A & color{red}{B} & C \
end{tabular}
end{table}
end{document}
tables color
add a comment |
I can not simply align the text by using p{xxlinewidth}
and color
in the same tabular.
The result is very awful... a conflicting package problem ?
anyone who has an idea is welcome ;)
sample:
source:
documentclass[a4paper,12pt]{book}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{color}
begin{document}
begin{table}
begin{tabular}{p{0.2linewidth}p{0.2linewidth}p{0.2linewidth}}
A & color{red}{B} & C \
end{tabular}
end{table}
end{document}
tables color
4
Usetextcolor{red}{B}
orleavevmodecolor{red}{B}
. The problem is in invokingcolor
while in vertical mode.
– Steven B. Segletes
May 23 '17 at 14:34
@StevenB.Segletes Maybe you should post it as the answer :)
– Raaja
May 23 '17 at 14:34
add a comment |
I can not simply align the text by using p{xxlinewidth}
and color
in the same tabular.
The result is very awful... a conflicting package problem ?
anyone who has an idea is welcome ;)
sample:
source:
documentclass[a4paper,12pt]{book}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{color}
begin{document}
begin{table}
begin{tabular}{p{0.2linewidth}p{0.2linewidth}p{0.2linewidth}}
A & color{red}{B} & C \
end{tabular}
end{table}
end{document}
tables color
I can not simply align the text by using p{xxlinewidth}
and color
in the same tabular.
The result is very awful... a conflicting package problem ?
anyone who has an idea is welcome ;)
sample:
source:
documentclass[a4paper,12pt]{book}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{color}
begin{document}
begin{table}
begin{tabular}{p{0.2linewidth}p{0.2linewidth}p{0.2linewidth}}
A & color{red}{B} & C \
end{tabular}
end{table}
end{document}
tables color
tables color
asked May 23 '17 at 14:29
Jc CrivelloJc Crivello
112
112
4
Usetextcolor{red}{B}
orleavevmodecolor{red}{B}
. The problem is in invokingcolor
while in vertical mode.
– Steven B. Segletes
May 23 '17 at 14:34
@StevenB.Segletes Maybe you should post it as the answer :)
– Raaja
May 23 '17 at 14:34
add a comment |
4
Usetextcolor{red}{B}
orleavevmodecolor{red}{B}
. The problem is in invokingcolor
while in vertical mode.
– Steven B. Segletes
May 23 '17 at 14:34
@StevenB.Segletes Maybe you should post it as the answer :)
– Raaja
May 23 '17 at 14:34
4
4
Use
textcolor{red}{B}
or leavevmodecolor{red}{B}
. The problem is in invoking color
while in vertical mode.– Steven B. Segletes
May 23 '17 at 14:34
Use
textcolor{red}{B}
or leavevmodecolor{red}{B}
. The problem is in invoking color
while in vertical mode.– Steven B. Segletes
May 23 '17 at 14:34
@StevenB.Segletes Maybe you should post it as the answer :)
– Raaja
May 23 '17 at 14:34
@StevenB.Segletes Maybe you should post it as the answer :)
– Raaja
May 23 '17 at 14:34
add a comment |
1 Answer
1
active
oldest
votes
When you invoke a p
column, you are in a parbox
(or is it minipage
?) that enters that column in vertical mode. Some commands act differently in vertical (page) mode than in horizontal (paragraph) mode. color
is one of them. The way to remedy the issue is to either use textcolor
which will leave vertical mode itself, or to explicitly leave vertical mode with a leavevmode
. I show both methods below.
documentclass[a4paper,12pt]{book}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{color}
begin{document}
begin{table}
begin{tabular}{p{0.2linewidth}p{0.2linewidth}p{0.2linewidth}}
A & leavevmodecolor{red}B & C \
A & textcolor{red}{B} & C \
end{tabular}
end{table}
end{document}
Other macros that will suffer the same fate, and thus require a leavevmode
to behave in the "expected" way, include llap
, rlap
, and (outside of tabular
environments) marginpar
.
1
@Jc Crivello I had the same thought, and found this related question that may be helpful.
– sk8forether
May 23 '17 at 14:42
1
@sk8forether Vertical alignment of theparbox
is certainly an issue too, but it is unique from the vertical/horizontal mode issue in which you found yourself with this question.
– Steven B. Segletes
May 23 '17 at 14:43
@JcCrivello Note thatcolor{red}{B}
of your MWE, while not wrong, gives an improper impression.color{}
is a declaration, taking no additional arguments such as{B}
. All text that follows is affected by the color change until the end of the current group. Thus, the syntax should becolor{} B
. On the other handtextcolor{}{}
is the macro that not only defines the color, but also the text to which to apply it.
– Steven B. Segletes
May 23 '17 at 14:56
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%2f371250%2fcannot-align-text-in-a-simple-table%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
When you invoke a p
column, you are in a parbox
(or is it minipage
?) that enters that column in vertical mode. Some commands act differently in vertical (page) mode than in horizontal (paragraph) mode. color
is one of them. The way to remedy the issue is to either use textcolor
which will leave vertical mode itself, or to explicitly leave vertical mode with a leavevmode
. I show both methods below.
documentclass[a4paper,12pt]{book}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{color}
begin{document}
begin{table}
begin{tabular}{p{0.2linewidth}p{0.2linewidth}p{0.2linewidth}}
A & leavevmodecolor{red}B & C \
A & textcolor{red}{B} & C \
end{tabular}
end{table}
end{document}
Other macros that will suffer the same fate, and thus require a leavevmode
to behave in the "expected" way, include llap
, rlap
, and (outside of tabular
environments) marginpar
.
1
@Jc Crivello I had the same thought, and found this related question that may be helpful.
– sk8forether
May 23 '17 at 14:42
1
@sk8forether Vertical alignment of theparbox
is certainly an issue too, but it is unique from the vertical/horizontal mode issue in which you found yourself with this question.
– Steven B. Segletes
May 23 '17 at 14:43
@JcCrivello Note thatcolor{red}{B}
of your MWE, while not wrong, gives an improper impression.color{}
is a declaration, taking no additional arguments such as{B}
. All text that follows is affected by the color change until the end of the current group. Thus, the syntax should becolor{} B
. On the other handtextcolor{}{}
is the macro that not only defines the color, but also the text to which to apply it.
– Steven B. Segletes
May 23 '17 at 14:56
add a comment |
When you invoke a p
column, you are in a parbox
(or is it minipage
?) that enters that column in vertical mode. Some commands act differently in vertical (page) mode than in horizontal (paragraph) mode. color
is one of them. The way to remedy the issue is to either use textcolor
which will leave vertical mode itself, or to explicitly leave vertical mode with a leavevmode
. I show both methods below.
documentclass[a4paper,12pt]{book}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{color}
begin{document}
begin{table}
begin{tabular}{p{0.2linewidth}p{0.2linewidth}p{0.2linewidth}}
A & leavevmodecolor{red}B & C \
A & textcolor{red}{B} & C \
end{tabular}
end{table}
end{document}
Other macros that will suffer the same fate, and thus require a leavevmode
to behave in the "expected" way, include llap
, rlap
, and (outside of tabular
environments) marginpar
.
1
@Jc Crivello I had the same thought, and found this related question that may be helpful.
– sk8forether
May 23 '17 at 14:42
1
@sk8forether Vertical alignment of theparbox
is certainly an issue too, but it is unique from the vertical/horizontal mode issue in which you found yourself with this question.
– Steven B. Segletes
May 23 '17 at 14:43
@JcCrivello Note thatcolor{red}{B}
of your MWE, while not wrong, gives an improper impression.color{}
is a declaration, taking no additional arguments such as{B}
. All text that follows is affected by the color change until the end of the current group. Thus, the syntax should becolor{} B
. On the other handtextcolor{}{}
is the macro that not only defines the color, but also the text to which to apply it.
– Steven B. Segletes
May 23 '17 at 14:56
add a comment |
When you invoke a p
column, you are in a parbox
(or is it minipage
?) that enters that column in vertical mode. Some commands act differently in vertical (page) mode than in horizontal (paragraph) mode. color
is one of them. The way to remedy the issue is to either use textcolor
which will leave vertical mode itself, or to explicitly leave vertical mode with a leavevmode
. I show both methods below.
documentclass[a4paper,12pt]{book}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{color}
begin{document}
begin{table}
begin{tabular}{p{0.2linewidth}p{0.2linewidth}p{0.2linewidth}}
A & leavevmodecolor{red}B & C \
A & textcolor{red}{B} & C \
end{tabular}
end{table}
end{document}
Other macros that will suffer the same fate, and thus require a leavevmode
to behave in the "expected" way, include llap
, rlap
, and (outside of tabular
environments) marginpar
.
When you invoke a p
column, you are in a parbox
(or is it minipage
?) that enters that column in vertical mode. Some commands act differently in vertical (page) mode than in horizontal (paragraph) mode. color
is one of them. The way to remedy the issue is to either use textcolor
which will leave vertical mode itself, or to explicitly leave vertical mode with a leavevmode
. I show both methods below.
documentclass[a4paper,12pt]{book}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{color}
begin{document}
begin{table}
begin{tabular}{p{0.2linewidth}p{0.2linewidth}p{0.2linewidth}}
A & leavevmodecolor{red}B & C \
A & textcolor{red}{B} & C \
end{tabular}
end{table}
end{document}
Other macros that will suffer the same fate, and thus require a leavevmode
to behave in the "expected" way, include llap
, rlap
, and (outside of tabular
environments) marginpar
.
edited May 23 '17 at 14:52
answered May 23 '17 at 14:37
Steven B. SegletesSteven B. Segletes
153k9193401
153k9193401
1
@Jc Crivello I had the same thought, and found this related question that may be helpful.
– sk8forether
May 23 '17 at 14:42
1
@sk8forether Vertical alignment of theparbox
is certainly an issue too, but it is unique from the vertical/horizontal mode issue in which you found yourself with this question.
– Steven B. Segletes
May 23 '17 at 14:43
@JcCrivello Note thatcolor{red}{B}
of your MWE, while not wrong, gives an improper impression.color{}
is a declaration, taking no additional arguments such as{B}
. All text that follows is affected by the color change until the end of the current group. Thus, the syntax should becolor{} B
. On the other handtextcolor{}{}
is the macro that not only defines the color, but also the text to which to apply it.
– Steven B. Segletes
May 23 '17 at 14:56
add a comment |
1
@Jc Crivello I had the same thought, and found this related question that may be helpful.
– sk8forether
May 23 '17 at 14:42
1
@sk8forether Vertical alignment of theparbox
is certainly an issue too, but it is unique from the vertical/horizontal mode issue in which you found yourself with this question.
– Steven B. Segletes
May 23 '17 at 14:43
@JcCrivello Note thatcolor{red}{B}
of your MWE, while not wrong, gives an improper impression.color{}
is a declaration, taking no additional arguments such as{B}
. All text that follows is affected by the color change until the end of the current group. Thus, the syntax should becolor{} B
. On the other handtextcolor{}{}
is the macro that not only defines the color, but also the text to which to apply it.
– Steven B. Segletes
May 23 '17 at 14:56
1
1
@Jc Crivello I had the same thought, and found this related question that may be helpful.
– sk8forether
May 23 '17 at 14:42
@Jc Crivello I had the same thought, and found this related question that may be helpful.
– sk8forether
May 23 '17 at 14:42
1
1
@sk8forether Vertical alignment of the
parbox
is certainly an issue too, but it is unique from the vertical/horizontal mode issue in which you found yourself with this question.– Steven B. Segletes
May 23 '17 at 14:43
@sk8forether Vertical alignment of the
parbox
is certainly an issue too, but it is unique from the vertical/horizontal mode issue in which you found yourself with this question.– Steven B. Segletes
May 23 '17 at 14:43
@JcCrivello Note that
color{red}{B}
of your MWE, while not wrong, gives an improper impression. color{}
is a declaration, taking no additional arguments such as {B}
. All text that follows is affected by the color change until the end of the current group. Thus, the syntax should be color{} B
. On the other hand textcolor{}{}
is the macro that not only defines the color, but also the text to which to apply it.– Steven B. Segletes
May 23 '17 at 14:56
@JcCrivello Note that
color{red}{B}
of your MWE, while not wrong, gives an improper impression. color{}
is a declaration, taking no additional arguments such as {B}
. All text that follows is affected by the color change until the end of the current group. Thus, the syntax should be color{} B
. On the other hand textcolor{}{}
is the macro that not only defines the color, but also the text to which to apply it.– Steven B. Segletes
May 23 '17 at 14:56
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.
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%2f371250%2fcannot-align-text-in-a-simple-table%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
4
Use
textcolor{red}{B}
orleavevmodecolor{red}{B}
. The problem is in invokingcolor
while in vertical mode.– Steven B. Segletes
May 23 '17 at 14:34
@StevenB.Segletes Maybe you should post it as the answer :)
– Raaja
May 23 '17 at 14:34