Hangindent and justfied multiline text in single cell of table











up vote
5
down vote

favorite












I have quite a lot of text that I want to format in a readable manner in a single cell of a table, so I want to use hangindents. But in addition to that I want to make the text justified, but this is not working. If I use usepackage{ragged2e} and then change raggedright to justify, all hell breaks loose.



In order to have the hangindent, I needed to make a customnewline command, to repeat the hangindent (see difference between left and right column).



How can I combine this all, so make the text 'hang' and justified?



Note: It is quite a large table, which I am creating using Excel2LaTeX, so I would like to make the least amount of changes possible... That's why I changed the columntype.



documentclass[a4paper,10pt]{article}

usepackage{booktabs}
usepackage{multirow}
usepackage{tabularx}

begin{document}

% define new column type
newcolumntype{Y}[1]{>{small hangindent=1em raggedright letnewline\arraybackslash}p{#1}}

% define newline to use hangindent on new line
newcommand{customnewline}{newline hangindent=1em}

renewcommand{arraystretch}{1.3}


begin{table}[htbp]
centering
caption{Example}
begin{tabular}{Y{15em}Y{15em}}
toprule
multicolumn{1}{c}{textbf{customnewline}} & multicolumn{1}{c}{textbf{normal newline}} \
midrule
A lot of text that I want to justify and hangindent customnewline And there some more text in the same cell that I want to hangindent as well & A lot of text that I want to justify and hangindent newline And there some more text in the same cell that I want to hangindent as well \
A lot of text that I want to justify and hangindent customnewline And there some more text in the same cell that I want to hangindent as well & A lot of text that I want to justify and hangindent newline And there some more text in the same cell that I want to hangindent as well \
bottomrule
end{tabular}%
label{tab:addlabel}%
end{table}%

end{document}


table MVCE example










share|improve this question






















  • Welcome to TeX.SE. Your objectives aren't entirely clear. E.g., you write "A lot of text that I want to justify and hangindent", but the material isn't [fully] justified; instead, it is set ragged-right. Please clarify.
    – Mico
    Dec 2 at 10:52










  • Well, that is the problem, if I set it to justify in newcolumntype, only half the table shows. So how can I change the column definition in such a way that the text will be justified?
    – rinkert
    Dec 2 at 10:56















up vote
5
down vote

favorite












I have quite a lot of text that I want to format in a readable manner in a single cell of a table, so I want to use hangindents. But in addition to that I want to make the text justified, but this is not working. If I use usepackage{ragged2e} and then change raggedright to justify, all hell breaks loose.



In order to have the hangindent, I needed to make a customnewline command, to repeat the hangindent (see difference between left and right column).



How can I combine this all, so make the text 'hang' and justified?



Note: It is quite a large table, which I am creating using Excel2LaTeX, so I would like to make the least amount of changes possible... That's why I changed the columntype.



documentclass[a4paper,10pt]{article}

usepackage{booktabs}
usepackage{multirow}
usepackage{tabularx}

begin{document}

% define new column type
newcolumntype{Y}[1]{>{small hangindent=1em raggedright letnewline\arraybackslash}p{#1}}

% define newline to use hangindent on new line
newcommand{customnewline}{newline hangindent=1em}

renewcommand{arraystretch}{1.3}


begin{table}[htbp]
centering
caption{Example}
begin{tabular}{Y{15em}Y{15em}}
toprule
multicolumn{1}{c}{textbf{customnewline}} & multicolumn{1}{c}{textbf{normal newline}} \
midrule
A lot of text that I want to justify and hangindent customnewline And there some more text in the same cell that I want to hangindent as well & A lot of text that I want to justify and hangindent newline And there some more text in the same cell that I want to hangindent as well \
A lot of text that I want to justify and hangindent customnewline And there some more text in the same cell that I want to hangindent as well & A lot of text that I want to justify and hangindent newline And there some more text in the same cell that I want to hangindent as well \
bottomrule
end{tabular}%
label{tab:addlabel}%
end{table}%

end{document}


table MVCE example










share|improve this question






















  • Welcome to TeX.SE. Your objectives aren't entirely clear. E.g., you write "A lot of text that I want to justify and hangindent", but the material isn't [fully] justified; instead, it is set ragged-right. Please clarify.
    – Mico
    Dec 2 at 10:52










  • Well, that is the problem, if I set it to justify in newcolumntype, only half the table shows. So how can I change the column definition in such a way that the text will be justified?
    – rinkert
    Dec 2 at 10:56













up vote
5
down vote

favorite









up vote
5
down vote

favorite











I have quite a lot of text that I want to format in a readable manner in a single cell of a table, so I want to use hangindents. But in addition to that I want to make the text justified, but this is not working. If I use usepackage{ragged2e} and then change raggedright to justify, all hell breaks loose.



In order to have the hangindent, I needed to make a customnewline command, to repeat the hangindent (see difference between left and right column).



How can I combine this all, so make the text 'hang' and justified?



Note: It is quite a large table, which I am creating using Excel2LaTeX, so I would like to make the least amount of changes possible... That's why I changed the columntype.



documentclass[a4paper,10pt]{article}

usepackage{booktabs}
usepackage{multirow}
usepackage{tabularx}

begin{document}

% define new column type
newcolumntype{Y}[1]{>{small hangindent=1em raggedright letnewline\arraybackslash}p{#1}}

% define newline to use hangindent on new line
newcommand{customnewline}{newline hangindent=1em}

renewcommand{arraystretch}{1.3}


begin{table}[htbp]
centering
caption{Example}
begin{tabular}{Y{15em}Y{15em}}
toprule
multicolumn{1}{c}{textbf{customnewline}} & multicolumn{1}{c}{textbf{normal newline}} \
midrule
A lot of text that I want to justify and hangindent customnewline And there some more text in the same cell that I want to hangindent as well & A lot of text that I want to justify and hangindent newline And there some more text in the same cell that I want to hangindent as well \
A lot of text that I want to justify and hangindent customnewline And there some more text in the same cell that I want to hangindent as well & A lot of text that I want to justify and hangindent newline And there some more text in the same cell that I want to hangindent as well \
bottomrule
end{tabular}%
label{tab:addlabel}%
end{table}%

end{document}


table MVCE example










share|improve this question













I have quite a lot of text that I want to format in a readable manner in a single cell of a table, so I want to use hangindents. But in addition to that I want to make the text justified, but this is not working. If I use usepackage{ragged2e} and then change raggedright to justify, all hell breaks loose.



In order to have the hangindent, I needed to make a customnewline command, to repeat the hangindent (see difference between left and right column).



How can I combine this all, so make the text 'hang' and justified?



Note: It is quite a large table, which I am creating using Excel2LaTeX, so I would like to make the least amount of changes possible... That's why I changed the columntype.



documentclass[a4paper,10pt]{article}

usepackage{booktabs}
usepackage{multirow}
usepackage{tabularx}

begin{document}

% define new column type
newcolumntype{Y}[1]{>{small hangindent=1em raggedright letnewline\arraybackslash}p{#1}}

% define newline to use hangindent on new line
newcommand{customnewline}{newline hangindent=1em}

renewcommand{arraystretch}{1.3}


begin{table}[htbp]
centering
caption{Example}
begin{tabular}{Y{15em}Y{15em}}
toprule
multicolumn{1}{c}{textbf{customnewline}} & multicolumn{1}{c}{textbf{normal newline}} \
midrule
A lot of text that I want to justify and hangindent customnewline And there some more text in the same cell that I want to hangindent as well & A lot of text that I want to justify and hangindent newline And there some more text in the same cell that I want to hangindent as well \
A lot of text that I want to justify and hangindent customnewline And there some more text in the same cell that I want to hangindent as well & A lot of text that I want to justify and hangindent newline And there some more text in the same cell that I want to hangindent as well \
bottomrule
end{tabular}%
label{tab:addlabel}%
end{table}%

end{document}


table MVCE example







tables horizontal-alignment indentation columns booktabs






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 2 at 10:44









rinkert

1285




1285












  • Welcome to TeX.SE. Your objectives aren't entirely clear. E.g., you write "A lot of text that I want to justify and hangindent", but the material isn't [fully] justified; instead, it is set ragged-right. Please clarify.
    – Mico
    Dec 2 at 10:52










  • Well, that is the problem, if I set it to justify in newcolumntype, only half the table shows. So how can I change the column definition in such a way that the text will be justified?
    – rinkert
    Dec 2 at 10:56


















  • Welcome to TeX.SE. Your objectives aren't entirely clear. E.g., you write "A lot of text that I want to justify and hangindent", but the material isn't [fully] justified; instead, it is set ragged-right. Please clarify.
    – Mico
    Dec 2 at 10:52










  • Well, that is the problem, if I set it to justify in newcolumntype, only half the table shows. So how can I change the column definition in such a way that the text will be justified?
    – rinkert
    Dec 2 at 10:56
















Welcome to TeX.SE. Your objectives aren't entirely clear. E.g., you write "A lot of text that I want to justify and hangindent", but the material isn't [fully] justified; instead, it is set ragged-right. Please clarify.
– Mico
Dec 2 at 10:52




Welcome to TeX.SE. Your objectives aren't entirely clear. E.g., you write "A lot of text that I want to justify and hangindent", but the material isn't [fully] justified; instead, it is set ragged-right. Please clarify.
– Mico
Dec 2 at 10:52












Well, that is the problem, if I set it to justify in newcolumntype, only half the table shows. So how can I change the column definition in such a way that the text will be justified?
– rinkert
Dec 2 at 10:56




Well, that is the problem, if I set it to justify in newcolumntype, only half the table shows. So how can I change the column definition in such a way that the text will be justified?
– rinkert
Dec 2 at 10:56










1 Answer
1






active

oldest

votes

















up vote
6
down vote



accepted










You can use a blank line, instead, provided you set up hanging indentation for every paragraph:



documentclass[a4paper,10pt]{article}

usepackage{booktabs,array}

begin{document}

% define new column type
newcolumntype{Y}[1]{%
>{smallraggedrighteverypar{hangindent=1em}arraybackslash}p{#1}%
}

newcolumntype{Z}[1]{%
>{smalleverypar{hangindent=1em}arraybackslash}p{#1}%
}

% define newline to use hangindent on new line

renewcommand{arraystretch}{1.3}

noindent
begin{tabular}{Y{15em}Z{15em}}
toprule
multicolumn{1}{c}{Ragged right} &
multicolumn{1}{c}{Justified} \
midrule
A lot of text that I want to justify and hangindent

And there some more text in the same cell that I want to
hangindent as well
&
A lot of text that I want to justify and hangindent

And there some more text in the same cell that I want to
hangindent as well
\
midrule
A lot of text that I want to justify and hangindent

And there some more text in the same cell that I want to
hangindent as well
&
A lot of text that I want to justify and hangindent

And there some more text in the same cell that I want to
hangindent as well
\
bottomrule
end{tabular}

end{document}


enter image description here






share|improve this answer





















  • Awesome! Since I didn't want to add blank lines in all my table cells, I changed my customnewline to break the paragraph; newcommand{customnewline}{par}
    – rinkert
    Dec 2 at 12:44













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',
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%2f462800%2fhangindent-and-justfied-multiline-text-in-single-cell-of-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








up vote
6
down vote



accepted










You can use a blank line, instead, provided you set up hanging indentation for every paragraph:



documentclass[a4paper,10pt]{article}

usepackage{booktabs,array}

begin{document}

% define new column type
newcolumntype{Y}[1]{%
>{smallraggedrighteverypar{hangindent=1em}arraybackslash}p{#1}%
}

newcolumntype{Z}[1]{%
>{smalleverypar{hangindent=1em}arraybackslash}p{#1}%
}

% define newline to use hangindent on new line

renewcommand{arraystretch}{1.3}

noindent
begin{tabular}{Y{15em}Z{15em}}
toprule
multicolumn{1}{c}{Ragged right} &
multicolumn{1}{c}{Justified} \
midrule
A lot of text that I want to justify and hangindent

And there some more text in the same cell that I want to
hangindent as well
&
A lot of text that I want to justify and hangindent

And there some more text in the same cell that I want to
hangindent as well
\
midrule
A lot of text that I want to justify and hangindent

And there some more text in the same cell that I want to
hangindent as well
&
A lot of text that I want to justify and hangindent

And there some more text in the same cell that I want to
hangindent as well
\
bottomrule
end{tabular}

end{document}


enter image description here






share|improve this answer





















  • Awesome! Since I didn't want to add blank lines in all my table cells, I changed my customnewline to break the paragraph; newcommand{customnewline}{par}
    – rinkert
    Dec 2 at 12:44

















up vote
6
down vote



accepted










You can use a blank line, instead, provided you set up hanging indentation for every paragraph:



documentclass[a4paper,10pt]{article}

usepackage{booktabs,array}

begin{document}

% define new column type
newcolumntype{Y}[1]{%
>{smallraggedrighteverypar{hangindent=1em}arraybackslash}p{#1}%
}

newcolumntype{Z}[1]{%
>{smalleverypar{hangindent=1em}arraybackslash}p{#1}%
}

% define newline to use hangindent on new line

renewcommand{arraystretch}{1.3}

noindent
begin{tabular}{Y{15em}Z{15em}}
toprule
multicolumn{1}{c}{Ragged right} &
multicolumn{1}{c}{Justified} \
midrule
A lot of text that I want to justify and hangindent

And there some more text in the same cell that I want to
hangindent as well
&
A lot of text that I want to justify and hangindent

And there some more text in the same cell that I want to
hangindent as well
\
midrule
A lot of text that I want to justify and hangindent

And there some more text in the same cell that I want to
hangindent as well
&
A lot of text that I want to justify and hangindent

And there some more text in the same cell that I want to
hangindent as well
\
bottomrule
end{tabular}

end{document}


enter image description here






share|improve this answer





















  • Awesome! Since I didn't want to add blank lines in all my table cells, I changed my customnewline to break the paragraph; newcommand{customnewline}{par}
    – rinkert
    Dec 2 at 12:44















up vote
6
down vote



accepted







up vote
6
down vote



accepted






You can use a blank line, instead, provided you set up hanging indentation for every paragraph:



documentclass[a4paper,10pt]{article}

usepackage{booktabs,array}

begin{document}

% define new column type
newcolumntype{Y}[1]{%
>{smallraggedrighteverypar{hangindent=1em}arraybackslash}p{#1}%
}

newcolumntype{Z}[1]{%
>{smalleverypar{hangindent=1em}arraybackslash}p{#1}%
}

% define newline to use hangindent on new line

renewcommand{arraystretch}{1.3}

noindent
begin{tabular}{Y{15em}Z{15em}}
toprule
multicolumn{1}{c}{Ragged right} &
multicolumn{1}{c}{Justified} \
midrule
A lot of text that I want to justify and hangindent

And there some more text in the same cell that I want to
hangindent as well
&
A lot of text that I want to justify and hangindent

And there some more text in the same cell that I want to
hangindent as well
\
midrule
A lot of text that I want to justify and hangindent

And there some more text in the same cell that I want to
hangindent as well
&
A lot of text that I want to justify and hangindent

And there some more text in the same cell that I want to
hangindent as well
\
bottomrule
end{tabular}

end{document}


enter image description here






share|improve this answer












You can use a blank line, instead, provided you set up hanging indentation for every paragraph:



documentclass[a4paper,10pt]{article}

usepackage{booktabs,array}

begin{document}

% define new column type
newcolumntype{Y}[1]{%
>{smallraggedrighteverypar{hangindent=1em}arraybackslash}p{#1}%
}

newcolumntype{Z}[1]{%
>{smalleverypar{hangindent=1em}arraybackslash}p{#1}%
}

% define newline to use hangindent on new line

renewcommand{arraystretch}{1.3}

noindent
begin{tabular}{Y{15em}Z{15em}}
toprule
multicolumn{1}{c}{Ragged right} &
multicolumn{1}{c}{Justified} \
midrule
A lot of text that I want to justify and hangindent

And there some more text in the same cell that I want to
hangindent as well
&
A lot of text that I want to justify and hangindent

And there some more text in the same cell that I want to
hangindent as well
\
midrule
A lot of text that I want to justify and hangindent

And there some more text in the same cell that I want to
hangindent as well
&
A lot of text that I want to justify and hangindent

And there some more text in the same cell that I want to
hangindent as well
\
bottomrule
end{tabular}

end{document}


enter image description here







share|improve this answer












share|improve this answer



share|improve this answer










answered Dec 2 at 10:55









egreg

705k8618763155




705k8618763155












  • Awesome! Since I didn't want to add blank lines in all my table cells, I changed my customnewline to break the paragraph; newcommand{customnewline}{par}
    – rinkert
    Dec 2 at 12:44




















  • Awesome! Since I didn't want to add blank lines in all my table cells, I changed my customnewline to break the paragraph; newcommand{customnewline}{par}
    – rinkert
    Dec 2 at 12:44


















Awesome! Since I didn't want to add blank lines in all my table cells, I changed my customnewline to break the paragraph; newcommand{customnewline}{par}
– rinkert
Dec 2 at 12:44






Awesome! Since I didn't want to add blank lines in all my table cells, I changed my customnewline to break the paragraph; newcommand{customnewline}{par}
– rinkert
Dec 2 at 12:44




















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%2f462800%2fhangindent-and-justfied-multiline-text-in-single-cell-of-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

Quarter-circle Tiles

build a pushdown automaton that recognizes the reverse language of a given pushdown automaton?

Mont Emei