Centre cell vertically in tabularx across multiple multiline rows
Consider this example:
documentclass{report}
usepackage{tabularx}
usepackage{lipsum}
usepackage{multirow}
renewcommand{tabularxcolumn}[1]{m{#1}}
begin{document}
begin{tabularx}{0.5linewidth}{llX}
multirow{2}{*}{A} & B & lipsum[1][1-2] \
& C & lipsum[2][1-3]\
end{tabularx}
end{document}
The output is
I have used Vertical alignment in tabularx X column type to centre cells vertically.
However, I am not pleased the way "A" is centred. It uses multirow
. How to centre "A" vertically in the middle of the table?
Solution that avoids the use of multirow
is also accepted.
tables vertical-alignment tabularx multirow
|
show 2 more comments
Consider this example:
documentclass{report}
usepackage{tabularx}
usepackage{lipsum}
usepackage{multirow}
renewcommand{tabularxcolumn}[1]{m{#1}}
begin{document}
begin{tabularx}{0.5linewidth}{llX}
multirow{2}{*}{A} & B & lipsum[1][1-2] \
& C & lipsum[2][1-3]\
end{tabularx}
end{document}
The output is
I have used Vertical alignment in tabularx X column type to centre cells vertically.
However, I am not pleased the way "A" is centred. It uses multirow
. How to centre "A" vertically in the middle of the table?
Solution that avoids the use of multirow
is also accepted.
tables vertical-alignment tabularx multirow
Maybe you can try withmultirow{8}{*}{A}
.
– leandriis
1 hour ago
Since you madem
the underlying column type, since the cells in column 3 occupy 12 rows in all, and since one half of 12 is 6, you should replacemultirow{2}{*}{A}
withmultirow{6}{*}{A}
.
– Mico
1 hour ago
@Mico: Wouldn't one typically usemultirow{12}
in order to vertically center a cell adjacent to a cell that contains 12 lines of text? However, in the OP's case the redefinition of theX
type column usingrenewcommand{tabularxcolumn}[1]{m{#1}}
seems to interfere with that.
– leandriis
1 hour ago
@leandriis, then I need to manually count rows. So laborious when dealing with many tables, changing text.
– Viesturs
1 hour ago
@leandriis - Indeed, if therenewcommand{tabularxcolumn}[1]{m{#1}}
directive weren't there, one would have to use12
, not6
, as the first argument ofmultirow
.
– Mico
1 hour ago
|
show 2 more comments
Consider this example:
documentclass{report}
usepackage{tabularx}
usepackage{lipsum}
usepackage{multirow}
renewcommand{tabularxcolumn}[1]{m{#1}}
begin{document}
begin{tabularx}{0.5linewidth}{llX}
multirow{2}{*}{A} & B & lipsum[1][1-2] \
& C & lipsum[2][1-3]\
end{tabularx}
end{document}
The output is
I have used Vertical alignment in tabularx X column type to centre cells vertically.
However, I am not pleased the way "A" is centred. It uses multirow
. How to centre "A" vertically in the middle of the table?
Solution that avoids the use of multirow
is also accepted.
tables vertical-alignment tabularx multirow
Consider this example:
documentclass{report}
usepackage{tabularx}
usepackage{lipsum}
usepackage{multirow}
renewcommand{tabularxcolumn}[1]{m{#1}}
begin{document}
begin{tabularx}{0.5linewidth}{llX}
multirow{2}{*}{A} & B & lipsum[1][1-2] \
& C & lipsum[2][1-3]\
end{tabularx}
end{document}
The output is
I have used Vertical alignment in tabularx X column type to centre cells vertically.
However, I am not pleased the way "A" is centred. It uses multirow
. How to centre "A" vertically in the middle of the table?
Solution that avoids the use of multirow
is also accepted.
tables vertical-alignment tabularx multirow
tables vertical-alignment tabularx multirow
edited 52 mins ago
Viesturs
asked 1 hour ago
ViestursViesturs
2,06241327
2,06241327
Maybe you can try withmultirow{8}{*}{A}
.
– leandriis
1 hour ago
Since you madem
the underlying column type, since the cells in column 3 occupy 12 rows in all, and since one half of 12 is 6, you should replacemultirow{2}{*}{A}
withmultirow{6}{*}{A}
.
– Mico
1 hour ago
@Mico: Wouldn't one typically usemultirow{12}
in order to vertically center a cell adjacent to a cell that contains 12 lines of text? However, in the OP's case the redefinition of theX
type column usingrenewcommand{tabularxcolumn}[1]{m{#1}}
seems to interfere with that.
– leandriis
1 hour ago
@leandriis, then I need to manually count rows. So laborious when dealing with many tables, changing text.
– Viesturs
1 hour ago
@leandriis - Indeed, if therenewcommand{tabularxcolumn}[1]{m{#1}}
directive weren't there, one would have to use12
, not6
, as the first argument ofmultirow
.
– Mico
1 hour ago
|
show 2 more comments
Maybe you can try withmultirow{8}{*}{A}
.
– leandriis
1 hour ago
Since you madem
the underlying column type, since the cells in column 3 occupy 12 rows in all, and since one half of 12 is 6, you should replacemultirow{2}{*}{A}
withmultirow{6}{*}{A}
.
– Mico
1 hour ago
@Mico: Wouldn't one typically usemultirow{12}
in order to vertically center a cell adjacent to a cell that contains 12 lines of text? However, in the OP's case the redefinition of theX
type column usingrenewcommand{tabularxcolumn}[1]{m{#1}}
seems to interfere with that.
– leandriis
1 hour ago
@leandriis, then I need to manually count rows. So laborious when dealing with many tables, changing text.
– Viesturs
1 hour ago
@leandriis - Indeed, if therenewcommand{tabularxcolumn}[1]{m{#1}}
directive weren't there, one would have to use12
, not6
, as the first argument ofmultirow
.
– Mico
1 hour ago
Maybe you can try with
multirow{8}{*}{A}
.– leandriis
1 hour ago
Maybe you can try with
multirow{8}{*}{A}
.– leandriis
1 hour ago
Since you made
m
the underlying column type, since the cells in column 3 occupy 12 rows in all, and since one half of 12 is 6, you should replace multirow{2}{*}{A}
with multirow{6}{*}{A}
.– Mico
1 hour ago
Since you made
m
the underlying column type, since the cells in column 3 occupy 12 rows in all, and since one half of 12 is 6, you should replace multirow{2}{*}{A}
with multirow{6}{*}{A}
.– Mico
1 hour ago
@Mico: Wouldn't one typically use
multirow{12}
in order to vertically center a cell adjacent to a cell that contains 12 lines of text? However, in the OP's case the redefinition of the X
type column using renewcommand{tabularxcolumn}[1]{m{#1}}
seems to interfere with that.– leandriis
1 hour ago
@Mico: Wouldn't one typically use
multirow{12}
in order to vertically center a cell adjacent to a cell that contains 12 lines of text? However, in the OP's case the redefinition of the X
type column using renewcommand{tabularxcolumn}[1]{m{#1}}
seems to interfere with that.– leandriis
1 hour ago
@leandriis, then I need to manually count rows. So laborious when dealing with many tables, changing text.
– Viesturs
1 hour ago
@leandriis, then I need to manually count rows. So laborious when dealing with many tables, changing text.
– Viesturs
1 hour ago
@leandriis - Indeed, if the
renewcommand{tabularxcolumn}[1]{m{#1}}
directive weren't there, one would have to use 12
, not 6
, as the first argument of multirow
.– Mico
1 hour ago
@leandriis - Indeed, if the
renewcommand{tabularxcolumn}[1]{m{#1}}
directive weren't there, one would have to use 12
, not 6
, as the first argument of multirow
.– Mico
1 hour ago
|
show 2 more comments
3 Answers
3
active
oldest
votes
As Ulrike said in a comment, to avoid manual adjustment, nesting tabular
s could be a solution.
I would put a tabular
with an m
column of appropriate width in the main tabular
.
I added the lines just to show the "A" is vertically centered.
documentclass{report}
usepackage{tabularx}
usepackage{array}
usepackage{lipsum}
begin{document}
noindentbegin{tabular}{|ll}
hline
A &
begin{tabular}{@{}lm{.352linewidth}@{}}
B & lipsum[1][1-2]\
C & lipsum[2][1-3]\
end{tabular}\
hline
end{tabular}
vspace{4ex}noindentbegin{tabularx}{.5linewidth}{|llX}
hline
A & B & Just for benchmark\
hline
end{tabularx}
end{document}
In case of multiple multirow cells nesting in a nesting would be required.
– Viesturs
38 mins ago
@Viesturs Yes, it may be
– CarLaTeX
37 mins ago
add a comment |
Here is a possibe solution using a minipage
and a tabularx
:
documentclass{report}
usepackage{tabularx}
usepackage{lipsum}
usepackage{multirow}
renewcommand{tabularxcolumn}[1]{m{#1}}
usepackage{calc}
begin{document}
begin{minipage}{2em}
A
end{minipage}%
begin{tabularx}{0.5linewidth-2em}{lX}
B & lipsum[1][1-2] \
C & lipsum[2][1-3]\
end{tabularx}
end{document}
add a comment |
In this case you can use a 1-row multicolumn as the baseline of the m-column is there. In other cases you will have to use the vmode-option described in the documentation. Imho while multirow works okay with 1-line cells it is imho rather a pain with m- and p-columns and I use it seldom.
documentclass{report}
usepackage{tabularx}
usepackage{lipsum}
usepackage{multirow}
begin{document}
% with X as p-column 5 works:
begin{tabularx}{0.5linewidth}{llX}
multirow{5}{*}{A} & B & lipsum[1][1-2] \
& C & lipsum[2][1-3]\
end{tabularx}
%X as m-column:
renewcommand{tabularxcolumn}[1]{m{#1}}
begin{tabularx}{0.5linewidth}{llX}
multirow{1}{*}{A} & B & lipsum[1][1-2] \
& C & lipsum[2][1-3]\
end{tabularx}
end{document}
To center the A over both cells use a value of 8.5 or 9 works (that's the number of lines below the baseline of the first cell.
documentclass{report}
usepackage{tabularx}
usepackage{lipsum}
usepackage{multirow}
renewcommand{tabularxcolumn}[1]{m{#1}}
begin{document}
begin{tabularx}{0.5linewidth}{llX}
multirow{9}{*}{A} & B & lipsum[1][1-2] \
& C & lipsum[2][1-3]\
end{tabularx}
end{document}
Where is the improvement? Apparently I was not clear in my question, but by nicely I mean "A" centred vertically in the middle of the table. I updated my question.
– Viesturs
1 hour ago
Ah sorry, I added an edit.
– Ulrike Fischer
1 hour ago
Now there are 6 lines above and 5 below "A".7
works for me. This solution requires a tedious counting of lines manually.
– Viesturs
1 hour ago
1
Yes, but the A is aligned to a line. It is up to you to decide what is visual more pleasing. And yes, it is a pain - I already wrote in the answer. I wouldn't use multirow but nested tabulars or even simple boxes for such a layout.
– Ulrike Fischer
1 hour ago
it could be worthwhile to provide your solution with nested tabulars or simple boxes.
– Viesturs
1 hour ago
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%2f486010%2fcentre-cell-vertically-in-tabularx-across-multiple-multiline-rows%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
As Ulrike said in a comment, to avoid manual adjustment, nesting tabular
s could be a solution.
I would put a tabular
with an m
column of appropriate width in the main tabular
.
I added the lines just to show the "A" is vertically centered.
documentclass{report}
usepackage{tabularx}
usepackage{array}
usepackage{lipsum}
begin{document}
noindentbegin{tabular}{|ll}
hline
A &
begin{tabular}{@{}lm{.352linewidth}@{}}
B & lipsum[1][1-2]\
C & lipsum[2][1-3]\
end{tabular}\
hline
end{tabular}
vspace{4ex}noindentbegin{tabularx}{.5linewidth}{|llX}
hline
A & B & Just for benchmark\
hline
end{tabularx}
end{document}
In case of multiple multirow cells nesting in a nesting would be required.
– Viesturs
38 mins ago
@Viesturs Yes, it may be
– CarLaTeX
37 mins ago
add a comment |
As Ulrike said in a comment, to avoid manual adjustment, nesting tabular
s could be a solution.
I would put a tabular
with an m
column of appropriate width in the main tabular
.
I added the lines just to show the "A" is vertically centered.
documentclass{report}
usepackage{tabularx}
usepackage{array}
usepackage{lipsum}
begin{document}
noindentbegin{tabular}{|ll}
hline
A &
begin{tabular}{@{}lm{.352linewidth}@{}}
B & lipsum[1][1-2]\
C & lipsum[2][1-3]\
end{tabular}\
hline
end{tabular}
vspace{4ex}noindentbegin{tabularx}{.5linewidth}{|llX}
hline
A & B & Just for benchmark\
hline
end{tabularx}
end{document}
In case of multiple multirow cells nesting in a nesting would be required.
– Viesturs
38 mins ago
@Viesturs Yes, it may be
– CarLaTeX
37 mins ago
add a comment |
As Ulrike said in a comment, to avoid manual adjustment, nesting tabular
s could be a solution.
I would put a tabular
with an m
column of appropriate width in the main tabular
.
I added the lines just to show the "A" is vertically centered.
documentclass{report}
usepackage{tabularx}
usepackage{array}
usepackage{lipsum}
begin{document}
noindentbegin{tabular}{|ll}
hline
A &
begin{tabular}{@{}lm{.352linewidth}@{}}
B & lipsum[1][1-2]\
C & lipsum[2][1-3]\
end{tabular}\
hline
end{tabular}
vspace{4ex}noindentbegin{tabularx}{.5linewidth}{|llX}
hline
A & B & Just for benchmark\
hline
end{tabularx}
end{document}
As Ulrike said in a comment, to avoid manual adjustment, nesting tabular
s could be a solution.
I would put a tabular
with an m
column of appropriate width in the main tabular
.
I added the lines just to show the "A" is vertically centered.
documentclass{report}
usepackage{tabularx}
usepackage{array}
usepackage{lipsum}
begin{document}
noindentbegin{tabular}{|ll}
hline
A &
begin{tabular}{@{}lm{.352linewidth}@{}}
B & lipsum[1][1-2]\
C & lipsum[2][1-3]\
end{tabular}\
hline
end{tabular}
vspace{4ex}noindentbegin{tabularx}{.5linewidth}{|llX}
hline
A & B & Just for benchmark\
hline
end{tabularx}
end{document}
edited 40 mins ago
answered 53 mins ago
CarLaTeXCarLaTeX
35.3k554152
35.3k554152
In case of multiple multirow cells nesting in a nesting would be required.
– Viesturs
38 mins ago
@Viesturs Yes, it may be
– CarLaTeX
37 mins ago
add a comment |
In case of multiple multirow cells nesting in a nesting would be required.
– Viesturs
38 mins ago
@Viesturs Yes, it may be
– CarLaTeX
37 mins ago
In case of multiple multirow cells nesting in a nesting would be required.
– Viesturs
38 mins ago
In case of multiple multirow cells nesting in a nesting would be required.
– Viesturs
38 mins ago
@Viesturs Yes, it may be
– CarLaTeX
37 mins ago
@Viesturs Yes, it may be
– CarLaTeX
37 mins ago
add a comment |
Here is a possibe solution using a minipage
and a tabularx
:
documentclass{report}
usepackage{tabularx}
usepackage{lipsum}
usepackage{multirow}
renewcommand{tabularxcolumn}[1]{m{#1}}
usepackage{calc}
begin{document}
begin{minipage}{2em}
A
end{minipage}%
begin{tabularx}{0.5linewidth-2em}{lX}
B & lipsum[1][1-2] \
C & lipsum[2][1-3]\
end{tabularx}
end{document}
add a comment |
Here is a possibe solution using a minipage
and a tabularx
:
documentclass{report}
usepackage{tabularx}
usepackage{lipsum}
usepackage{multirow}
renewcommand{tabularxcolumn}[1]{m{#1}}
usepackage{calc}
begin{document}
begin{minipage}{2em}
A
end{minipage}%
begin{tabularx}{0.5linewidth-2em}{lX}
B & lipsum[1][1-2] \
C & lipsum[2][1-3]\
end{tabularx}
end{document}
add a comment |
Here is a possibe solution using a minipage
and a tabularx
:
documentclass{report}
usepackage{tabularx}
usepackage{lipsum}
usepackage{multirow}
renewcommand{tabularxcolumn}[1]{m{#1}}
usepackage{calc}
begin{document}
begin{minipage}{2em}
A
end{minipage}%
begin{tabularx}{0.5linewidth-2em}{lX}
B & lipsum[1][1-2] \
C & lipsum[2][1-3]\
end{tabularx}
end{document}
Here is a possibe solution using a minipage
and a tabularx
:
documentclass{report}
usepackage{tabularx}
usepackage{lipsum}
usepackage{multirow}
renewcommand{tabularxcolumn}[1]{m{#1}}
usepackage{calc}
begin{document}
begin{minipage}{2em}
A
end{minipage}%
begin{tabularx}{0.5linewidth-2em}{lX}
B & lipsum[1][1-2] \
C & lipsum[2][1-3]\
end{tabularx}
end{document}
answered 25 mins ago
leandriisleandriis
11.7k1733
11.7k1733
add a comment |
add a comment |
In this case you can use a 1-row multicolumn as the baseline of the m-column is there. In other cases you will have to use the vmode-option described in the documentation. Imho while multirow works okay with 1-line cells it is imho rather a pain with m- and p-columns and I use it seldom.
documentclass{report}
usepackage{tabularx}
usepackage{lipsum}
usepackage{multirow}
begin{document}
% with X as p-column 5 works:
begin{tabularx}{0.5linewidth}{llX}
multirow{5}{*}{A} & B & lipsum[1][1-2] \
& C & lipsum[2][1-3]\
end{tabularx}
%X as m-column:
renewcommand{tabularxcolumn}[1]{m{#1}}
begin{tabularx}{0.5linewidth}{llX}
multirow{1}{*}{A} & B & lipsum[1][1-2] \
& C & lipsum[2][1-3]\
end{tabularx}
end{document}
To center the A over both cells use a value of 8.5 or 9 works (that's the number of lines below the baseline of the first cell.
documentclass{report}
usepackage{tabularx}
usepackage{lipsum}
usepackage{multirow}
renewcommand{tabularxcolumn}[1]{m{#1}}
begin{document}
begin{tabularx}{0.5linewidth}{llX}
multirow{9}{*}{A} & B & lipsum[1][1-2] \
& C & lipsum[2][1-3]\
end{tabularx}
end{document}
Where is the improvement? Apparently I was not clear in my question, but by nicely I mean "A" centred vertically in the middle of the table. I updated my question.
– Viesturs
1 hour ago
Ah sorry, I added an edit.
– Ulrike Fischer
1 hour ago
Now there are 6 lines above and 5 below "A".7
works for me. This solution requires a tedious counting of lines manually.
– Viesturs
1 hour ago
1
Yes, but the A is aligned to a line. It is up to you to decide what is visual more pleasing. And yes, it is a pain - I already wrote in the answer. I wouldn't use multirow but nested tabulars or even simple boxes for such a layout.
– Ulrike Fischer
1 hour ago
it could be worthwhile to provide your solution with nested tabulars or simple boxes.
– Viesturs
1 hour ago
add a comment |
In this case you can use a 1-row multicolumn as the baseline of the m-column is there. In other cases you will have to use the vmode-option described in the documentation. Imho while multirow works okay with 1-line cells it is imho rather a pain with m- and p-columns and I use it seldom.
documentclass{report}
usepackage{tabularx}
usepackage{lipsum}
usepackage{multirow}
begin{document}
% with X as p-column 5 works:
begin{tabularx}{0.5linewidth}{llX}
multirow{5}{*}{A} & B & lipsum[1][1-2] \
& C & lipsum[2][1-3]\
end{tabularx}
%X as m-column:
renewcommand{tabularxcolumn}[1]{m{#1}}
begin{tabularx}{0.5linewidth}{llX}
multirow{1}{*}{A} & B & lipsum[1][1-2] \
& C & lipsum[2][1-3]\
end{tabularx}
end{document}
To center the A over both cells use a value of 8.5 or 9 works (that's the number of lines below the baseline of the first cell.
documentclass{report}
usepackage{tabularx}
usepackage{lipsum}
usepackage{multirow}
renewcommand{tabularxcolumn}[1]{m{#1}}
begin{document}
begin{tabularx}{0.5linewidth}{llX}
multirow{9}{*}{A} & B & lipsum[1][1-2] \
& C & lipsum[2][1-3]\
end{tabularx}
end{document}
Where is the improvement? Apparently I was not clear in my question, but by nicely I mean "A" centred vertically in the middle of the table. I updated my question.
– Viesturs
1 hour ago
Ah sorry, I added an edit.
– Ulrike Fischer
1 hour ago
Now there are 6 lines above and 5 below "A".7
works for me. This solution requires a tedious counting of lines manually.
– Viesturs
1 hour ago
1
Yes, but the A is aligned to a line. It is up to you to decide what is visual more pleasing. And yes, it is a pain - I already wrote in the answer. I wouldn't use multirow but nested tabulars or even simple boxes for such a layout.
– Ulrike Fischer
1 hour ago
it could be worthwhile to provide your solution with nested tabulars or simple boxes.
– Viesturs
1 hour ago
add a comment |
In this case you can use a 1-row multicolumn as the baseline of the m-column is there. In other cases you will have to use the vmode-option described in the documentation. Imho while multirow works okay with 1-line cells it is imho rather a pain with m- and p-columns and I use it seldom.
documentclass{report}
usepackage{tabularx}
usepackage{lipsum}
usepackage{multirow}
begin{document}
% with X as p-column 5 works:
begin{tabularx}{0.5linewidth}{llX}
multirow{5}{*}{A} & B & lipsum[1][1-2] \
& C & lipsum[2][1-3]\
end{tabularx}
%X as m-column:
renewcommand{tabularxcolumn}[1]{m{#1}}
begin{tabularx}{0.5linewidth}{llX}
multirow{1}{*}{A} & B & lipsum[1][1-2] \
& C & lipsum[2][1-3]\
end{tabularx}
end{document}
To center the A over both cells use a value of 8.5 or 9 works (that's the number of lines below the baseline of the first cell.
documentclass{report}
usepackage{tabularx}
usepackage{lipsum}
usepackage{multirow}
renewcommand{tabularxcolumn}[1]{m{#1}}
begin{document}
begin{tabularx}{0.5linewidth}{llX}
multirow{9}{*}{A} & B & lipsum[1][1-2] \
& C & lipsum[2][1-3]\
end{tabularx}
end{document}
In this case you can use a 1-row multicolumn as the baseline of the m-column is there. In other cases you will have to use the vmode-option described in the documentation. Imho while multirow works okay with 1-line cells it is imho rather a pain with m- and p-columns and I use it seldom.
documentclass{report}
usepackage{tabularx}
usepackage{lipsum}
usepackage{multirow}
begin{document}
% with X as p-column 5 works:
begin{tabularx}{0.5linewidth}{llX}
multirow{5}{*}{A} & B & lipsum[1][1-2] \
& C & lipsum[2][1-3]\
end{tabularx}
%X as m-column:
renewcommand{tabularxcolumn}[1]{m{#1}}
begin{tabularx}{0.5linewidth}{llX}
multirow{1}{*}{A} & B & lipsum[1][1-2] \
& C & lipsum[2][1-3]\
end{tabularx}
end{document}
To center the A over both cells use a value of 8.5 or 9 works (that's the number of lines below the baseline of the first cell.
documentclass{report}
usepackage{tabularx}
usepackage{lipsum}
usepackage{multirow}
renewcommand{tabularxcolumn}[1]{m{#1}}
begin{document}
begin{tabularx}{0.5linewidth}{llX}
multirow{9}{*}{A} & B & lipsum[1][1-2] \
& C & lipsum[2][1-3]\
end{tabularx}
end{document}
edited 1 hour ago
answered 1 hour ago
Ulrike FischerUlrike Fischer
200k9306693
200k9306693
Where is the improvement? Apparently I was not clear in my question, but by nicely I mean "A" centred vertically in the middle of the table. I updated my question.
– Viesturs
1 hour ago
Ah sorry, I added an edit.
– Ulrike Fischer
1 hour ago
Now there are 6 lines above and 5 below "A".7
works for me. This solution requires a tedious counting of lines manually.
– Viesturs
1 hour ago
1
Yes, but the A is aligned to a line. It is up to you to decide what is visual more pleasing. And yes, it is a pain - I already wrote in the answer. I wouldn't use multirow but nested tabulars or even simple boxes for such a layout.
– Ulrike Fischer
1 hour ago
it could be worthwhile to provide your solution with nested tabulars or simple boxes.
– Viesturs
1 hour ago
add a comment |
Where is the improvement? Apparently I was not clear in my question, but by nicely I mean "A" centred vertically in the middle of the table. I updated my question.
– Viesturs
1 hour ago
Ah sorry, I added an edit.
– Ulrike Fischer
1 hour ago
Now there are 6 lines above and 5 below "A".7
works for me. This solution requires a tedious counting of lines manually.
– Viesturs
1 hour ago
1
Yes, but the A is aligned to a line. It is up to you to decide what is visual more pleasing. And yes, it is a pain - I already wrote in the answer. I wouldn't use multirow but nested tabulars or even simple boxes for such a layout.
– Ulrike Fischer
1 hour ago
it could be worthwhile to provide your solution with nested tabulars or simple boxes.
– Viesturs
1 hour ago
Where is the improvement? Apparently I was not clear in my question, but by nicely I mean "A" centred vertically in the middle of the table. I updated my question.
– Viesturs
1 hour ago
Where is the improvement? Apparently I was not clear in my question, but by nicely I mean "A" centred vertically in the middle of the table. I updated my question.
– Viesturs
1 hour ago
Ah sorry, I added an edit.
– Ulrike Fischer
1 hour ago
Ah sorry, I added an edit.
– Ulrike Fischer
1 hour ago
Now there are 6 lines above and 5 below "A".
7
works for me. This solution requires a tedious counting of lines manually.– Viesturs
1 hour ago
Now there are 6 lines above and 5 below "A".
7
works for me. This solution requires a tedious counting of lines manually.– Viesturs
1 hour ago
1
1
Yes, but the A is aligned to a line. It is up to you to decide what is visual more pleasing. And yes, it is a pain - I already wrote in the answer. I wouldn't use multirow but nested tabulars or even simple boxes for such a layout.
– Ulrike Fischer
1 hour ago
Yes, but the A is aligned to a line. It is up to you to decide what is visual more pleasing. And yes, it is a pain - I already wrote in the answer. I wouldn't use multirow but nested tabulars or even simple boxes for such a layout.
– Ulrike Fischer
1 hour ago
it could be worthwhile to provide your solution with nested tabulars or simple boxes.
– Viesturs
1 hour ago
it could be worthwhile to provide your solution with nested tabulars or simple boxes.
– Viesturs
1 hour ago
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%2f486010%2fcentre-cell-vertically-in-tabularx-across-multiple-multiline-rows%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
Maybe you can try with
multirow{8}{*}{A}
.– leandriis
1 hour ago
Since you made
m
the underlying column type, since the cells in column 3 occupy 12 rows in all, and since one half of 12 is 6, you should replacemultirow{2}{*}{A}
withmultirow{6}{*}{A}
.– Mico
1 hour ago
@Mico: Wouldn't one typically use
multirow{12}
in order to vertically center a cell adjacent to a cell that contains 12 lines of text? However, in the OP's case the redefinition of theX
type column usingrenewcommand{tabularxcolumn}[1]{m{#1}}
seems to interfere with that.– leandriis
1 hour ago
@leandriis, then I need to manually count rows. So laborious when dealing with many tables, changing text.
– Viesturs
1 hour ago
@leandriis - Indeed, if the
renewcommand{tabularxcolumn}[1]{m{#1}}
directive weren't there, one would have to use12
, not6
, as the first argument ofmultirow
.– Mico
1 hour ago