How to center the middle of a table to be in the center of the page?
I'd like to have the vertical rule in my {r|l}
table to be horizontally aligned in the center of the page.
So far, I've only managed to do
begin{center}
begin{tabular}{r|l}
short & long long long \
short & long long long \
short & long long \
short & long long long\
end{tabular}
end{center}
begin{center}
begin{tabular}{r|l}
long long & short
end{tabular}
end{center}
which yields
How can I center the vertical lines of my tables to be in the center of the page?
tables horizontal-alignment
New contributor
add a comment |
I'd like to have the vertical rule in my {r|l}
table to be horizontally aligned in the center of the page.
So far, I've only managed to do
begin{center}
begin{tabular}{r|l}
short & long long long \
short & long long long \
short & long long \
short & long long long\
end{tabular}
end{center}
begin{center}
begin{tabular}{r|l}
long long & short
end{tabular}
end{center}
which yields
How can I center the vertical lines of my tables to be in the center of the page?
tables horizontal-alignment
New contributor
I'd like to have them both aligned such that the vertical line is in the middle of pagewidth
– Stephan
2 hours ago
add a comment |
I'd like to have the vertical rule in my {r|l}
table to be horizontally aligned in the center of the page.
So far, I've only managed to do
begin{center}
begin{tabular}{r|l}
short & long long long \
short & long long long \
short & long long \
short & long long long\
end{tabular}
end{center}
begin{center}
begin{tabular}{r|l}
long long & short
end{tabular}
end{center}
which yields
How can I center the vertical lines of my tables to be in the center of the page?
tables horizontal-alignment
New contributor
I'd like to have the vertical rule in my {r|l}
table to be horizontally aligned in the center of the page.
So far, I've only managed to do
begin{center}
begin{tabular}{r|l}
short & long long long \
short & long long long \
short & long long \
short & long long long\
end{tabular}
end{center}
begin{center}
begin{tabular}{r|l}
long long & short
end{tabular}
end{center}
which yields
How can I center the vertical lines of my tables to be in the center of the page?
tables horizontal-alignment
tables horizontal-alignment
New contributor
New contributor
New contributor
asked 3 hours ago
StephanStephan
1084
1084
New contributor
New contributor
I'd like to have them both aligned such that the vertical line is in the middle of pagewidth
– Stephan
2 hours ago
add a comment |
I'd like to have them both aligned such that the vertical line is in the middle of pagewidth
– Stephan
2 hours ago
I'd like to have them both aligned such that the vertical line is in the middle of pagewidth
– Stephan
2 hours ago
I'd like to have them both aligned such that the vertical line is in the middle of pagewidth
– Stephan
2 hours ago
add a comment |
2 Answers
2
active
oldest
votes
You may need to define new column type (thanks @lockstep in his answer)
documentclass{article}
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}}
begin{document}
begin{tabular}{ R{0.465textwidth} | L{0.465textwidth}}
short & long long long \
short & long long long \
short & long long \
short & long long long\
end{tabular}
begin{tabular}{ R{0.465textwidth} | L{0.465textwidth}}
long long & short
end{tabular}
end{document}
which gives
That's exactly it, thank you! One question though: why is raggedleft used in the right-aligned column?
– Stephan
2 hours ago
1
The commandraggedleft
pushes all text to the right of the line or column, keeping the left side text margin ragged. // ...One more minor correction to my answer:0.49textwidth
gives an "Overfull hbox (10.59pt too wide)". This is due to the column separator and the adjacent spaces on either side. So, you will have to allot somewhat less width to the columns to really center the column-separator. In my example, 0.465 worked best (editing accordingly).
– Partha D.
1 hour ago
add a comment |
You could give a fixed length to the columns of the tables.
If you want the columns to occupy all the space possible in the half of the line, you have to calculate their column width in this way, in order to not have an overfull hbox:.5linewidth
(half line)-2tabsep
(minus the two spaces before and after the text column)-.5arrayrulewidth
(minus half of the width of the vertical bar).
In my MWE I use the calc
package, without it you can write setlength{myhalfpage}{dimexpr .5linewidth-2tabcolsep-.5arrayrulewidth}
to get the same result.
You can use lockstep's definitions with this length.
documentclass{article}
usepackage{array}
usepackage{calc}
newlength{myhalfpage}
setlength{myhalfpage}{.5linewidth-2tabcolsep-.5arrayrulewidth}
newcolumntype{L}{>{raggedrightletnewline\arraybackslashhspace{0pt}}m{myhalfpage}}
newcolumntype{C}{>{centeringletnewline\arraybackslashhspace{0pt}}m{myhalfpage}}
newcolumntype{R}{>{raggedleftletnewline\arraybackslashhspace{0pt}}m{myhalfpage}}
begin{document}
begin{center}
begin{tabular}{R|L}
short & long long long \
short & long long long \
short & long long \
short & long long long\
end{tabular}
end{center}
begin{center}
begin{tabular}{R|L}
long long & short
end{tabular}
end{center}
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
});
}
});
Stephan is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
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%2f470181%2fhow-to-center-the-middle-of-a-table-to-be-in-the-center-of-the-page%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You may need to define new column type (thanks @lockstep in his answer)
documentclass{article}
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}}
begin{document}
begin{tabular}{ R{0.465textwidth} | L{0.465textwidth}}
short & long long long \
short & long long long \
short & long long \
short & long long long\
end{tabular}
begin{tabular}{ R{0.465textwidth} | L{0.465textwidth}}
long long & short
end{tabular}
end{document}
which gives
That's exactly it, thank you! One question though: why is raggedleft used in the right-aligned column?
– Stephan
2 hours ago
1
The commandraggedleft
pushes all text to the right of the line or column, keeping the left side text margin ragged. // ...One more minor correction to my answer:0.49textwidth
gives an "Overfull hbox (10.59pt too wide)". This is due to the column separator and the adjacent spaces on either side. So, you will have to allot somewhat less width to the columns to really center the column-separator. In my example, 0.465 worked best (editing accordingly).
– Partha D.
1 hour ago
add a comment |
You may need to define new column type (thanks @lockstep in his answer)
documentclass{article}
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}}
begin{document}
begin{tabular}{ R{0.465textwidth} | L{0.465textwidth}}
short & long long long \
short & long long long \
short & long long \
short & long long long\
end{tabular}
begin{tabular}{ R{0.465textwidth} | L{0.465textwidth}}
long long & short
end{tabular}
end{document}
which gives
That's exactly it, thank you! One question though: why is raggedleft used in the right-aligned column?
– Stephan
2 hours ago
1
The commandraggedleft
pushes all text to the right of the line or column, keeping the left side text margin ragged. // ...One more minor correction to my answer:0.49textwidth
gives an "Overfull hbox (10.59pt too wide)". This is due to the column separator and the adjacent spaces on either side. So, you will have to allot somewhat less width to the columns to really center the column-separator. In my example, 0.465 worked best (editing accordingly).
– Partha D.
1 hour ago
add a comment |
You may need to define new column type (thanks @lockstep in his answer)
documentclass{article}
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}}
begin{document}
begin{tabular}{ R{0.465textwidth} | L{0.465textwidth}}
short & long long long \
short & long long long \
short & long long \
short & long long long\
end{tabular}
begin{tabular}{ R{0.465textwidth} | L{0.465textwidth}}
long long & short
end{tabular}
end{document}
which gives
You may need to define new column type (thanks @lockstep in his answer)
documentclass{article}
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}}
begin{document}
begin{tabular}{ R{0.465textwidth} | L{0.465textwidth}}
short & long long long \
short & long long long \
short & long long \
short & long long long\
end{tabular}
begin{tabular}{ R{0.465textwidth} | L{0.465textwidth}}
long long & short
end{tabular}
end{document}
which gives
edited 1 hour ago
answered 2 hours ago
Partha D.Partha D.
39316
39316
That's exactly it, thank you! One question though: why is raggedleft used in the right-aligned column?
– Stephan
2 hours ago
1
The commandraggedleft
pushes all text to the right of the line or column, keeping the left side text margin ragged. // ...One more minor correction to my answer:0.49textwidth
gives an "Overfull hbox (10.59pt too wide)". This is due to the column separator and the adjacent spaces on either side. So, you will have to allot somewhat less width to the columns to really center the column-separator. In my example, 0.465 worked best (editing accordingly).
– Partha D.
1 hour ago
add a comment |
That's exactly it, thank you! One question though: why is raggedleft used in the right-aligned column?
– Stephan
2 hours ago
1
The commandraggedleft
pushes all text to the right of the line or column, keeping the left side text margin ragged. // ...One more minor correction to my answer:0.49textwidth
gives an "Overfull hbox (10.59pt too wide)". This is due to the column separator and the adjacent spaces on either side. So, you will have to allot somewhat less width to the columns to really center the column-separator. In my example, 0.465 worked best (editing accordingly).
– Partha D.
1 hour ago
That's exactly it, thank you! One question though: why is raggedleft used in the right-aligned column?
– Stephan
2 hours ago
That's exactly it, thank you! One question though: why is raggedleft used in the right-aligned column?
– Stephan
2 hours ago
1
1
The command
raggedleft
pushes all text to the right of the line or column, keeping the left side text margin ragged. // ...One more minor correction to my answer: 0.49textwidth
gives an "Overfull hbox (10.59pt too wide)". This is due to the column separator and the adjacent spaces on either side. So, you will have to allot somewhat less width to the columns to really center the column-separator. In my example, 0.465 worked best (editing accordingly).– Partha D.
1 hour ago
The command
raggedleft
pushes all text to the right of the line or column, keeping the left side text margin ragged. // ...One more minor correction to my answer: 0.49textwidth
gives an "Overfull hbox (10.59pt too wide)". This is due to the column separator and the adjacent spaces on either side. So, you will have to allot somewhat less width to the columns to really center the column-separator. In my example, 0.465 worked best (editing accordingly).– Partha D.
1 hour ago
add a comment |
You could give a fixed length to the columns of the tables.
If you want the columns to occupy all the space possible in the half of the line, you have to calculate their column width in this way, in order to not have an overfull hbox:.5linewidth
(half line)-2tabsep
(minus the two spaces before and after the text column)-.5arrayrulewidth
(minus half of the width of the vertical bar).
In my MWE I use the calc
package, without it you can write setlength{myhalfpage}{dimexpr .5linewidth-2tabcolsep-.5arrayrulewidth}
to get the same result.
You can use lockstep's definitions with this length.
documentclass{article}
usepackage{array}
usepackage{calc}
newlength{myhalfpage}
setlength{myhalfpage}{.5linewidth-2tabcolsep-.5arrayrulewidth}
newcolumntype{L}{>{raggedrightletnewline\arraybackslashhspace{0pt}}m{myhalfpage}}
newcolumntype{C}{>{centeringletnewline\arraybackslashhspace{0pt}}m{myhalfpage}}
newcolumntype{R}{>{raggedleftletnewline\arraybackslashhspace{0pt}}m{myhalfpage}}
begin{document}
begin{center}
begin{tabular}{R|L}
short & long long long \
short & long long long \
short & long long \
short & long long long\
end{tabular}
end{center}
begin{center}
begin{tabular}{R|L}
long long & short
end{tabular}
end{center}
end{document}
add a comment |
You could give a fixed length to the columns of the tables.
If you want the columns to occupy all the space possible in the half of the line, you have to calculate their column width in this way, in order to not have an overfull hbox:.5linewidth
(half line)-2tabsep
(minus the two spaces before and after the text column)-.5arrayrulewidth
(minus half of the width of the vertical bar).
In my MWE I use the calc
package, without it you can write setlength{myhalfpage}{dimexpr .5linewidth-2tabcolsep-.5arrayrulewidth}
to get the same result.
You can use lockstep's definitions with this length.
documentclass{article}
usepackage{array}
usepackage{calc}
newlength{myhalfpage}
setlength{myhalfpage}{.5linewidth-2tabcolsep-.5arrayrulewidth}
newcolumntype{L}{>{raggedrightletnewline\arraybackslashhspace{0pt}}m{myhalfpage}}
newcolumntype{C}{>{centeringletnewline\arraybackslashhspace{0pt}}m{myhalfpage}}
newcolumntype{R}{>{raggedleftletnewline\arraybackslashhspace{0pt}}m{myhalfpage}}
begin{document}
begin{center}
begin{tabular}{R|L}
short & long long long \
short & long long long \
short & long long \
short & long long long\
end{tabular}
end{center}
begin{center}
begin{tabular}{R|L}
long long & short
end{tabular}
end{center}
end{document}
add a comment |
You could give a fixed length to the columns of the tables.
If you want the columns to occupy all the space possible in the half of the line, you have to calculate their column width in this way, in order to not have an overfull hbox:.5linewidth
(half line)-2tabsep
(minus the two spaces before and after the text column)-.5arrayrulewidth
(minus half of the width of the vertical bar).
In my MWE I use the calc
package, without it you can write setlength{myhalfpage}{dimexpr .5linewidth-2tabcolsep-.5arrayrulewidth}
to get the same result.
You can use lockstep's definitions with this length.
documentclass{article}
usepackage{array}
usepackage{calc}
newlength{myhalfpage}
setlength{myhalfpage}{.5linewidth-2tabcolsep-.5arrayrulewidth}
newcolumntype{L}{>{raggedrightletnewline\arraybackslashhspace{0pt}}m{myhalfpage}}
newcolumntype{C}{>{centeringletnewline\arraybackslashhspace{0pt}}m{myhalfpage}}
newcolumntype{R}{>{raggedleftletnewline\arraybackslashhspace{0pt}}m{myhalfpage}}
begin{document}
begin{center}
begin{tabular}{R|L}
short & long long long \
short & long long long \
short & long long \
short & long long long\
end{tabular}
end{center}
begin{center}
begin{tabular}{R|L}
long long & short
end{tabular}
end{center}
end{document}
You could give a fixed length to the columns of the tables.
If you want the columns to occupy all the space possible in the half of the line, you have to calculate their column width in this way, in order to not have an overfull hbox:.5linewidth
(half line)-2tabsep
(minus the two spaces before and after the text column)-.5arrayrulewidth
(minus half of the width of the vertical bar).
In my MWE I use the calc
package, without it you can write setlength{myhalfpage}{dimexpr .5linewidth-2tabcolsep-.5arrayrulewidth}
to get the same result.
You can use lockstep's definitions with this length.
documentclass{article}
usepackage{array}
usepackage{calc}
newlength{myhalfpage}
setlength{myhalfpage}{.5linewidth-2tabcolsep-.5arrayrulewidth}
newcolumntype{L}{>{raggedrightletnewline\arraybackslashhspace{0pt}}m{myhalfpage}}
newcolumntype{C}{>{centeringletnewline\arraybackslashhspace{0pt}}m{myhalfpage}}
newcolumntype{R}{>{raggedleftletnewline\arraybackslashhspace{0pt}}m{myhalfpage}}
begin{document}
begin{center}
begin{tabular}{R|L}
short & long long long \
short & long long long \
short & long long \
short & long long long\
end{tabular}
end{center}
begin{center}
begin{tabular}{R|L}
long long & short
end{tabular}
end{center}
end{document}
edited 9 mins ago
answered 2 hours ago
CarLaTeXCarLaTeX
30.2k447127
30.2k447127
add a comment |
add a comment |
Stephan is a new contributor. Be nice, and check out our Code of Conduct.
Stephan is a new contributor. Be nice, and check out our Code of Conduct.
Stephan is a new contributor. Be nice, and check out our Code of Conduct.
Stephan 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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
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%2f470181%2fhow-to-center-the-middle-of-a-table-to-be-in-the-center-of-the-page%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');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
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');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
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');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
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
I'd like to have them both aligned such that the vertical line is in the middle of pagewidth
– Stephan
2 hours ago