multicolumn tabularx extending page width
I have used multicolumn and tabularx for the table I intend to write in LaTex. But the resultant table is going out of the page width. I also added the textwidth in tabularx but it is not working as desired. Surely, I have did some mistake but cant figure out. Would be glad to have the correction. Thank you
begin{table}
centering
caption{my table}
label{mytable}
begin{tabularx}{textwidth}{|c|c|c|c|X|c|X|}
hline
multicolumn{1}{|l|}{Type} & multicolumn{1}{l|}{Product name} & multicolumn{1}{l|}{begin{tabular}[c]{@{}l@{}}Diameter\(mm)end{tabular}} & multicolumn{1}{l|}{begin{tabular}[c]{@{}l@{}}Tensile strength\(MPa)end{tabular}} & multicolumn{1}{l|}{begin{tabular}[c]{@{}l@{}}Young's modulus\(GPa)end{tabular}} & multicolumn{1}{l|}{begin{tabular}[c]{@{}l@{}}Elongation\(%)end{tabular}} & Application \
hline
multirow{5}{*}{begin{tabular}[c]{@{}c@{}}class A\~\~\~\ end{tabular}} & abc123 & 0.014 & 1500 & 36 & 7 & four words text here \
cline{2-7} & abc123 & 0.040 & 1400 & 36 & 6.5 & four words text here\
cline{2-7} & abc123 & 0.20 & 975 & 27 & 9 & four words text here \
cline{2-7} & abc123 & 0.31 & 975 & 26 & 6 & four words text here \
cline{2-7} & abc123 & 0.67 & 900 & 23 & 9 & four words text here \ hline
multicolumn{1}{|l|}{multirow{3}{*}{class B}} & abc123 & 0.027 & 1560 & 39 & 6.5 & four words text here \
cline{2-7} multicolumn{1}{|l|}{} & abc123 & 0.040 & 1600 & 41 & 6.5 & four words text here \
cline{2-7} multicolumn{1}{|l|}{} & abc123 & 0.10 & 1200 & 28 & 12.5 & four words text here \
hline
end{tabularx}
end{table}
Also, the merged column text of the first column, I want it to set the vertical alignment to center instead of top.
tabularx
add a comment |
I have used multicolumn and tabularx for the table I intend to write in LaTex. But the resultant table is going out of the page width. I also added the textwidth in tabularx but it is not working as desired. Surely, I have did some mistake but cant figure out. Would be glad to have the correction. Thank you
begin{table}
centering
caption{my table}
label{mytable}
begin{tabularx}{textwidth}{|c|c|c|c|X|c|X|}
hline
multicolumn{1}{|l|}{Type} & multicolumn{1}{l|}{Product name} & multicolumn{1}{l|}{begin{tabular}[c]{@{}l@{}}Diameter\(mm)end{tabular}} & multicolumn{1}{l|}{begin{tabular}[c]{@{}l@{}}Tensile strength\(MPa)end{tabular}} & multicolumn{1}{l|}{begin{tabular}[c]{@{}l@{}}Young's modulus\(GPa)end{tabular}} & multicolumn{1}{l|}{begin{tabular}[c]{@{}l@{}}Elongation\(%)end{tabular}} & Application \
hline
multirow{5}{*}{begin{tabular}[c]{@{}c@{}}class A\~\~\~\ end{tabular}} & abc123 & 0.014 & 1500 & 36 & 7 & four words text here \
cline{2-7} & abc123 & 0.040 & 1400 & 36 & 6.5 & four words text here\
cline{2-7} & abc123 & 0.20 & 975 & 27 & 9 & four words text here \
cline{2-7} & abc123 & 0.31 & 975 & 26 & 6 & four words text here \
cline{2-7} & abc123 & 0.67 & 900 & 23 & 9 & four words text here \ hline
multicolumn{1}{|l|}{multirow{3}{*}{class B}} & abc123 & 0.027 & 1560 & 39 & 6.5 & four words text here \
cline{2-7} multicolumn{1}{|l|}{} & abc123 & 0.040 & 1600 & 41 & 6.5 & four words text here \
cline{2-7} multicolumn{1}{|l|}{} & abc123 & 0.10 & 1200 & 28 & 12.5 & four words text here \
hline
end{tabularx}
end{table}
Also, the merged column text of the first column, I want it to set the vertical alignment to center instead of top.
tabularx
add a comment |
I have used multicolumn and tabularx for the table I intend to write in LaTex. But the resultant table is going out of the page width. I also added the textwidth in tabularx but it is not working as desired. Surely, I have did some mistake but cant figure out. Would be glad to have the correction. Thank you
begin{table}
centering
caption{my table}
label{mytable}
begin{tabularx}{textwidth}{|c|c|c|c|X|c|X|}
hline
multicolumn{1}{|l|}{Type} & multicolumn{1}{l|}{Product name} & multicolumn{1}{l|}{begin{tabular}[c]{@{}l@{}}Diameter\(mm)end{tabular}} & multicolumn{1}{l|}{begin{tabular}[c]{@{}l@{}}Tensile strength\(MPa)end{tabular}} & multicolumn{1}{l|}{begin{tabular}[c]{@{}l@{}}Young's modulus\(GPa)end{tabular}} & multicolumn{1}{l|}{begin{tabular}[c]{@{}l@{}}Elongation\(%)end{tabular}} & Application \
hline
multirow{5}{*}{begin{tabular}[c]{@{}c@{}}class A\~\~\~\ end{tabular}} & abc123 & 0.014 & 1500 & 36 & 7 & four words text here \
cline{2-7} & abc123 & 0.040 & 1400 & 36 & 6.5 & four words text here\
cline{2-7} & abc123 & 0.20 & 975 & 27 & 9 & four words text here \
cline{2-7} & abc123 & 0.31 & 975 & 26 & 6 & four words text here \
cline{2-7} & abc123 & 0.67 & 900 & 23 & 9 & four words text here \ hline
multicolumn{1}{|l|}{multirow{3}{*}{class B}} & abc123 & 0.027 & 1560 & 39 & 6.5 & four words text here \
cline{2-7} multicolumn{1}{|l|}{} & abc123 & 0.040 & 1600 & 41 & 6.5 & four words text here \
cline{2-7} multicolumn{1}{|l|}{} & abc123 & 0.10 & 1200 & 28 & 12.5 & four words text here \
hline
end{tabularx}
end{table}
Also, the merged column text of the first column, I want it to set the vertical alignment to center instead of top.
tabularx
I have used multicolumn and tabularx for the table I intend to write in LaTex. But the resultant table is going out of the page width. I also added the textwidth in tabularx but it is not working as desired. Surely, I have did some mistake but cant figure out. Would be glad to have the correction. Thank you
begin{table}
centering
caption{my table}
label{mytable}
begin{tabularx}{textwidth}{|c|c|c|c|X|c|X|}
hline
multicolumn{1}{|l|}{Type} & multicolumn{1}{l|}{Product name} & multicolumn{1}{l|}{begin{tabular}[c]{@{}l@{}}Diameter\(mm)end{tabular}} & multicolumn{1}{l|}{begin{tabular}[c]{@{}l@{}}Tensile strength\(MPa)end{tabular}} & multicolumn{1}{l|}{begin{tabular}[c]{@{}l@{}}Young's modulus\(GPa)end{tabular}} & multicolumn{1}{l|}{begin{tabular}[c]{@{}l@{}}Elongation\(%)end{tabular}} & Application \
hline
multirow{5}{*}{begin{tabular}[c]{@{}c@{}}class A\~\~\~\ end{tabular}} & abc123 & 0.014 & 1500 & 36 & 7 & four words text here \
cline{2-7} & abc123 & 0.040 & 1400 & 36 & 6.5 & four words text here\
cline{2-7} & abc123 & 0.20 & 975 & 27 & 9 & four words text here \
cline{2-7} & abc123 & 0.31 & 975 & 26 & 6 & four words text here \
cline{2-7} & abc123 & 0.67 & 900 & 23 & 9 & four words text here \ hline
multicolumn{1}{|l|}{multirow{3}{*}{class B}} & abc123 & 0.027 & 1560 & 39 & 6.5 & four words text here \
cline{2-7} multicolumn{1}{|l|}{} & abc123 & 0.040 & 1600 & 41 & 6.5 & four words text here \
cline{2-7} multicolumn{1}{|l|}{} & abc123 & 0.10 & 1200 & 28 & 12.5 & four words text here \
hline
end{tabularx}
end{table}
Also, the merged column text of the first column, I want it to set the vertical alignment to center instead of top.
tabularx
tabularx
asked 1 hour ago
JackJack
4815
4815
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
The reason the tabularx
environment's width exceeds the width of the textblock is that you're not allowing line breaks in the header cells. I suggest that you (a) radically simplify the header material, mostly by getting rid of the multicolumn
"wrappers", and (b) use a centered version of the X
column type for all six data columns. Optionally, consider using a separate row in the header to place the information about the units of measurement.
documentclass{article}
usepackage{tabularx} % for "tabularx" environment and "X" column type
usepackage{ragged2e} % for "Centering" macro
newcolumntype{C}{>{Centeringarraybackslashhspace{0pt}}X}
%% "hspace{0pt}" allows for hyphenation of first word in header cells
begin{document}
begin{table}
%%centering % not needed
caption{My table}
label{tab:mytable}
setlengthextrarowheight{2pt} % for a slightly more open "look"
setlengthtabcolsep{3pt} % default: 6pt
begin{tabularx}{textwidth}{|l|*{6}{C|}}
hline
Type & Product name & Diameter & Tensile strength
& Young's modulus & Elongation & Application \
& & (mm) & (MPa) & (GPa) & (%) & \ % place units of measurement on a separate row
hline
Class A & abc123 & 0.014 & 1500 & 36 & 7 & four words text here \ cline{2-7}
& abc123 & 0.040 & 1400 & 36 & 6.5 & four words text here \ cline{2-7}
& abc123 & 0.20 & 975 & 27 & 9 & four words text here \ cline{2-7}
& abc123 & 0.31 & 975 & 26 & 6 & four words text here \ cline{2-7}
& abc123 & 0.67 & 900 & 23 & 9 & four words text here \
hline
Class B & abc123 & 0.027 & 1560 & 39 & 6.5 & four words text here \ cline{2-7}
& abc123 & 0.040 & 1600 & 41 & 6.5 & four words text here \ cline{2-7}
& abc123 & 0.10 & 1200 & 28 & 12.5& four words text here \
hline
end{tabularx}
end{table}
end{document}
Addendum: If this were my table, I'd strive to give it a far more open and "inviting" look. I'd do so mainly by (a) getting rid of all vertical rules and (b) using fewer, but well-spaced, horizontal rules. The booktabs
package, and its macros toprule
, midrule
, and bottomrule
, are made for just this use case.
documentclass{article}
usepackage{tabularx,ragged2e,siunitx,booktabs}
newcolumntype{C}{>{Centeringarraybackslashhspace{0pt}}X}
begin{document}
begin{table}
caption{Second try}
label{tab:secondtry}
setlengthtabcolsep{4pt} % default: 6pt
begin{tabularx}{textwidth}{@{} l *{6}{C} @{}}
toprule
Type & Product name & Diameter & Tensile strength
& Young's modulus & Elongation & Application \
& & (si{millimeter}) & (si{megapascal}) & (si{gigapascal}) & (%) & \
midrule
Class A & abc123 & 0.014 & 1500 & 36 & 7 & four words text here \ addlinespace
& abc123 & 0.040 & 1400 & 36 & 6.5 & four words text here \ addlinespace
& abc123 & 0.20 & 975 & 27 & 9 & four words text here \ addlinespace
& abc123 & 0.31 & 975 & 26 & 6 & four words text here \ addlinespace
& abc123 & 0.67 & 900 & 23 & 9 & four words text here \
midrule
Class B & abc123 & 0.027 & 1560 & 39 & 6.5 & four words text here \ addlinespace
& abc123 & 0.040 & 1600 & 41 & 6.5 & four words text here \ addlinespace
& abc123 & 0.10 & 1200 & 28 & 12.5& four words text here \
bottomrule
end{tabularx}
end{table}
end{document}
add a comment |
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
});
}
});
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%2f481836%2fmulticolumn-tabularx-extending-page-width%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
The reason the tabularx
environment's width exceeds the width of the textblock is that you're not allowing line breaks in the header cells. I suggest that you (a) radically simplify the header material, mostly by getting rid of the multicolumn
"wrappers", and (b) use a centered version of the X
column type for all six data columns. Optionally, consider using a separate row in the header to place the information about the units of measurement.
documentclass{article}
usepackage{tabularx} % for "tabularx" environment and "X" column type
usepackage{ragged2e} % for "Centering" macro
newcolumntype{C}{>{Centeringarraybackslashhspace{0pt}}X}
%% "hspace{0pt}" allows for hyphenation of first word in header cells
begin{document}
begin{table}
%%centering % not needed
caption{My table}
label{tab:mytable}
setlengthextrarowheight{2pt} % for a slightly more open "look"
setlengthtabcolsep{3pt} % default: 6pt
begin{tabularx}{textwidth}{|l|*{6}{C|}}
hline
Type & Product name & Diameter & Tensile strength
& Young's modulus & Elongation & Application \
& & (mm) & (MPa) & (GPa) & (%) & \ % place units of measurement on a separate row
hline
Class A & abc123 & 0.014 & 1500 & 36 & 7 & four words text here \ cline{2-7}
& abc123 & 0.040 & 1400 & 36 & 6.5 & four words text here \ cline{2-7}
& abc123 & 0.20 & 975 & 27 & 9 & four words text here \ cline{2-7}
& abc123 & 0.31 & 975 & 26 & 6 & four words text here \ cline{2-7}
& abc123 & 0.67 & 900 & 23 & 9 & four words text here \
hline
Class B & abc123 & 0.027 & 1560 & 39 & 6.5 & four words text here \ cline{2-7}
& abc123 & 0.040 & 1600 & 41 & 6.5 & four words text here \ cline{2-7}
& abc123 & 0.10 & 1200 & 28 & 12.5& four words text here \
hline
end{tabularx}
end{table}
end{document}
Addendum: If this were my table, I'd strive to give it a far more open and "inviting" look. I'd do so mainly by (a) getting rid of all vertical rules and (b) using fewer, but well-spaced, horizontal rules. The booktabs
package, and its macros toprule
, midrule
, and bottomrule
, are made for just this use case.
documentclass{article}
usepackage{tabularx,ragged2e,siunitx,booktabs}
newcolumntype{C}{>{Centeringarraybackslashhspace{0pt}}X}
begin{document}
begin{table}
caption{Second try}
label{tab:secondtry}
setlengthtabcolsep{4pt} % default: 6pt
begin{tabularx}{textwidth}{@{} l *{6}{C} @{}}
toprule
Type & Product name & Diameter & Tensile strength
& Young's modulus & Elongation & Application \
& & (si{millimeter}) & (si{megapascal}) & (si{gigapascal}) & (%) & \
midrule
Class A & abc123 & 0.014 & 1500 & 36 & 7 & four words text here \ addlinespace
& abc123 & 0.040 & 1400 & 36 & 6.5 & four words text here \ addlinespace
& abc123 & 0.20 & 975 & 27 & 9 & four words text here \ addlinespace
& abc123 & 0.31 & 975 & 26 & 6 & four words text here \ addlinespace
& abc123 & 0.67 & 900 & 23 & 9 & four words text here \
midrule
Class B & abc123 & 0.027 & 1560 & 39 & 6.5 & four words text here \ addlinespace
& abc123 & 0.040 & 1600 & 41 & 6.5 & four words text here \ addlinespace
& abc123 & 0.10 & 1200 & 28 & 12.5& four words text here \
bottomrule
end{tabularx}
end{table}
end{document}
add a comment |
The reason the tabularx
environment's width exceeds the width of the textblock is that you're not allowing line breaks in the header cells. I suggest that you (a) radically simplify the header material, mostly by getting rid of the multicolumn
"wrappers", and (b) use a centered version of the X
column type for all six data columns. Optionally, consider using a separate row in the header to place the information about the units of measurement.
documentclass{article}
usepackage{tabularx} % for "tabularx" environment and "X" column type
usepackage{ragged2e} % for "Centering" macro
newcolumntype{C}{>{Centeringarraybackslashhspace{0pt}}X}
%% "hspace{0pt}" allows for hyphenation of first word in header cells
begin{document}
begin{table}
%%centering % not needed
caption{My table}
label{tab:mytable}
setlengthextrarowheight{2pt} % for a slightly more open "look"
setlengthtabcolsep{3pt} % default: 6pt
begin{tabularx}{textwidth}{|l|*{6}{C|}}
hline
Type & Product name & Diameter & Tensile strength
& Young's modulus & Elongation & Application \
& & (mm) & (MPa) & (GPa) & (%) & \ % place units of measurement on a separate row
hline
Class A & abc123 & 0.014 & 1500 & 36 & 7 & four words text here \ cline{2-7}
& abc123 & 0.040 & 1400 & 36 & 6.5 & four words text here \ cline{2-7}
& abc123 & 0.20 & 975 & 27 & 9 & four words text here \ cline{2-7}
& abc123 & 0.31 & 975 & 26 & 6 & four words text here \ cline{2-7}
& abc123 & 0.67 & 900 & 23 & 9 & four words text here \
hline
Class B & abc123 & 0.027 & 1560 & 39 & 6.5 & four words text here \ cline{2-7}
& abc123 & 0.040 & 1600 & 41 & 6.5 & four words text here \ cline{2-7}
& abc123 & 0.10 & 1200 & 28 & 12.5& four words text here \
hline
end{tabularx}
end{table}
end{document}
Addendum: If this were my table, I'd strive to give it a far more open and "inviting" look. I'd do so mainly by (a) getting rid of all vertical rules and (b) using fewer, but well-spaced, horizontal rules. The booktabs
package, and its macros toprule
, midrule
, and bottomrule
, are made for just this use case.
documentclass{article}
usepackage{tabularx,ragged2e,siunitx,booktabs}
newcolumntype{C}{>{Centeringarraybackslashhspace{0pt}}X}
begin{document}
begin{table}
caption{Second try}
label{tab:secondtry}
setlengthtabcolsep{4pt} % default: 6pt
begin{tabularx}{textwidth}{@{} l *{6}{C} @{}}
toprule
Type & Product name & Diameter & Tensile strength
& Young's modulus & Elongation & Application \
& & (si{millimeter}) & (si{megapascal}) & (si{gigapascal}) & (%) & \
midrule
Class A & abc123 & 0.014 & 1500 & 36 & 7 & four words text here \ addlinespace
& abc123 & 0.040 & 1400 & 36 & 6.5 & four words text here \ addlinespace
& abc123 & 0.20 & 975 & 27 & 9 & four words text here \ addlinespace
& abc123 & 0.31 & 975 & 26 & 6 & four words text here \ addlinespace
& abc123 & 0.67 & 900 & 23 & 9 & four words text here \
midrule
Class B & abc123 & 0.027 & 1560 & 39 & 6.5 & four words text here \ addlinespace
& abc123 & 0.040 & 1600 & 41 & 6.5 & four words text here \ addlinespace
& abc123 & 0.10 & 1200 & 28 & 12.5& four words text here \
bottomrule
end{tabularx}
end{table}
end{document}
add a comment |
The reason the tabularx
environment's width exceeds the width of the textblock is that you're not allowing line breaks in the header cells. I suggest that you (a) radically simplify the header material, mostly by getting rid of the multicolumn
"wrappers", and (b) use a centered version of the X
column type for all six data columns. Optionally, consider using a separate row in the header to place the information about the units of measurement.
documentclass{article}
usepackage{tabularx} % for "tabularx" environment and "X" column type
usepackage{ragged2e} % for "Centering" macro
newcolumntype{C}{>{Centeringarraybackslashhspace{0pt}}X}
%% "hspace{0pt}" allows for hyphenation of first word in header cells
begin{document}
begin{table}
%%centering % not needed
caption{My table}
label{tab:mytable}
setlengthextrarowheight{2pt} % for a slightly more open "look"
setlengthtabcolsep{3pt} % default: 6pt
begin{tabularx}{textwidth}{|l|*{6}{C|}}
hline
Type & Product name & Diameter & Tensile strength
& Young's modulus & Elongation & Application \
& & (mm) & (MPa) & (GPa) & (%) & \ % place units of measurement on a separate row
hline
Class A & abc123 & 0.014 & 1500 & 36 & 7 & four words text here \ cline{2-7}
& abc123 & 0.040 & 1400 & 36 & 6.5 & four words text here \ cline{2-7}
& abc123 & 0.20 & 975 & 27 & 9 & four words text here \ cline{2-7}
& abc123 & 0.31 & 975 & 26 & 6 & four words text here \ cline{2-7}
& abc123 & 0.67 & 900 & 23 & 9 & four words text here \
hline
Class B & abc123 & 0.027 & 1560 & 39 & 6.5 & four words text here \ cline{2-7}
& abc123 & 0.040 & 1600 & 41 & 6.5 & four words text here \ cline{2-7}
& abc123 & 0.10 & 1200 & 28 & 12.5& four words text here \
hline
end{tabularx}
end{table}
end{document}
Addendum: If this were my table, I'd strive to give it a far more open and "inviting" look. I'd do so mainly by (a) getting rid of all vertical rules and (b) using fewer, but well-spaced, horizontal rules. The booktabs
package, and its macros toprule
, midrule
, and bottomrule
, are made for just this use case.
documentclass{article}
usepackage{tabularx,ragged2e,siunitx,booktabs}
newcolumntype{C}{>{Centeringarraybackslashhspace{0pt}}X}
begin{document}
begin{table}
caption{Second try}
label{tab:secondtry}
setlengthtabcolsep{4pt} % default: 6pt
begin{tabularx}{textwidth}{@{} l *{6}{C} @{}}
toprule
Type & Product name & Diameter & Tensile strength
& Young's modulus & Elongation & Application \
& & (si{millimeter}) & (si{megapascal}) & (si{gigapascal}) & (%) & \
midrule
Class A & abc123 & 0.014 & 1500 & 36 & 7 & four words text here \ addlinespace
& abc123 & 0.040 & 1400 & 36 & 6.5 & four words text here \ addlinespace
& abc123 & 0.20 & 975 & 27 & 9 & four words text here \ addlinespace
& abc123 & 0.31 & 975 & 26 & 6 & four words text here \ addlinespace
& abc123 & 0.67 & 900 & 23 & 9 & four words text here \
midrule
Class B & abc123 & 0.027 & 1560 & 39 & 6.5 & four words text here \ addlinespace
& abc123 & 0.040 & 1600 & 41 & 6.5 & four words text here \ addlinespace
& abc123 & 0.10 & 1200 & 28 & 12.5& four words text here \
bottomrule
end{tabularx}
end{table}
end{document}
The reason the tabularx
environment's width exceeds the width of the textblock is that you're not allowing line breaks in the header cells. I suggest that you (a) radically simplify the header material, mostly by getting rid of the multicolumn
"wrappers", and (b) use a centered version of the X
column type for all six data columns. Optionally, consider using a separate row in the header to place the information about the units of measurement.
documentclass{article}
usepackage{tabularx} % for "tabularx" environment and "X" column type
usepackage{ragged2e} % for "Centering" macro
newcolumntype{C}{>{Centeringarraybackslashhspace{0pt}}X}
%% "hspace{0pt}" allows for hyphenation of first word in header cells
begin{document}
begin{table}
%%centering % not needed
caption{My table}
label{tab:mytable}
setlengthextrarowheight{2pt} % for a slightly more open "look"
setlengthtabcolsep{3pt} % default: 6pt
begin{tabularx}{textwidth}{|l|*{6}{C|}}
hline
Type & Product name & Diameter & Tensile strength
& Young's modulus & Elongation & Application \
& & (mm) & (MPa) & (GPa) & (%) & \ % place units of measurement on a separate row
hline
Class A & abc123 & 0.014 & 1500 & 36 & 7 & four words text here \ cline{2-7}
& abc123 & 0.040 & 1400 & 36 & 6.5 & four words text here \ cline{2-7}
& abc123 & 0.20 & 975 & 27 & 9 & four words text here \ cline{2-7}
& abc123 & 0.31 & 975 & 26 & 6 & four words text here \ cline{2-7}
& abc123 & 0.67 & 900 & 23 & 9 & four words text here \
hline
Class B & abc123 & 0.027 & 1560 & 39 & 6.5 & four words text here \ cline{2-7}
& abc123 & 0.040 & 1600 & 41 & 6.5 & four words text here \ cline{2-7}
& abc123 & 0.10 & 1200 & 28 & 12.5& four words text here \
hline
end{tabularx}
end{table}
end{document}
Addendum: If this were my table, I'd strive to give it a far more open and "inviting" look. I'd do so mainly by (a) getting rid of all vertical rules and (b) using fewer, but well-spaced, horizontal rules. The booktabs
package, and its macros toprule
, midrule
, and bottomrule
, are made for just this use case.
documentclass{article}
usepackage{tabularx,ragged2e,siunitx,booktabs}
newcolumntype{C}{>{Centeringarraybackslashhspace{0pt}}X}
begin{document}
begin{table}
caption{Second try}
label{tab:secondtry}
setlengthtabcolsep{4pt} % default: 6pt
begin{tabularx}{textwidth}{@{} l *{6}{C} @{}}
toprule
Type & Product name & Diameter & Tensile strength
& Young's modulus & Elongation & Application \
& & (si{millimeter}) & (si{megapascal}) & (si{gigapascal}) & (%) & \
midrule
Class A & abc123 & 0.014 & 1500 & 36 & 7 & four words text here \ addlinespace
& abc123 & 0.040 & 1400 & 36 & 6.5 & four words text here \ addlinespace
& abc123 & 0.20 & 975 & 27 & 9 & four words text here \ addlinespace
& abc123 & 0.31 & 975 & 26 & 6 & four words text here \ addlinespace
& abc123 & 0.67 & 900 & 23 & 9 & four words text here \
midrule
Class B & abc123 & 0.027 & 1560 & 39 & 6.5 & four words text here \ addlinespace
& abc123 & 0.040 & 1600 & 41 & 6.5 & four words text here \ addlinespace
& abc123 & 0.10 & 1200 & 28 & 12.5& four words text here \
bottomrule
end{tabularx}
end{table}
end{document}
edited 35 mins ago
answered 50 mins ago
MicoMico
284k31388778
284k31388778
add a comment |
add a comment |
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.
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%2f481836%2fmulticolumn-tabularx-extending-page-width%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