Centering table data under right-aligned tabularx header
I'm trying to align the following table so that the "21" is centered under its header.
begin{table}[h]
centering
begin{tabularx}{1.09textwidth}{|cll>{raggedleftarraybackslash}X|}
hline
textbf{ID} & textbf{Severity} & textbf{Vulnerability} &
textbf{Occurrences} \
hline
111111 & Lorem & Lorem ipsum dolor sit amet & 21 \
hline
end{tabularx}
caption{example}
label{table:example}
end{table}
I can use centering
instead of raggedleft
for the last column to center the numbers under the header but then the header ends up too much to the left, I want the header to be like in the above picture.
Is there anyway I can get the combination of these two? The header aligned to the right like in the first picture but the number centered under the header like in the second picture.
tables tabularx alignment
add a comment |
I'm trying to align the following table so that the "21" is centered under its header.
begin{table}[h]
centering
begin{tabularx}{1.09textwidth}{|cll>{raggedleftarraybackslash}X|}
hline
textbf{ID} & textbf{Severity} & textbf{Vulnerability} &
textbf{Occurrences} \
hline
111111 & Lorem & Lorem ipsum dolor sit amet & 21 \
hline
end{tabularx}
caption{example}
label{table:example}
end{table}
I can use centering
instead of raggedleft
for the last column to center the numbers under the header but then the header ends up too much to the left, I want the header to be like in the above picture.
Is there anyway I can get the combination of these two? The header aligned to the right like in the first picture but the number centered under the header like in the second picture.
tables tabularx alignment
Welcome to TeX SX! Have you any reason for a tabularx which flows into the margins?
– Bernard
Mar 18 at 10:21
@Bernard The reason i'm using tabularx is to get the same width as my widest table
– antmo
Mar 18 at 10:27
add a comment |
I'm trying to align the following table so that the "21" is centered under its header.
begin{table}[h]
centering
begin{tabularx}{1.09textwidth}{|cll>{raggedleftarraybackslash}X|}
hline
textbf{ID} & textbf{Severity} & textbf{Vulnerability} &
textbf{Occurrences} \
hline
111111 & Lorem & Lorem ipsum dolor sit amet & 21 \
hline
end{tabularx}
caption{example}
label{table:example}
end{table}
I can use centering
instead of raggedleft
for the last column to center the numbers under the header but then the header ends up too much to the left, I want the header to be like in the above picture.
Is there anyway I can get the combination of these two? The header aligned to the right like in the first picture but the number centered under the header like in the second picture.
tables tabularx alignment
I'm trying to align the following table so that the "21" is centered under its header.
begin{table}[h]
centering
begin{tabularx}{1.09textwidth}{|cll>{raggedleftarraybackslash}X|}
hline
textbf{ID} & textbf{Severity} & textbf{Vulnerability} &
textbf{Occurrences} \
hline
111111 & Lorem & Lorem ipsum dolor sit amet & 21 \
hline
end{tabularx}
caption{example}
label{table:example}
end{table}
I can use centering
instead of raggedleft
for the last column to center the numbers under the header but then the header ends up too much to the left, I want the header to be like in the above picture.
Is there anyway I can get the combination of these two? The header aligned to the right like in the first picture but the number centered under the header like in the second picture.
tables tabularx alignment
tables tabularx alignment
asked Mar 18 at 10:06
antmoantmo
82
82
Welcome to TeX SX! Have you any reason for a tabularx which flows into the margins?
– Bernard
Mar 18 at 10:21
@Bernard The reason i'm using tabularx is to get the same width as my widest table
– antmo
Mar 18 at 10:27
add a comment |
Welcome to TeX SX! Have you any reason for a tabularx which flows into the margins?
– Bernard
Mar 18 at 10:21
@Bernard The reason i'm using tabularx is to get the same width as my widest table
– antmo
Mar 18 at 10:27
Welcome to TeX SX! Have you any reason for a tabularx which flows into the margins?
– Bernard
Mar 18 at 10:21
Welcome to TeX SX! Have you any reason for a tabularx which flows into the margins?
– Bernard
Mar 18 at 10:21
@Bernard The reason i'm using tabularx is to get the same width as my widest table
– antmo
Mar 18 at 10:27
@Bernard The reason i'm using tabularx is to get the same width as my widest table
– antmo
Mar 18 at 10:27
add a comment |
1 Answer
1
active
oldest
votes
I would use the X
type colum for the 3rd instead of the 4th cell: begin{tabularx}{1.09textwidth}{|clXc|}
. With makecell[r]{textbf{Occurrences}}
you can then right align the header:
documentclass{article}
usepackage{tabularx}
usepackage{makecell}
begin{document}
begin{table}[h]
centering
begin{tabularx}{1.09textwidth}{|clXc|}
hline
textbf{ID} & textbf{Severity} & textbf{Vulnerability} &
makecell[r]{textbf{Occurrences}} \
hline
111111 & Lorem & Lorem ipsum dolor sit amet & 21 \
hline
end{tabularx}
caption{example}
label{table:example}
end{table}
end{document}
2
Maybe usingthead
for all column heads would simplify the code?
– Bernard
Mar 18 at 10:19
1
Thank you, that was an easy solution that gives the right look!
– antmo
Mar 18 at 10:21
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%2f480053%2fcentering-table-data-under-right-aligned-tabularx-header%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
I would use the X
type colum for the 3rd instead of the 4th cell: begin{tabularx}{1.09textwidth}{|clXc|}
. With makecell[r]{textbf{Occurrences}}
you can then right align the header:
documentclass{article}
usepackage{tabularx}
usepackage{makecell}
begin{document}
begin{table}[h]
centering
begin{tabularx}{1.09textwidth}{|clXc|}
hline
textbf{ID} & textbf{Severity} & textbf{Vulnerability} &
makecell[r]{textbf{Occurrences}} \
hline
111111 & Lorem & Lorem ipsum dolor sit amet & 21 \
hline
end{tabularx}
caption{example}
label{table:example}
end{table}
end{document}
2
Maybe usingthead
for all column heads would simplify the code?
– Bernard
Mar 18 at 10:19
1
Thank you, that was an easy solution that gives the right look!
– antmo
Mar 18 at 10:21
add a comment |
I would use the X
type colum for the 3rd instead of the 4th cell: begin{tabularx}{1.09textwidth}{|clXc|}
. With makecell[r]{textbf{Occurrences}}
you can then right align the header:
documentclass{article}
usepackage{tabularx}
usepackage{makecell}
begin{document}
begin{table}[h]
centering
begin{tabularx}{1.09textwidth}{|clXc|}
hline
textbf{ID} & textbf{Severity} & textbf{Vulnerability} &
makecell[r]{textbf{Occurrences}} \
hline
111111 & Lorem & Lorem ipsum dolor sit amet & 21 \
hline
end{tabularx}
caption{example}
label{table:example}
end{table}
end{document}
2
Maybe usingthead
for all column heads would simplify the code?
– Bernard
Mar 18 at 10:19
1
Thank you, that was an easy solution that gives the right look!
– antmo
Mar 18 at 10:21
add a comment |
I would use the X
type colum for the 3rd instead of the 4th cell: begin{tabularx}{1.09textwidth}{|clXc|}
. With makecell[r]{textbf{Occurrences}}
you can then right align the header:
documentclass{article}
usepackage{tabularx}
usepackage{makecell}
begin{document}
begin{table}[h]
centering
begin{tabularx}{1.09textwidth}{|clXc|}
hline
textbf{ID} & textbf{Severity} & textbf{Vulnerability} &
makecell[r]{textbf{Occurrences}} \
hline
111111 & Lorem & Lorem ipsum dolor sit amet & 21 \
hline
end{tabularx}
caption{example}
label{table:example}
end{table}
end{document}
I would use the X
type colum for the 3rd instead of the 4th cell: begin{tabularx}{1.09textwidth}{|clXc|}
. With makecell[r]{textbf{Occurrences}}
you can then right align the header:
documentclass{article}
usepackage{tabularx}
usepackage{makecell}
begin{document}
begin{table}[h]
centering
begin{tabularx}{1.09textwidth}{|clXc|}
hline
textbf{ID} & textbf{Severity} & textbf{Vulnerability} &
makecell[r]{textbf{Occurrences}} \
hline
111111 & Lorem & Lorem ipsum dolor sit amet & 21 \
hline
end{tabularx}
caption{example}
label{table:example}
end{table}
end{document}
answered Mar 18 at 10:13
leandriisleandriis
10.8k1732
10.8k1732
2
Maybe usingthead
for all column heads would simplify the code?
– Bernard
Mar 18 at 10:19
1
Thank you, that was an easy solution that gives the right look!
– antmo
Mar 18 at 10:21
add a comment |
2
Maybe usingthead
for all column heads would simplify the code?
– Bernard
Mar 18 at 10:19
1
Thank you, that was an easy solution that gives the right look!
– antmo
Mar 18 at 10:21
2
2
Maybe using
thead
for all column heads would simplify the code?– Bernard
Mar 18 at 10:19
Maybe using
thead
for all column heads would simplify the code?– Bernard
Mar 18 at 10:19
1
1
Thank you, that was an easy solution that gives the right look!
– antmo
Mar 18 at 10:21
Thank you, that was an easy solution that gives the right look!
– antmo
Mar 18 at 10:21
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%2f480053%2fcentering-table-data-under-right-aligned-tabularx-header%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 SX! Have you any reason for a tabularx which flows into the margins?
– Bernard
Mar 18 at 10:21
@Bernard The reason i'm using tabularx is to get the same width as my widest table
– antmo
Mar 18 at 10:27