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}
tables horizontal-alignment indentation columns booktabs
New contributor
add a comment |
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}
tables horizontal-alignment indentation columns booktabs
New contributor
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 tojustify
innewcolumntype
, 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
add a comment |
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}
tables horizontal-alignment indentation columns booktabs
New contributor
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}
tables horizontal-alignment indentation columns booktabs
tables horizontal-alignment indentation columns booktabs
New contributor
New contributor
New contributor
asked Dec 2 at 10:44
rinkert
1285
1285
New contributor
New contributor
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 tojustify
innewcolumntype
, 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
add a comment |
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 tojustify
innewcolumntype
, 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
add a comment |
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}
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
add a comment |
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}
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
add a comment |
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}
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
add a comment |
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}
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}
answered Dec 2 at 10:55
egreg
702k8618733147
702k8618733147
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
add a comment |
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
add a comment |
rinkert is a new contributor. Be nice, and check out our Code of Conduct.
rinkert is a new contributor. Be nice, and check out our Code of Conduct.
rinkert is a new contributor. Be nice, and check out our Code of Conduct.
rinkert is a new contributor. Be nice, and check out our Code of Conduct.
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%2f462800%2fhangindent-and-justfied-multiline-text-in-single-cell-of-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
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
innewcolumntype
, 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