Central alignment of text or numbers in `Table` Environment
up vote
3
down vote
favorite
I want to know how to centre-align a text or a number while using multicolumn
in Table
environment. I need to prepare a table as shown in the image below.
The MWE
for the above table is as follows:
documentclass{article}
%%%%%%%%%% PACKAGES %%%%%%%%%%%%%%%%%%%%%%
usepackage{multirow}
usepackage{calc}
usepackage{array}
newcolumntype{L}[1]{>
{raggedrightletnewline\arraybackslashhspace{0pt}}m{#1}}
newcolumntype{C}[1]{>
{centeringletnewline\arraybackslashhspace{0pt}}m{#1}}
newcolumntype{R}[1]{>
{raggedleftletnewline\arraybackslashhspace{0pt}}m{#1}}
newcommand{mc}[3]{multicolumn{#1}{#2}{#3}}
newcommand{mr}[3]{multirow{#1}{#2}{#3}}
usepackage{booktabs}
begin{document}
begin{table}[ht!]
begin{center}
begin{tabular}{cccccccccccccc}hline
mc{2}{|C{0.75cm}|}{} & mc{3}{C{2cm}|}{} & mc{3}{C{3cm}|}{1} & mc{3}{C{3cm}|}{2} & mc{3}{C{3cm}|}{3}\ hline
%-----------------------------------------------------------------------------------------------------------------------
mc{2}{|C{0.75cm}|}{} & mc{3}{C{2cm}|}{} & mc{3}{p{3cm}|}{centering $T_{alpha}^{-1}$ exists and \ is bounded } & mc{3}{p{3cm}|}{centering $T_{alpha}^{-1}$ exists and \ is unbounded } & mc{3}{C{3cm}|}{$T_{alpha}^{-1}$ does not exists}\ hline
%-----------------------------------------------------------------------------------------------------------------------
mc{2}{|L{0.75cm}|}{$I$} & mc{3}{C{2.5cm}|}{$R(T-alpha I)=X$} & mc{3}{p{3cm}|}{$alpha in rho (T,X)$} & mc{3}{C{3cm}|}{$-$} & mc{3}{p{3cm}|}{centering$alpha in sigma_{p} (T,X)$ \ $alpha in sigma_{ap} (T,X)$}\ hline
end{tabular}
end{center}
end{table}
%
end{document}
The output of the MWE
looks similar to the one in the image. The only issue is the alignment of the text or numbers.
Please help or provide suggestions?
tables multicolumn
add a comment |
up vote
3
down vote
favorite
I want to know how to centre-align a text or a number while using multicolumn
in Table
environment. I need to prepare a table as shown in the image below.
The MWE
for the above table is as follows:
documentclass{article}
%%%%%%%%%% PACKAGES %%%%%%%%%%%%%%%%%%%%%%
usepackage{multirow}
usepackage{calc}
usepackage{array}
newcolumntype{L}[1]{>
{raggedrightletnewline\arraybackslashhspace{0pt}}m{#1}}
newcolumntype{C}[1]{>
{centeringletnewline\arraybackslashhspace{0pt}}m{#1}}
newcolumntype{R}[1]{>
{raggedleftletnewline\arraybackslashhspace{0pt}}m{#1}}
newcommand{mc}[3]{multicolumn{#1}{#2}{#3}}
newcommand{mr}[3]{multirow{#1}{#2}{#3}}
usepackage{booktabs}
begin{document}
begin{table}[ht!]
begin{center}
begin{tabular}{cccccccccccccc}hline
mc{2}{|C{0.75cm}|}{} & mc{3}{C{2cm}|}{} & mc{3}{C{3cm}|}{1} & mc{3}{C{3cm}|}{2} & mc{3}{C{3cm}|}{3}\ hline
%-----------------------------------------------------------------------------------------------------------------------
mc{2}{|C{0.75cm}|}{} & mc{3}{C{2cm}|}{} & mc{3}{p{3cm}|}{centering $T_{alpha}^{-1}$ exists and \ is bounded } & mc{3}{p{3cm}|}{centering $T_{alpha}^{-1}$ exists and \ is unbounded } & mc{3}{C{3cm}|}{$T_{alpha}^{-1}$ does not exists}\ hline
%-----------------------------------------------------------------------------------------------------------------------
mc{2}{|L{0.75cm}|}{$I$} & mc{3}{C{2.5cm}|}{$R(T-alpha I)=X$} & mc{3}{p{3cm}|}{$alpha in rho (T,X)$} & mc{3}{C{3cm}|}{$-$} & mc{3}{p{3cm}|}{centering$alpha in sigma_{p} (T,X)$ \ $alpha in sigma_{ap} (T,X)$}\ hline
end{tabular}
end{center}
end{table}
%
end{document}
The output of the MWE
looks similar to the one in the image. The only issue is the alignment of the text or numbers.
Please help or provide suggestions?
tables multicolumn
What you want is not entirely clear. Must text or numbers be horizontally or vertically be centred (or both) in its cell?
– Bernard
yesterday
@Bernard The text or numbers should be centred vertically. I think they are horizontally centred in the cell.
– Tanvir
yesterday
The solutions provided below solved the problem I had with the alignment.
– Tanvir
yesterday
add a comment |
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I want to know how to centre-align a text or a number while using multicolumn
in Table
environment. I need to prepare a table as shown in the image below.
The MWE
for the above table is as follows:
documentclass{article}
%%%%%%%%%% PACKAGES %%%%%%%%%%%%%%%%%%%%%%
usepackage{multirow}
usepackage{calc}
usepackage{array}
newcolumntype{L}[1]{>
{raggedrightletnewline\arraybackslashhspace{0pt}}m{#1}}
newcolumntype{C}[1]{>
{centeringletnewline\arraybackslashhspace{0pt}}m{#1}}
newcolumntype{R}[1]{>
{raggedleftletnewline\arraybackslashhspace{0pt}}m{#1}}
newcommand{mc}[3]{multicolumn{#1}{#2}{#3}}
newcommand{mr}[3]{multirow{#1}{#2}{#3}}
usepackage{booktabs}
begin{document}
begin{table}[ht!]
begin{center}
begin{tabular}{cccccccccccccc}hline
mc{2}{|C{0.75cm}|}{} & mc{3}{C{2cm}|}{} & mc{3}{C{3cm}|}{1} & mc{3}{C{3cm}|}{2} & mc{3}{C{3cm}|}{3}\ hline
%-----------------------------------------------------------------------------------------------------------------------
mc{2}{|C{0.75cm}|}{} & mc{3}{C{2cm}|}{} & mc{3}{p{3cm}|}{centering $T_{alpha}^{-1}$ exists and \ is bounded } & mc{3}{p{3cm}|}{centering $T_{alpha}^{-1}$ exists and \ is unbounded } & mc{3}{C{3cm}|}{$T_{alpha}^{-1}$ does not exists}\ hline
%-----------------------------------------------------------------------------------------------------------------------
mc{2}{|L{0.75cm}|}{$I$} & mc{3}{C{2.5cm}|}{$R(T-alpha I)=X$} & mc{3}{p{3cm}|}{$alpha in rho (T,X)$} & mc{3}{C{3cm}|}{$-$} & mc{3}{p{3cm}|}{centering$alpha in sigma_{p} (T,X)$ \ $alpha in sigma_{ap} (T,X)$}\ hline
end{tabular}
end{center}
end{table}
%
end{document}
The output of the MWE
looks similar to the one in the image. The only issue is the alignment of the text or numbers.
Please help or provide suggestions?
tables multicolumn
I want to know how to centre-align a text or a number while using multicolumn
in Table
environment. I need to prepare a table as shown in the image below.
The MWE
for the above table is as follows:
documentclass{article}
%%%%%%%%%% PACKAGES %%%%%%%%%%%%%%%%%%%%%%
usepackage{multirow}
usepackage{calc}
usepackage{array}
newcolumntype{L}[1]{>
{raggedrightletnewline\arraybackslashhspace{0pt}}m{#1}}
newcolumntype{C}[1]{>
{centeringletnewline\arraybackslashhspace{0pt}}m{#1}}
newcolumntype{R}[1]{>
{raggedleftletnewline\arraybackslashhspace{0pt}}m{#1}}
newcommand{mc}[3]{multicolumn{#1}{#2}{#3}}
newcommand{mr}[3]{multirow{#1}{#2}{#3}}
usepackage{booktabs}
begin{document}
begin{table}[ht!]
begin{center}
begin{tabular}{cccccccccccccc}hline
mc{2}{|C{0.75cm}|}{} & mc{3}{C{2cm}|}{} & mc{3}{C{3cm}|}{1} & mc{3}{C{3cm}|}{2} & mc{3}{C{3cm}|}{3}\ hline
%-----------------------------------------------------------------------------------------------------------------------
mc{2}{|C{0.75cm}|}{} & mc{3}{C{2cm}|}{} & mc{3}{p{3cm}|}{centering $T_{alpha}^{-1}$ exists and \ is bounded } & mc{3}{p{3cm}|}{centering $T_{alpha}^{-1}$ exists and \ is unbounded } & mc{3}{C{3cm}|}{$T_{alpha}^{-1}$ does not exists}\ hline
%-----------------------------------------------------------------------------------------------------------------------
mc{2}{|L{0.75cm}|}{$I$} & mc{3}{C{2.5cm}|}{$R(T-alpha I)=X$} & mc{3}{p{3cm}|}{$alpha in rho (T,X)$} & mc{3}{C{3cm}|}{$-$} & mc{3}{p{3cm}|}{centering$alpha in sigma_{p} (T,X)$ \ $alpha in sigma_{ap} (T,X)$}\ hline
end{tabular}
end{center}
end{table}
%
end{document}
The output of the MWE
looks similar to the one in the image. The only issue is the alignment of the text or numbers.
Please help or provide suggestions?
tables multicolumn
tables multicolumn
asked yesterday
Tanvir
173214
173214
What you want is not entirely clear. Must text or numbers be horizontally or vertically be centred (or both) in its cell?
– Bernard
yesterday
@Bernard The text or numbers should be centred vertically. I think they are horizontally centred in the cell.
– Tanvir
yesterday
The solutions provided below solved the problem I had with the alignment.
– Tanvir
yesterday
add a comment |
What you want is not entirely clear. Must text or numbers be horizontally or vertically be centred (or both) in its cell?
– Bernard
yesterday
@Bernard The text or numbers should be centred vertically. I think they are horizontally centred in the cell.
– Tanvir
yesterday
The solutions provided below solved the problem I had with the alignment.
– Tanvir
yesterday
What you want is not entirely clear. Must text or numbers be horizontally or vertically be centred (or both) in its cell?
– Bernard
yesterday
What you want is not entirely clear. Must text or numbers be horizontally or vertically be centred (or both) in its cell?
– Bernard
yesterday
@Bernard The text or numbers should be centred vertically. I think they are horizontally centred in the cell.
– Tanvir
yesterday
@Bernard The text or numbers should be centred vertically. I think they are horizontally centred in the cell.
– Tanvir
yesterday
The solutions provided below solved the problem I had with the alignment.
– Tanvir
yesterday
The solutions provided below solved the problem I had with the alignment.
– Tanvir
yesterday
add a comment |
3 Answers
3
active
oldest
votes
up vote
3
down vote
accepted
I think you were almost there.
documentclass{article}
usepackage{array}
usepackage{amsmath}
usepackage{bbm}
begin{document}
newcolumntype{C}{>{centeringarraybackslash}p{3cm}}
begin{table}
renewcommand{arraystretch}{1.3}
begin{tabular}{|l|l|C|C|C|}
hline
& & 1 &2 & multicolumn{1}{c|}{3} \ hline
& & $T_alpha^{-1}$ exists and is bounded & $T_alpha^{-1}$ exists and is unbounded & $T_alpha^{-1}$ does not exist \ hline
$mathbbm{1}$ & $R(T-alpha mathbbm{1})=X$ & $alpha in rho (T,X)$ & - &
$begin{array}{r@{}l}
alpha& in sigma_{p} (T,X)\ alpha& in sigma_{ap} (T,X)
end{array}$ \ hline
end{tabular}
end{table}
end{document}
add a comment |
up vote
2
down vote
Using tabularx
gives you more flexibility for line wrapping and total page width table. To center a cell use multicolumn{1}{c|}{..}
and you can increase vertical space for rows by renewcommand{arraystretch}{1.3}
for more readability. Cells of the last row can be vertically centered by using multirow
but this will not make much difference.
documentclass{article}
usepackage{array,tabularx}
begin{document}
newcolumntype{L}{>{raggedrightarraybackslash}X}
begin{table}
renewcommand{arraystretch}{1.3}
begin{tabularx}{textwidth}{|l|l|L|L|L|}
hline
& & multicolumn{1}{c|}{1} & multicolumn{1}{c|}{2} & multicolumn{1}{c|}{3} \ hline
& & $T_alpha^{-1}$ exists and is bounded & $T_alpha^{-1}$ exists and is unbounded & $T_alpha^{-1}$ does not exists \ hline
$I$ & $R(T-alpha I)=X$ & $alpha in rho (T,X)$ & - & $alpha in sigma_{p} (T,X)$ newline $alpha in sigma_{ap} (T,X)$ \ hline
end{tabularx}
end{table}
end{document}
You may also want to improve the whole design using booktabs
as follows:
documentclass{article}
usepackage{array,tabularx,booktabs}
begin{document}
newcolumntype{L}{>{raggedrightarraybackslash}X}
begin{table}
%renewcommand{arraystretch}{1.3}
begin{tabularx}{textwidth}{@{}llLLL@{}}
toprule
& & multicolumn{1}{c}{1} & multicolumn{1}{c}{2} & multicolumn{1}{c}{3} \ midrule
& & $T_alpha^{-1}$ exists and is bounded & $T_alpha^{-1}$ exists and is unbounded & $T_alpha^{-1}$ does not exists \
textit{$I$} & $R(T-alpha I)=X$ & $alpha in rho (T,X)$ & - & $alpha in sigma_{p} (T,X)$ newline $alpha in sigma_{ap} (T,X)$ \ bottomrule
end{tabularx}
end{table}
end{document}
+1. Please replacetextit{$I$}
with$I$
, though.
– Mico
yesterday
The solution provided worked like charm. Also learnt a new thing -- usingbooktabs
. This made the final table looked nice.
– Tanvir
yesterday
add a comment |
up vote
1
down vote
Avoid jailed tables:
documentclass{article}
%%%%%%%%%% PACKAGES %%%%%%%%%%%%%%%%%%%%%%
usepackage{array}
usepackage{booktabs}
usepackage{tabularx}
newcolumntype{C}{>{centering}X}
begin{document}
begin{table}[ht!]
centering
renewcommand{tabularxcolumn}{m}
begin{tabularx}{textwidth}{@{}ccCCC@{}}
toprule
&& 1 & 2 & 3 tabularnewline
cmidrule(lr){3-3} cmidrule(lr){4-4} cmidrule(l){5-5}
&& $T_{alpha}^{-1}$ exists and \ is bounded &
$T_{alpha}^{-1}$ exists and \ is unbounded &
$T_{alpha}^{-1}$ does not exist tabularnewline
midrule
$I$ & $R(T-alpha I)=X$ & $alpha in rho (T,X)$ & --- &
$alpha in sigma_{p} (T,X)$ \ $alpha in sigma_{ap} (T,X)$ tabularnewline
bottomrule
end{tabularx}
end{table}
end{document}
Define only the columns you need. Here two centered columns at their natural width, then three equalized columns. For all columns, both vertical and horizontal centering.
Since you want to specify the line breaks, I don't state arraybackslash
and use tabularnewline
for ending rows.
It's easy to make it jailed, though.
begin{tabularx}{textwidth}{|c|c|C|C|C|}
hline
&& 1 & 2 & 3 tabularnewline
hline
&& $T_{alpha}^{-1}$ exists and \ is bounded &
$T_{alpha}^{-1}$ exists and \ is unbounded &
$T_{alpha}^{-1}$ does not exist tabularnewline
hline
$I$ & $R(T-alpha I)=X$ & $alpha in rho (T,X)$ & --- &
$alpha in sigma_{p} (T,X)$ \ $alpha in sigma_{ap} (T,X)$ tabularnewline
hline
end{tabularx}
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
I think you were almost there.
documentclass{article}
usepackage{array}
usepackage{amsmath}
usepackage{bbm}
begin{document}
newcolumntype{C}{>{centeringarraybackslash}p{3cm}}
begin{table}
renewcommand{arraystretch}{1.3}
begin{tabular}{|l|l|C|C|C|}
hline
& & 1 &2 & multicolumn{1}{c|}{3} \ hline
& & $T_alpha^{-1}$ exists and is bounded & $T_alpha^{-1}$ exists and is unbounded & $T_alpha^{-1}$ does not exist \ hline
$mathbbm{1}$ & $R(T-alpha mathbbm{1})=X$ & $alpha in rho (T,X)$ & - &
$begin{array}{r@{}l}
alpha& in sigma_{p} (T,X)\ alpha& in sigma_{ap} (T,X)
end{array}$ \ hline
end{tabular}
end{table}
end{document}
add a comment |
up vote
3
down vote
accepted
I think you were almost there.
documentclass{article}
usepackage{array}
usepackage{amsmath}
usepackage{bbm}
begin{document}
newcolumntype{C}{>{centeringarraybackslash}p{3cm}}
begin{table}
renewcommand{arraystretch}{1.3}
begin{tabular}{|l|l|C|C|C|}
hline
& & 1 &2 & multicolumn{1}{c|}{3} \ hline
& & $T_alpha^{-1}$ exists and is bounded & $T_alpha^{-1}$ exists and is unbounded & $T_alpha^{-1}$ does not exist \ hline
$mathbbm{1}$ & $R(T-alpha mathbbm{1})=X$ & $alpha in rho (T,X)$ & - &
$begin{array}{r@{}l}
alpha& in sigma_{p} (T,X)\ alpha& in sigma_{ap} (T,X)
end{array}$ \ hline
end{tabular}
end{table}
end{document}
add a comment |
up vote
3
down vote
accepted
up vote
3
down vote
accepted
I think you were almost there.
documentclass{article}
usepackage{array}
usepackage{amsmath}
usepackage{bbm}
begin{document}
newcolumntype{C}{>{centeringarraybackslash}p{3cm}}
begin{table}
renewcommand{arraystretch}{1.3}
begin{tabular}{|l|l|C|C|C|}
hline
& & 1 &2 & multicolumn{1}{c|}{3} \ hline
& & $T_alpha^{-1}$ exists and is bounded & $T_alpha^{-1}$ exists and is unbounded & $T_alpha^{-1}$ does not exist \ hline
$mathbbm{1}$ & $R(T-alpha mathbbm{1})=X$ & $alpha in rho (T,X)$ & - &
$begin{array}{r@{}l}
alpha& in sigma_{p} (T,X)\ alpha& in sigma_{ap} (T,X)
end{array}$ \ hline
end{tabular}
end{table}
end{document}
I think you were almost there.
documentclass{article}
usepackage{array}
usepackage{amsmath}
usepackage{bbm}
begin{document}
newcolumntype{C}{>{centeringarraybackslash}p{3cm}}
begin{table}
renewcommand{arraystretch}{1.3}
begin{tabular}{|l|l|C|C|C|}
hline
& & 1 &2 & multicolumn{1}{c|}{3} \ hline
& & $T_alpha^{-1}$ exists and is bounded & $T_alpha^{-1}$ exists and is unbounded & $T_alpha^{-1}$ does not exist \ hline
$mathbbm{1}$ & $R(T-alpha mathbbm{1})=X$ & $alpha in rho (T,X)$ & - &
$begin{array}{r@{}l}
alpha& in sigma_{p} (T,X)\ alpha& in sigma_{ap} (T,X)
end{array}$ \ hline
end{tabular}
end{table}
end{document}
answered yesterday
marmot
77.7k487166
77.7k487166
add a comment |
add a comment |
up vote
2
down vote
Using tabularx
gives you more flexibility for line wrapping and total page width table. To center a cell use multicolumn{1}{c|}{..}
and you can increase vertical space for rows by renewcommand{arraystretch}{1.3}
for more readability. Cells of the last row can be vertically centered by using multirow
but this will not make much difference.
documentclass{article}
usepackage{array,tabularx}
begin{document}
newcolumntype{L}{>{raggedrightarraybackslash}X}
begin{table}
renewcommand{arraystretch}{1.3}
begin{tabularx}{textwidth}{|l|l|L|L|L|}
hline
& & multicolumn{1}{c|}{1} & multicolumn{1}{c|}{2} & multicolumn{1}{c|}{3} \ hline
& & $T_alpha^{-1}$ exists and is bounded & $T_alpha^{-1}$ exists and is unbounded & $T_alpha^{-1}$ does not exists \ hline
$I$ & $R(T-alpha I)=X$ & $alpha in rho (T,X)$ & - & $alpha in sigma_{p} (T,X)$ newline $alpha in sigma_{ap} (T,X)$ \ hline
end{tabularx}
end{table}
end{document}
You may also want to improve the whole design using booktabs
as follows:
documentclass{article}
usepackage{array,tabularx,booktabs}
begin{document}
newcolumntype{L}{>{raggedrightarraybackslash}X}
begin{table}
%renewcommand{arraystretch}{1.3}
begin{tabularx}{textwidth}{@{}llLLL@{}}
toprule
& & multicolumn{1}{c}{1} & multicolumn{1}{c}{2} & multicolumn{1}{c}{3} \ midrule
& & $T_alpha^{-1}$ exists and is bounded & $T_alpha^{-1}$ exists and is unbounded & $T_alpha^{-1}$ does not exists \
textit{$I$} & $R(T-alpha I)=X$ & $alpha in rho (T,X)$ & - & $alpha in sigma_{p} (T,X)$ newline $alpha in sigma_{ap} (T,X)$ \ bottomrule
end{tabularx}
end{table}
end{document}
+1. Please replacetextit{$I$}
with$I$
, though.
– Mico
yesterday
The solution provided worked like charm. Also learnt a new thing -- usingbooktabs
. This made the final table looked nice.
– Tanvir
yesterday
add a comment |
up vote
2
down vote
Using tabularx
gives you more flexibility for line wrapping and total page width table. To center a cell use multicolumn{1}{c|}{..}
and you can increase vertical space for rows by renewcommand{arraystretch}{1.3}
for more readability. Cells of the last row can be vertically centered by using multirow
but this will not make much difference.
documentclass{article}
usepackage{array,tabularx}
begin{document}
newcolumntype{L}{>{raggedrightarraybackslash}X}
begin{table}
renewcommand{arraystretch}{1.3}
begin{tabularx}{textwidth}{|l|l|L|L|L|}
hline
& & multicolumn{1}{c|}{1} & multicolumn{1}{c|}{2} & multicolumn{1}{c|}{3} \ hline
& & $T_alpha^{-1}$ exists and is bounded & $T_alpha^{-1}$ exists and is unbounded & $T_alpha^{-1}$ does not exists \ hline
$I$ & $R(T-alpha I)=X$ & $alpha in rho (T,X)$ & - & $alpha in sigma_{p} (T,X)$ newline $alpha in sigma_{ap} (T,X)$ \ hline
end{tabularx}
end{table}
end{document}
You may also want to improve the whole design using booktabs
as follows:
documentclass{article}
usepackage{array,tabularx,booktabs}
begin{document}
newcolumntype{L}{>{raggedrightarraybackslash}X}
begin{table}
%renewcommand{arraystretch}{1.3}
begin{tabularx}{textwidth}{@{}llLLL@{}}
toprule
& & multicolumn{1}{c}{1} & multicolumn{1}{c}{2} & multicolumn{1}{c}{3} \ midrule
& & $T_alpha^{-1}$ exists and is bounded & $T_alpha^{-1}$ exists and is unbounded & $T_alpha^{-1}$ does not exists \
textit{$I$} & $R(T-alpha I)=X$ & $alpha in rho (T,X)$ & - & $alpha in sigma_{p} (T,X)$ newline $alpha in sigma_{ap} (T,X)$ \ bottomrule
end{tabularx}
end{table}
end{document}
+1. Please replacetextit{$I$}
with$I$
, though.
– Mico
yesterday
The solution provided worked like charm. Also learnt a new thing -- usingbooktabs
. This made the final table looked nice.
– Tanvir
yesterday
add a comment |
up vote
2
down vote
up vote
2
down vote
Using tabularx
gives you more flexibility for line wrapping and total page width table. To center a cell use multicolumn{1}{c|}{..}
and you can increase vertical space for rows by renewcommand{arraystretch}{1.3}
for more readability. Cells of the last row can be vertically centered by using multirow
but this will not make much difference.
documentclass{article}
usepackage{array,tabularx}
begin{document}
newcolumntype{L}{>{raggedrightarraybackslash}X}
begin{table}
renewcommand{arraystretch}{1.3}
begin{tabularx}{textwidth}{|l|l|L|L|L|}
hline
& & multicolumn{1}{c|}{1} & multicolumn{1}{c|}{2} & multicolumn{1}{c|}{3} \ hline
& & $T_alpha^{-1}$ exists and is bounded & $T_alpha^{-1}$ exists and is unbounded & $T_alpha^{-1}$ does not exists \ hline
$I$ & $R(T-alpha I)=X$ & $alpha in rho (T,X)$ & - & $alpha in sigma_{p} (T,X)$ newline $alpha in sigma_{ap} (T,X)$ \ hline
end{tabularx}
end{table}
end{document}
You may also want to improve the whole design using booktabs
as follows:
documentclass{article}
usepackage{array,tabularx,booktabs}
begin{document}
newcolumntype{L}{>{raggedrightarraybackslash}X}
begin{table}
%renewcommand{arraystretch}{1.3}
begin{tabularx}{textwidth}{@{}llLLL@{}}
toprule
& & multicolumn{1}{c}{1} & multicolumn{1}{c}{2} & multicolumn{1}{c}{3} \ midrule
& & $T_alpha^{-1}$ exists and is bounded & $T_alpha^{-1}$ exists and is unbounded & $T_alpha^{-1}$ does not exists \
textit{$I$} & $R(T-alpha I)=X$ & $alpha in rho (T,X)$ & - & $alpha in sigma_{p} (T,X)$ newline $alpha in sigma_{ap} (T,X)$ \ bottomrule
end{tabularx}
end{table}
end{document}
Using tabularx
gives you more flexibility for line wrapping and total page width table. To center a cell use multicolumn{1}{c|}{..}
and you can increase vertical space for rows by renewcommand{arraystretch}{1.3}
for more readability. Cells of the last row can be vertically centered by using multirow
but this will not make much difference.
documentclass{article}
usepackage{array,tabularx}
begin{document}
newcolumntype{L}{>{raggedrightarraybackslash}X}
begin{table}
renewcommand{arraystretch}{1.3}
begin{tabularx}{textwidth}{|l|l|L|L|L|}
hline
& & multicolumn{1}{c|}{1} & multicolumn{1}{c|}{2} & multicolumn{1}{c|}{3} \ hline
& & $T_alpha^{-1}$ exists and is bounded & $T_alpha^{-1}$ exists and is unbounded & $T_alpha^{-1}$ does not exists \ hline
$I$ & $R(T-alpha I)=X$ & $alpha in rho (T,X)$ & - & $alpha in sigma_{p} (T,X)$ newline $alpha in sigma_{ap} (T,X)$ \ hline
end{tabularx}
end{table}
end{document}
You may also want to improve the whole design using booktabs
as follows:
documentclass{article}
usepackage{array,tabularx,booktabs}
begin{document}
newcolumntype{L}{>{raggedrightarraybackslash}X}
begin{table}
%renewcommand{arraystretch}{1.3}
begin{tabularx}{textwidth}{@{}llLLL@{}}
toprule
& & multicolumn{1}{c}{1} & multicolumn{1}{c}{2} & multicolumn{1}{c}{3} \ midrule
& & $T_alpha^{-1}$ exists and is bounded & $T_alpha^{-1}$ exists and is unbounded & $T_alpha^{-1}$ does not exists \
textit{$I$} & $R(T-alpha I)=X$ & $alpha in rho (T,X)$ & - & $alpha in sigma_{p} (T,X)$ newline $alpha in sigma_{ap} (T,X)$ \ bottomrule
end{tabularx}
end{table}
end{document}
edited yesterday
answered yesterday
AboAmmar
31.1k22780
31.1k22780
+1. Please replacetextit{$I$}
with$I$
, though.
– Mico
yesterday
The solution provided worked like charm. Also learnt a new thing -- usingbooktabs
. This made the final table looked nice.
– Tanvir
yesterday
add a comment |
+1. Please replacetextit{$I$}
with$I$
, though.
– Mico
yesterday
The solution provided worked like charm. Also learnt a new thing -- usingbooktabs
. This made the final table looked nice.
– Tanvir
yesterday
+1. Please replace
textit{$I$}
with $I$
, though.– Mico
yesterday
+1. Please replace
textit{$I$}
with $I$
, though.– Mico
yesterday
The solution provided worked like charm. Also learnt a new thing -- using
booktabs
. This made the final table looked nice.– Tanvir
yesterday
The solution provided worked like charm. Also learnt a new thing -- using
booktabs
. This made the final table looked nice.– Tanvir
yesterday
add a comment |
up vote
1
down vote
Avoid jailed tables:
documentclass{article}
%%%%%%%%%% PACKAGES %%%%%%%%%%%%%%%%%%%%%%
usepackage{array}
usepackage{booktabs}
usepackage{tabularx}
newcolumntype{C}{>{centering}X}
begin{document}
begin{table}[ht!]
centering
renewcommand{tabularxcolumn}{m}
begin{tabularx}{textwidth}{@{}ccCCC@{}}
toprule
&& 1 & 2 & 3 tabularnewline
cmidrule(lr){3-3} cmidrule(lr){4-4} cmidrule(l){5-5}
&& $T_{alpha}^{-1}$ exists and \ is bounded &
$T_{alpha}^{-1}$ exists and \ is unbounded &
$T_{alpha}^{-1}$ does not exist tabularnewline
midrule
$I$ & $R(T-alpha I)=X$ & $alpha in rho (T,X)$ & --- &
$alpha in sigma_{p} (T,X)$ \ $alpha in sigma_{ap} (T,X)$ tabularnewline
bottomrule
end{tabularx}
end{table}
end{document}
Define only the columns you need. Here two centered columns at their natural width, then three equalized columns. For all columns, both vertical and horizontal centering.
Since you want to specify the line breaks, I don't state arraybackslash
and use tabularnewline
for ending rows.
It's easy to make it jailed, though.
begin{tabularx}{textwidth}{|c|c|C|C|C|}
hline
&& 1 & 2 & 3 tabularnewline
hline
&& $T_{alpha}^{-1}$ exists and \ is bounded &
$T_{alpha}^{-1}$ exists and \ is unbounded &
$T_{alpha}^{-1}$ does not exist tabularnewline
hline
$I$ & $R(T-alpha I)=X$ & $alpha in rho (T,X)$ & --- &
$alpha in sigma_{p} (T,X)$ \ $alpha in sigma_{ap} (T,X)$ tabularnewline
hline
end{tabularx}
add a comment |
up vote
1
down vote
Avoid jailed tables:
documentclass{article}
%%%%%%%%%% PACKAGES %%%%%%%%%%%%%%%%%%%%%%
usepackage{array}
usepackage{booktabs}
usepackage{tabularx}
newcolumntype{C}{>{centering}X}
begin{document}
begin{table}[ht!]
centering
renewcommand{tabularxcolumn}{m}
begin{tabularx}{textwidth}{@{}ccCCC@{}}
toprule
&& 1 & 2 & 3 tabularnewline
cmidrule(lr){3-3} cmidrule(lr){4-4} cmidrule(l){5-5}
&& $T_{alpha}^{-1}$ exists and \ is bounded &
$T_{alpha}^{-1}$ exists and \ is unbounded &
$T_{alpha}^{-1}$ does not exist tabularnewline
midrule
$I$ & $R(T-alpha I)=X$ & $alpha in rho (T,X)$ & --- &
$alpha in sigma_{p} (T,X)$ \ $alpha in sigma_{ap} (T,X)$ tabularnewline
bottomrule
end{tabularx}
end{table}
end{document}
Define only the columns you need. Here two centered columns at their natural width, then three equalized columns. For all columns, both vertical and horizontal centering.
Since you want to specify the line breaks, I don't state arraybackslash
and use tabularnewline
for ending rows.
It's easy to make it jailed, though.
begin{tabularx}{textwidth}{|c|c|C|C|C|}
hline
&& 1 & 2 & 3 tabularnewline
hline
&& $T_{alpha}^{-1}$ exists and \ is bounded &
$T_{alpha}^{-1}$ exists and \ is unbounded &
$T_{alpha}^{-1}$ does not exist tabularnewline
hline
$I$ & $R(T-alpha I)=X$ & $alpha in rho (T,X)$ & --- &
$alpha in sigma_{p} (T,X)$ \ $alpha in sigma_{ap} (T,X)$ tabularnewline
hline
end{tabularx}
add a comment |
up vote
1
down vote
up vote
1
down vote
Avoid jailed tables:
documentclass{article}
%%%%%%%%%% PACKAGES %%%%%%%%%%%%%%%%%%%%%%
usepackage{array}
usepackage{booktabs}
usepackage{tabularx}
newcolumntype{C}{>{centering}X}
begin{document}
begin{table}[ht!]
centering
renewcommand{tabularxcolumn}{m}
begin{tabularx}{textwidth}{@{}ccCCC@{}}
toprule
&& 1 & 2 & 3 tabularnewline
cmidrule(lr){3-3} cmidrule(lr){4-4} cmidrule(l){5-5}
&& $T_{alpha}^{-1}$ exists and \ is bounded &
$T_{alpha}^{-1}$ exists and \ is unbounded &
$T_{alpha}^{-1}$ does not exist tabularnewline
midrule
$I$ & $R(T-alpha I)=X$ & $alpha in rho (T,X)$ & --- &
$alpha in sigma_{p} (T,X)$ \ $alpha in sigma_{ap} (T,X)$ tabularnewline
bottomrule
end{tabularx}
end{table}
end{document}
Define only the columns you need. Here two centered columns at their natural width, then three equalized columns. For all columns, both vertical and horizontal centering.
Since you want to specify the line breaks, I don't state arraybackslash
and use tabularnewline
for ending rows.
It's easy to make it jailed, though.
begin{tabularx}{textwidth}{|c|c|C|C|C|}
hline
&& 1 & 2 & 3 tabularnewline
hline
&& $T_{alpha}^{-1}$ exists and \ is bounded &
$T_{alpha}^{-1}$ exists and \ is unbounded &
$T_{alpha}^{-1}$ does not exist tabularnewline
hline
$I$ & $R(T-alpha I)=X$ & $alpha in rho (T,X)$ & --- &
$alpha in sigma_{p} (T,X)$ \ $alpha in sigma_{ap} (T,X)$ tabularnewline
hline
end{tabularx}
Avoid jailed tables:
documentclass{article}
%%%%%%%%%% PACKAGES %%%%%%%%%%%%%%%%%%%%%%
usepackage{array}
usepackage{booktabs}
usepackage{tabularx}
newcolumntype{C}{>{centering}X}
begin{document}
begin{table}[ht!]
centering
renewcommand{tabularxcolumn}{m}
begin{tabularx}{textwidth}{@{}ccCCC@{}}
toprule
&& 1 & 2 & 3 tabularnewline
cmidrule(lr){3-3} cmidrule(lr){4-4} cmidrule(l){5-5}
&& $T_{alpha}^{-1}$ exists and \ is bounded &
$T_{alpha}^{-1}$ exists and \ is unbounded &
$T_{alpha}^{-1}$ does not exist tabularnewline
midrule
$I$ & $R(T-alpha I)=X$ & $alpha in rho (T,X)$ & --- &
$alpha in sigma_{p} (T,X)$ \ $alpha in sigma_{ap} (T,X)$ tabularnewline
bottomrule
end{tabularx}
end{table}
end{document}
Define only the columns you need. Here two centered columns at their natural width, then three equalized columns. For all columns, both vertical and horizontal centering.
Since you want to specify the line breaks, I don't state arraybackslash
and use tabularnewline
for ending rows.
It's easy to make it jailed, though.
begin{tabularx}{textwidth}{|c|c|C|C|C|}
hline
&& 1 & 2 & 3 tabularnewline
hline
&& $T_{alpha}^{-1}$ exists and \ is bounded &
$T_{alpha}^{-1}$ exists and \ is unbounded &
$T_{alpha}^{-1}$ does not exist tabularnewline
hline
$I$ & $R(T-alpha I)=X$ & $alpha in rho (T,X)$ & --- &
$alpha in sigma_{p} (T,X)$ \ $alpha in sigma_{ap} (T,X)$ tabularnewline
hline
end{tabularx}
answered yesterday
egreg
699k8518613132
699k8518613132
add a comment |
add a comment |
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%2f461478%2fcentral-alignment-of-text-or-numbers-in-table-environment%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
What you want is not entirely clear. Must text or numbers be horizontally or vertically be centred (or both) in its cell?
– Bernard
yesterday
@Bernard The text or numbers should be centred vertically. I think they are horizontally centred in the cell.
– Tanvir
yesterday
The solutions provided below solved the problem I had with the alignment.
– Tanvir
yesterday