Actual table column width is unequal with set number
I want to create a table with fixed column lengths like this:
documentclass[a4paper,12pt]{article}
begin{document}
begin{tabular}{|p{1cm}|p{2cm}|p{3cm}|}
hline
1 cm & 2 cm & 3 cm \
hline
end{tabular}
Table with actual widths
begin{tabular}{|p{0.56cm}|p{1.56cm}|p{2.56cm}|}
hline
1 cm & 2 cm & 3 cm \
hline
end{tabular}
end{document}
But column lengths are not the exact number, that I set. So I found the shift to make column with lengths, that I want.
Why this is happening and how I can automate the process of getting right value?
tables columns lengths
add a comment |
I want to create a table with fixed column lengths like this:
documentclass[a4paper,12pt]{article}
begin{document}
begin{tabular}{|p{1cm}|p{2cm}|p{3cm}|}
hline
1 cm & 2 cm & 3 cm \
hline
end{tabular}
Table with actual widths
begin{tabular}{|p{0.56cm}|p{1.56cm}|p{2.56cm}|}
hline
1 cm & 2 cm & 3 cm \
hline
end{tabular}
end{document}
But column lengths are not the exact number, that I set. So I found the shift to make column with lengths, that I want.
Why this is happening and how I can automate the process of getting right value?
tables columns lengths
2
The argument of thep
columns specifies the textwidth inside the cells, not the total width with padding around the text.
– samcarter
1 hour ago
2
If you just for fun remove all other spacesbegin{tabular}{|@{}p{1cm}@{}|@{}p{2cm}@{}|@{}p{3cm}@{}|}
you can see the effect
– samcarter
1 hour ago
add a comment |
I want to create a table with fixed column lengths like this:
documentclass[a4paper,12pt]{article}
begin{document}
begin{tabular}{|p{1cm}|p{2cm}|p{3cm}|}
hline
1 cm & 2 cm & 3 cm \
hline
end{tabular}
Table with actual widths
begin{tabular}{|p{0.56cm}|p{1.56cm}|p{2.56cm}|}
hline
1 cm & 2 cm & 3 cm \
hline
end{tabular}
end{document}
But column lengths are not the exact number, that I set. So I found the shift to make column with lengths, that I want.
Why this is happening and how I can automate the process of getting right value?
tables columns lengths
I want to create a table with fixed column lengths like this:
documentclass[a4paper,12pt]{article}
begin{document}
begin{tabular}{|p{1cm}|p{2cm}|p{3cm}|}
hline
1 cm & 2 cm & 3 cm \
hline
end{tabular}
Table with actual widths
begin{tabular}{|p{0.56cm}|p{1.56cm}|p{2.56cm}|}
hline
1 cm & 2 cm & 3 cm \
hline
end{tabular}
end{document}
But column lengths are not the exact number, that I set. So I found the shift to make column with lengths, that I want.
Why this is happening and how I can automate the process of getting right value?
tables columns lengths
tables columns lengths
asked 1 hour ago
Shalom AlecheimShalom Alecheim
626
626
2
The argument of thep
columns specifies the textwidth inside the cells, not the total width with padding around the text.
– samcarter
1 hour ago
2
If you just for fun remove all other spacesbegin{tabular}{|@{}p{1cm}@{}|@{}p{2cm}@{}|@{}p{3cm}@{}|}
you can see the effect
– samcarter
1 hour ago
add a comment |
2
The argument of thep
columns specifies the textwidth inside the cells, not the total width with padding around the text.
– samcarter
1 hour ago
2
If you just for fun remove all other spacesbegin{tabular}{|@{}p{1cm}@{}|@{}p{2cm}@{}|@{}p{3cm}@{}|}
you can see the effect
– samcarter
1 hour ago
2
2
The argument of the
p
columns specifies the textwidth inside the cells, not the total width with padding around the text.– samcarter
1 hour ago
The argument of the
p
columns specifies the textwidth inside the cells, not the total width with padding around the text.– samcarter
1 hour ago
2
2
If you just for fun remove all other spaces
begin{tabular}{|@{}p{1cm}@{}|@{}p{2cm}@{}|@{}p{3cm}@{}|}
you can see the effect– samcarter
1 hour ago
If you just for fun remove all other spaces
begin{tabular}{|@{}p{1cm}@{}|@{}p{2cm}@{}|@{}p{3cm}@{}|}
you can see the effect– samcarter
1 hour ago
add a comment |
2 Answers
2
active
oldest
votes
documentclass[a4paper,12pt]{article}
begin{document}
setlengtharrayrulewidth{2pt}
begin{tabular}{|p{dimexpr1cm-2tabcolsep}
|p{dimexpr2cm-2tabcolsep}
|p{dimexpr3cm-2tabcolsep}|}
hline
1 cm & 2 cm & 3 cm \
hline
end{tabular}
rule{6cm}{2pt}
end{document}
make absolute width of cells as you like to have. rule
is comparison of the table width.
add a comment |
Almost the same as @Zarko's answer, except reducing the (fine) length of the line separating columns... and a introducing a customized macro:
documentclass[a4paper,12pt]{article}
usepackage{array, calc}
newlength{lw}
setlength{lw}{2tabcolsep+arrayrulewidth}
begin{document}
begin{tabular}{| p{1cm-lw} | p{2cm-lw} | p{3cm-lw} |}
hline
1 cm & 2 cm & 3 cm \
hline
end{tabular}
Table with actual widths
begin{tabular}{|p{0.56cm}|p{1.56cm}|p{2.56cm}|}
hline
1 cm & 2 cm & 3 cm \
hline
end{tabular}
end{document}
producing :
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%2f470712%2factual-table-column-width-is-unequal-with-set-number%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
documentclass[a4paper,12pt]{article}
begin{document}
setlengtharrayrulewidth{2pt}
begin{tabular}{|p{dimexpr1cm-2tabcolsep}
|p{dimexpr2cm-2tabcolsep}
|p{dimexpr3cm-2tabcolsep}|}
hline
1 cm & 2 cm & 3 cm \
hline
end{tabular}
rule{6cm}{2pt}
end{document}
make absolute width of cells as you like to have. rule
is comparison of the table width.
add a comment |
documentclass[a4paper,12pt]{article}
begin{document}
setlengtharrayrulewidth{2pt}
begin{tabular}{|p{dimexpr1cm-2tabcolsep}
|p{dimexpr2cm-2tabcolsep}
|p{dimexpr3cm-2tabcolsep}|}
hline
1 cm & 2 cm & 3 cm \
hline
end{tabular}
rule{6cm}{2pt}
end{document}
make absolute width of cells as you like to have. rule
is comparison of the table width.
add a comment |
documentclass[a4paper,12pt]{article}
begin{document}
setlengtharrayrulewidth{2pt}
begin{tabular}{|p{dimexpr1cm-2tabcolsep}
|p{dimexpr2cm-2tabcolsep}
|p{dimexpr3cm-2tabcolsep}|}
hline
1 cm & 2 cm & 3 cm \
hline
end{tabular}
rule{6cm}{2pt}
end{document}
make absolute width of cells as you like to have. rule
is comparison of the table width.
documentclass[a4paper,12pt]{article}
begin{document}
setlengtharrayrulewidth{2pt}
begin{tabular}{|p{dimexpr1cm-2tabcolsep}
|p{dimexpr2cm-2tabcolsep}
|p{dimexpr3cm-2tabcolsep}|}
hline
1 cm & 2 cm & 3 cm \
hline
end{tabular}
rule{6cm}{2pt}
end{document}
make absolute width of cells as you like to have. rule
is comparison of the table width.
answered 1 hour ago
ZarkoZarko
122k865160
122k865160
add a comment |
add a comment |
Almost the same as @Zarko's answer, except reducing the (fine) length of the line separating columns... and a introducing a customized macro:
documentclass[a4paper,12pt]{article}
usepackage{array, calc}
newlength{lw}
setlength{lw}{2tabcolsep+arrayrulewidth}
begin{document}
begin{tabular}{| p{1cm-lw} | p{2cm-lw} | p{3cm-lw} |}
hline
1 cm & 2 cm & 3 cm \
hline
end{tabular}
Table with actual widths
begin{tabular}{|p{0.56cm}|p{1.56cm}|p{2.56cm}|}
hline
1 cm & 2 cm & 3 cm \
hline
end{tabular}
end{document}
producing :
add a comment |
Almost the same as @Zarko's answer, except reducing the (fine) length of the line separating columns... and a introducing a customized macro:
documentclass[a4paper,12pt]{article}
usepackage{array, calc}
newlength{lw}
setlength{lw}{2tabcolsep+arrayrulewidth}
begin{document}
begin{tabular}{| p{1cm-lw} | p{2cm-lw} | p{3cm-lw} |}
hline
1 cm & 2 cm & 3 cm \
hline
end{tabular}
Table with actual widths
begin{tabular}{|p{0.56cm}|p{1.56cm}|p{2.56cm}|}
hline
1 cm & 2 cm & 3 cm \
hline
end{tabular}
end{document}
producing :
add a comment |
Almost the same as @Zarko's answer, except reducing the (fine) length of the line separating columns... and a introducing a customized macro:
documentclass[a4paper,12pt]{article}
usepackage{array, calc}
newlength{lw}
setlength{lw}{2tabcolsep+arrayrulewidth}
begin{document}
begin{tabular}{| p{1cm-lw} | p{2cm-lw} | p{3cm-lw} |}
hline
1 cm & 2 cm & 3 cm \
hline
end{tabular}
Table with actual widths
begin{tabular}{|p{0.56cm}|p{1.56cm}|p{2.56cm}|}
hline
1 cm & 2 cm & 3 cm \
hline
end{tabular}
end{document}
producing :
Almost the same as @Zarko's answer, except reducing the (fine) length of the line separating columns... and a introducing a customized macro:
documentclass[a4paper,12pt]{article}
usepackage{array, calc}
newlength{lw}
setlength{lw}{2tabcolsep+arrayrulewidth}
begin{document}
begin{tabular}{| p{1cm-lw} | p{2cm-lw} | p{3cm-lw} |}
hline
1 cm & 2 cm & 3 cm \
hline
end{tabular}
Table with actual widths
begin{tabular}{|p{0.56cm}|p{1.56cm}|p{2.56cm}|}
hline
1 cm & 2 cm & 3 cm \
hline
end{tabular}
end{document}
producing :
answered 1 hour ago
Partha D.Partha D.
46816
46816
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%2f470712%2factual-table-column-width-is-unequal-with-set-number%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
2
The argument of the
p
columns specifies the textwidth inside the cells, not the total width with padding around the text.– samcarter
1 hour ago
2
If you just for fun remove all other spaces
begin{tabular}{|@{}p{1cm}@{}|@{}p{2cm}@{}|@{}p{3cm}@{}|}
you can see the effect– samcarter
1 hour ago