How to get raggedright in tabular*?












7














I want to make a table with three columns of paragraphs, each in raggedright. I can only make it work for the first two columns. If I try to add >{raggedright}, as in the commented-out line below, I get the following error:



! Extra alignment tab has been changed to cr.


Here's my MWE:



documentclass{article}
usepackage{array}
newcommandfox{The quick brown fox jumps.}

begin{document}
begin{tabular}{%
>{raggedright}p{1.5in}%
>{raggedright}p{1.5in}%
p{1.5in}}
% >{raggedright}p{1.5in}} % doesn't work in 3rd column
fox & fox & fox \
fox & fox & fox
end{tabular}
end{document}









share|improve this question
























  • If you use tabular* with a fixed target width (here: 5in), you should add the directive @{extracolsep{fill}} at the start of the second argument of the tabular* environment.
    – Mico
    Dec 23 at 19:51










  • Thanks, Mico. I fixed the MWE to use tabular (the MWE was hacked down from an attempt to figure this out, which itself was hacked down from the original tabular* I was trying to include in a document).
    – dedded
    Dec 24 at 3:35
















7














I want to make a table with three columns of paragraphs, each in raggedright. I can only make it work for the first two columns. If I try to add >{raggedright}, as in the commented-out line below, I get the following error:



! Extra alignment tab has been changed to cr.


Here's my MWE:



documentclass{article}
usepackage{array}
newcommandfox{The quick brown fox jumps.}

begin{document}
begin{tabular}{%
>{raggedright}p{1.5in}%
>{raggedright}p{1.5in}%
p{1.5in}}
% >{raggedright}p{1.5in}} % doesn't work in 3rd column
fox & fox & fox \
fox & fox & fox
end{tabular}
end{document}









share|improve this question
























  • If you use tabular* with a fixed target width (here: 5in), you should add the directive @{extracolsep{fill}} at the start of the second argument of the tabular* environment.
    – Mico
    Dec 23 at 19:51










  • Thanks, Mico. I fixed the MWE to use tabular (the MWE was hacked down from an attempt to figure this out, which itself was hacked down from the original tabular* I was trying to include in a document).
    – dedded
    Dec 24 at 3:35














7












7








7







I want to make a table with three columns of paragraphs, each in raggedright. I can only make it work for the first two columns. If I try to add >{raggedright}, as in the commented-out line below, I get the following error:



! Extra alignment tab has been changed to cr.


Here's my MWE:



documentclass{article}
usepackage{array}
newcommandfox{The quick brown fox jumps.}

begin{document}
begin{tabular}{%
>{raggedright}p{1.5in}%
>{raggedright}p{1.5in}%
p{1.5in}}
% >{raggedright}p{1.5in}} % doesn't work in 3rd column
fox & fox & fox \
fox & fox & fox
end{tabular}
end{document}









share|improve this question















I want to make a table with three columns of paragraphs, each in raggedright. I can only make it work for the first two columns. If I try to add >{raggedright}, as in the commented-out line below, I get the following error:



! Extra alignment tab has been changed to cr.


Here's my MWE:



documentclass{article}
usepackage{array}
newcommandfox{The quick brown fox jumps.}

begin{document}
begin{tabular}{%
>{raggedright}p{1.5in}%
>{raggedright}p{1.5in}%
p{1.5in}}
% >{raggedright}p{1.5in}} % doesn't work in 3rd column
fox & fox & fox \
fox & fox & fox
end{tabular}
end{document}






tables horizontal-alignment






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 24 at 3:32

























asked Dec 23 at 19:03









dedded

624312




624312












  • If you use tabular* with a fixed target width (here: 5in), you should add the directive @{extracolsep{fill}} at the start of the second argument of the tabular* environment.
    – Mico
    Dec 23 at 19:51










  • Thanks, Mico. I fixed the MWE to use tabular (the MWE was hacked down from an attempt to figure this out, which itself was hacked down from the original tabular* I was trying to include in a document).
    – dedded
    Dec 24 at 3:35


















  • If you use tabular* with a fixed target width (here: 5in), you should add the directive @{extracolsep{fill}} at the start of the second argument of the tabular* environment.
    – Mico
    Dec 23 at 19:51










  • Thanks, Mico. I fixed the MWE to use tabular (the MWE was hacked down from an attempt to figure this out, which itself was hacked down from the original tabular* I was trying to include in a document).
    – dedded
    Dec 24 at 3:35
















If you use tabular* with a fixed target width (here: 5in), you should add the directive @{extracolsep{fill}} at the start of the second argument of the tabular* environment.
– Mico
Dec 23 at 19:51




If you use tabular* with a fixed target width (here: 5in), you should add the directive @{extracolsep{fill}} at the start of the second argument of the tabular* environment.
– Mico
Dec 23 at 19:51












Thanks, Mico. I fixed the MWE to use tabular (the MWE was hacked down from an attempt to figure this out, which itself was hacked down from the original tabular* I was trying to include in a document).
– dedded
Dec 24 at 3:35




Thanks, Mico. I fixed the MWE to use tabular (the MWE was hacked down from an attempt to figure this out, which itself was hacked down from the original tabular* I was trying to include in a document).
– dedded
Dec 24 at 3:35










3 Answers
3






active

oldest

votes


















6














if you use tabularnewline, than you not need arraybackslash for restoring meaning of \:



documentclass{article}
usepackage{array}
newcommandfox{The quick brown fox jumps.}

begin{document}
begin{tabular}{*{3}{>{raggedright}p{1.5in}}}%
fox & fox & fox tabularnewline
fox & fox & fox
end{tabular}
end{document}


enter image description here



off-topic: if you define width of all columns in table, than you not need to define table width with use tabular* environment, since it is determined by column widths. exception is, if you like to add @{extracolsep{fill}} by which you spread columns over prescribed table width.






share|improve this answer























  • Accepted this solution, since it explains my problem (\ getting redefined). Not sure I don't prefer arraybackslash though, since it allows the shorter \ in each row.
    – dedded
    Dec 24 at 3:27



















10














Add arraybackslash after raggedright:



documentclass{article}
usepackage{array}
newcommandfox{The quick brown fox jumps.}

begin{document}
begin{tabular*}{5in}{%
>{raggedrightarraybackslash}p{1.5in}%
>{raggedrightarraybackslash}p{1.5in}%
>{raggedrightarraybackslash}p{1.5in}}% does work in 3rd column :)
fox & fox & fox \
fox & fox & fox
end{tabular*}
end{document}


enter image description here



You can shorten the code a bit by repeating the same column 3 times:



documentclass{article}
usepackage{array}
newcommandfox{The quick brown fox jumps.}

begin{document}
begin{tabular*}{5in}{%
*{3}{>{raggedrightarraybackslash}p{1.5in}}}%
fox & fox & fox \
fox & fox & fox
end{tabular*}
end{document}





share|improve this answer





















  • with use only p column type in table i don't see why op use tabular* environment (which width is different than width of columns width). better is use ordinary tabular ...
    – Zarko
    Dec 23 at 19:20












  • @Zarko In general I agree, in this particular case the widths are surprisingly well choosen. Taking the intercolumn spaces into account, the sum is only off by 0.003 inch
    – samcarter
    Dec 23 at 19:24





















3














You can also put raggedright after p. I've just used it for the last column but it would be OK with the other columns. For more details see the descriptions mentioned by @DavidCarlisle in Auto Detect Last Paragraph and Pass to Macro.



documentclass{article}
usepackage{array}
usepackage{lipsum}
newcommandfox{The quick brown fox jumps.}

begin{document}
begin{tabular*}{5in}{%
>{raggedright}p{1.5in}%
>{raggedright}p{1.5in}%
p{1.5in}<{raggedright}}
% >{raggedright}p{1.5in}} % doesn't work in 3rd column
lipsum[1] & lipsum[1] & lipsum[1] \
fox & fox & fox
end{tabular*}
end{document}





share|improve this answer





















  • that does not work in general, it assumes there is only one paragraph in the cell and no blank line at the ned, and no display math
    – David Carlisle
    Dec 23 at 21:51










  • @DavidCarlisle thanks for the correction.
    – javadr
    Dec 24 at 19:20











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%2f467119%2fhow-to-get-raggedright-in-tabular%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























3 Answers
3






active

oldest

votes








3 Answers
3






active

oldest

votes









active

oldest

votes






active

oldest

votes









6














if you use tabularnewline, than you not need arraybackslash for restoring meaning of \:



documentclass{article}
usepackage{array}
newcommandfox{The quick brown fox jumps.}

begin{document}
begin{tabular}{*{3}{>{raggedright}p{1.5in}}}%
fox & fox & fox tabularnewline
fox & fox & fox
end{tabular}
end{document}


enter image description here



off-topic: if you define width of all columns in table, than you not need to define table width with use tabular* environment, since it is determined by column widths. exception is, if you like to add @{extracolsep{fill}} by which you spread columns over prescribed table width.






share|improve this answer























  • Accepted this solution, since it explains my problem (\ getting redefined). Not sure I don't prefer arraybackslash though, since it allows the shorter \ in each row.
    – dedded
    Dec 24 at 3:27
















6














if you use tabularnewline, than you not need arraybackslash for restoring meaning of \:



documentclass{article}
usepackage{array}
newcommandfox{The quick brown fox jumps.}

begin{document}
begin{tabular}{*{3}{>{raggedright}p{1.5in}}}%
fox & fox & fox tabularnewline
fox & fox & fox
end{tabular}
end{document}


enter image description here



off-topic: if you define width of all columns in table, than you not need to define table width with use tabular* environment, since it is determined by column widths. exception is, if you like to add @{extracolsep{fill}} by which you spread columns over prescribed table width.






share|improve this answer























  • Accepted this solution, since it explains my problem (\ getting redefined). Not sure I don't prefer arraybackslash though, since it allows the shorter \ in each row.
    – dedded
    Dec 24 at 3:27














6












6








6






if you use tabularnewline, than you not need arraybackslash for restoring meaning of \:



documentclass{article}
usepackage{array}
newcommandfox{The quick brown fox jumps.}

begin{document}
begin{tabular}{*{3}{>{raggedright}p{1.5in}}}%
fox & fox & fox tabularnewline
fox & fox & fox
end{tabular}
end{document}


enter image description here



off-topic: if you define width of all columns in table, than you not need to define table width with use tabular* environment, since it is determined by column widths. exception is, if you like to add @{extracolsep{fill}} by which you spread columns over prescribed table width.






share|improve this answer














if you use tabularnewline, than you not need arraybackslash for restoring meaning of \:



documentclass{article}
usepackage{array}
newcommandfox{The quick brown fox jumps.}

begin{document}
begin{tabular}{*{3}{>{raggedright}p{1.5in}}}%
fox & fox & fox tabularnewline
fox & fox & fox
end{tabular}
end{document}


enter image description here



off-topic: if you define width of all columns in table, than you not need to define table width with use tabular* environment, since it is determined by column widths. exception is, if you like to add @{extracolsep{fill}} by which you spread columns over prescribed table width.







share|improve this answer














share|improve this answer



share|improve this answer








edited Dec 23 at 23:01









samcarter

85.6k794275




85.6k794275










answered Dec 23 at 19:57









Zarko

120k865156




120k865156












  • Accepted this solution, since it explains my problem (\ getting redefined). Not sure I don't prefer arraybackslash though, since it allows the shorter \ in each row.
    – dedded
    Dec 24 at 3:27


















  • Accepted this solution, since it explains my problem (\ getting redefined). Not sure I don't prefer arraybackslash though, since it allows the shorter \ in each row.
    – dedded
    Dec 24 at 3:27
















Accepted this solution, since it explains my problem (\ getting redefined). Not sure I don't prefer arraybackslash though, since it allows the shorter \ in each row.
– dedded
Dec 24 at 3:27




Accepted this solution, since it explains my problem (\ getting redefined). Not sure I don't prefer arraybackslash though, since it allows the shorter \ in each row.
– dedded
Dec 24 at 3:27











10














Add arraybackslash after raggedright:



documentclass{article}
usepackage{array}
newcommandfox{The quick brown fox jumps.}

begin{document}
begin{tabular*}{5in}{%
>{raggedrightarraybackslash}p{1.5in}%
>{raggedrightarraybackslash}p{1.5in}%
>{raggedrightarraybackslash}p{1.5in}}% does work in 3rd column :)
fox & fox & fox \
fox & fox & fox
end{tabular*}
end{document}


enter image description here



You can shorten the code a bit by repeating the same column 3 times:



documentclass{article}
usepackage{array}
newcommandfox{The quick brown fox jumps.}

begin{document}
begin{tabular*}{5in}{%
*{3}{>{raggedrightarraybackslash}p{1.5in}}}%
fox & fox & fox \
fox & fox & fox
end{tabular*}
end{document}





share|improve this answer





















  • with use only p column type in table i don't see why op use tabular* environment (which width is different than width of columns width). better is use ordinary tabular ...
    – Zarko
    Dec 23 at 19:20












  • @Zarko In general I agree, in this particular case the widths are surprisingly well choosen. Taking the intercolumn spaces into account, the sum is only off by 0.003 inch
    – samcarter
    Dec 23 at 19:24


















10














Add arraybackslash after raggedright:



documentclass{article}
usepackage{array}
newcommandfox{The quick brown fox jumps.}

begin{document}
begin{tabular*}{5in}{%
>{raggedrightarraybackslash}p{1.5in}%
>{raggedrightarraybackslash}p{1.5in}%
>{raggedrightarraybackslash}p{1.5in}}% does work in 3rd column :)
fox & fox & fox \
fox & fox & fox
end{tabular*}
end{document}


enter image description here



You can shorten the code a bit by repeating the same column 3 times:



documentclass{article}
usepackage{array}
newcommandfox{The quick brown fox jumps.}

begin{document}
begin{tabular*}{5in}{%
*{3}{>{raggedrightarraybackslash}p{1.5in}}}%
fox & fox & fox \
fox & fox & fox
end{tabular*}
end{document}





share|improve this answer





















  • with use only p column type in table i don't see why op use tabular* environment (which width is different than width of columns width). better is use ordinary tabular ...
    – Zarko
    Dec 23 at 19:20












  • @Zarko In general I agree, in this particular case the widths are surprisingly well choosen. Taking the intercolumn spaces into account, the sum is only off by 0.003 inch
    – samcarter
    Dec 23 at 19:24
















10












10








10






Add arraybackslash after raggedright:



documentclass{article}
usepackage{array}
newcommandfox{The quick brown fox jumps.}

begin{document}
begin{tabular*}{5in}{%
>{raggedrightarraybackslash}p{1.5in}%
>{raggedrightarraybackslash}p{1.5in}%
>{raggedrightarraybackslash}p{1.5in}}% does work in 3rd column :)
fox & fox & fox \
fox & fox & fox
end{tabular*}
end{document}


enter image description here



You can shorten the code a bit by repeating the same column 3 times:



documentclass{article}
usepackage{array}
newcommandfox{The quick brown fox jumps.}

begin{document}
begin{tabular*}{5in}{%
*{3}{>{raggedrightarraybackslash}p{1.5in}}}%
fox & fox & fox \
fox & fox & fox
end{tabular*}
end{document}





share|improve this answer












Add arraybackslash after raggedright:



documentclass{article}
usepackage{array}
newcommandfox{The quick brown fox jumps.}

begin{document}
begin{tabular*}{5in}{%
>{raggedrightarraybackslash}p{1.5in}%
>{raggedrightarraybackslash}p{1.5in}%
>{raggedrightarraybackslash}p{1.5in}}% does work in 3rd column :)
fox & fox & fox \
fox & fox & fox
end{tabular*}
end{document}


enter image description here



You can shorten the code a bit by repeating the same column 3 times:



documentclass{article}
usepackage{array}
newcommandfox{The quick brown fox jumps.}

begin{document}
begin{tabular*}{5in}{%
*{3}{>{raggedrightarraybackslash}p{1.5in}}}%
fox & fox & fox \
fox & fox & fox
end{tabular*}
end{document}






share|improve this answer












share|improve this answer



share|improve this answer










answered Dec 23 at 19:12









samcarter

85.6k794275




85.6k794275












  • with use only p column type in table i don't see why op use tabular* environment (which width is different than width of columns width). better is use ordinary tabular ...
    – Zarko
    Dec 23 at 19:20












  • @Zarko In general I agree, in this particular case the widths are surprisingly well choosen. Taking the intercolumn spaces into account, the sum is only off by 0.003 inch
    – samcarter
    Dec 23 at 19:24




















  • with use only p column type in table i don't see why op use tabular* environment (which width is different than width of columns width). better is use ordinary tabular ...
    – Zarko
    Dec 23 at 19:20












  • @Zarko In general I agree, in this particular case the widths are surprisingly well choosen. Taking the intercolumn spaces into account, the sum is only off by 0.003 inch
    – samcarter
    Dec 23 at 19:24


















with use only p column type in table i don't see why op use tabular* environment (which width is different than width of columns width). better is use ordinary tabular ...
– Zarko
Dec 23 at 19:20






with use only p column type in table i don't see why op use tabular* environment (which width is different than width of columns width). better is use ordinary tabular ...
– Zarko
Dec 23 at 19:20














@Zarko In general I agree, in this particular case the widths are surprisingly well choosen. Taking the intercolumn spaces into account, the sum is only off by 0.003 inch
– samcarter
Dec 23 at 19:24






@Zarko In general I agree, in this particular case the widths are surprisingly well choosen. Taking the intercolumn spaces into account, the sum is only off by 0.003 inch
– samcarter
Dec 23 at 19:24













3














You can also put raggedright after p. I've just used it for the last column but it would be OK with the other columns. For more details see the descriptions mentioned by @DavidCarlisle in Auto Detect Last Paragraph and Pass to Macro.



documentclass{article}
usepackage{array}
usepackage{lipsum}
newcommandfox{The quick brown fox jumps.}

begin{document}
begin{tabular*}{5in}{%
>{raggedright}p{1.5in}%
>{raggedright}p{1.5in}%
p{1.5in}<{raggedright}}
% >{raggedright}p{1.5in}} % doesn't work in 3rd column
lipsum[1] & lipsum[1] & lipsum[1] \
fox & fox & fox
end{tabular*}
end{document}





share|improve this answer





















  • that does not work in general, it assumes there is only one paragraph in the cell and no blank line at the ned, and no display math
    – David Carlisle
    Dec 23 at 21:51










  • @DavidCarlisle thanks for the correction.
    – javadr
    Dec 24 at 19:20
















3














You can also put raggedright after p. I've just used it for the last column but it would be OK with the other columns. For more details see the descriptions mentioned by @DavidCarlisle in Auto Detect Last Paragraph and Pass to Macro.



documentclass{article}
usepackage{array}
usepackage{lipsum}
newcommandfox{The quick brown fox jumps.}

begin{document}
begin{tabular*}{5in}{%
>{raggedright}p{1.5in}%
>{raggedright}p{1.5in}%
p{1.5in}<{raggedright}}
% >{raggedright}p{1.5in}} % doesn't work in 3rd column
lipsum[1] & lipsum[1] & lipsum[1] \
fox & fox & fox
end{tabular*}
end{document}





share|improve this answer





















  • that does not work in general, it assumes there is only one paragraph in the cell and no blank line at the ned, and no display math
    – David Carlisle
    Dec 23 at 21:51










  • @DavidCarlisle thanks for the correction.
    – javadr
    Dec 24 at 19:20














3












3








3






You can also put raggedright after p. I've just used it for the last column but it would be OK with the other columns. For more details see the descriptions mentioned by @DavidCarlisle in Auto Detect Last Paragraph and Pass to Macro.



documentclass{article}
usepackage{array}
usepackage{lipsum}
newcommandfox{The quick brown fox jumps.}

begin{document}
begin{tabular*}{5in}{%
>{raggedright}p{1.5in}%
>{raggedright}p{1.5in}%
p{1.5in}<{raggedright}}
% >{raggedright}p{1.5in}} % doesn't work in 3rd column
lipsum[1] & lipsum[1] & lipsum[1] \
fox & fox & fox
end{tabular*}
end{document}





share|improve this answer












You can also put raggedright after p. I've just used it for the last column but it would be OK with the other columns. For more details see the descriptions mentioned by @DavidCarlisle in Auto Detect Last Paragraph and Pass to Macro.



documentclass{article}
usepackage{array}
usepackage{lipsum}
newcommandfox{The quick brown fox jumps.}

begin{document}
begin{tabular*}{5in}{%
>{raggedright}p{1.5in}%
>{raggedright}p{1.5in}%
p{1.5in}<{raggedright}}
% >{raggedright}p{1.5in}} % doesn't work in 3rd column
lipsum[1] & lipsum[1] & lipsum[1] \
fox & fox & fox
end{tabular*}
end{document}






share|improve this answer












share|improve this answer



share|improve this answer










answered Dec 23 at 19:27









javadr

1,633313




1,633313












  • that does not work in general, it assumes there is only one paragraph in the cell and no blank line at the ned, and no display math
    – David Carlisle
    Dec 23 at 21:51










  • @DavidCarlisle thanks for the correction.
    – javadr
    Dec 24 at 19:20


















  • that does not work in general, it assumes there is only one paragraph in the cell and no blank line at the ned, and no display math
    – David Carlisle
    Dec 23 at 21:51










  • @DavidCarlisle thanks for the correction.
    – javadr
    Dec 24 at 19:20
















that does not work in general, it assumes there is only one paragraph in the cell and no blank line at the ned, and no display math
– David Carlisle
Dec 23 at 21:51




that does not work in general, it assumes there is only one paragraph in the cell and no blank line at the ned, and no display math
– David Carlisle
Dec 23 at 21:51












@DavidCarlisle thanks for the correction.
– javadr
Dec 24 at 19:20




@DavidCarlisle thanks for the correction.
– javadr
Dec 24 at 19:20


















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%2f467119%2fhow-to-get-raggedright-in-tabular%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 did Captain America manage to do this?

迪纳利

南乌拉尔铁路局