cannot align text in a simple table












2















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:



why B below A and C ?



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}









share|improve this question


















  • 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













  • @StevenB.Segletes Maybe you should post it as the answer :)

    – Raaja
    May 23 '17 at 14:34
















2















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:



why B below A and C ?



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}









share|improve this question


















  • 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













  • @StevenB.Segletes Maybe you should post it as the answer :)

    – Raaja
    May 23 '17 at 14:34














2












2








2








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:



why B below A and C ?



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}









share|improve this question














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:



why B below A and C ?



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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked May 23 '17 at 14:29









Jc CrivelloJc Crivello

112




112








  • 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













  • @StevenB.Segletes Maybe you should post it as the answer :)

    – Raaja
    May 23 '17 at 14:34














  • 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













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










1 Answer
1






active

oldest

votes


















2














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}


enter image description here



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.






share|improve this answer





















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











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









2














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}


enter image description here



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.






share|improve this answer





















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
















2














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}


enter image description here



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.






share|improve this answer





















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














2












2








2







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}


enter image description here



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.






share|improve this answer















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}


enter image description here



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.







share|improve this answer














share|improve this answer



share|improve this answer








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














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








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


















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.




draft saved


draft discarded














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





















































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

サソリ

広島県道265号伴広島線

Setup Asymptote in Texstudio