How to vertically align the three columns of my table top, top, middleAlign content with the bottom of a...
Non-OR journals which regularly publish OR research
What are the uses and limitations of Persuasion, Insight, and Deception against other PCs?
How can you evade tax by getting employment income just in equity, then using this equity as collateral to take out loan?
Does a code snippet compile? Or does it get compiled?
Want to draw this commutative diagram
Does two puncture wounds mean venomous snake?
In Pokémon Go, why does one of my Pikachu have an option to evolve, but another one doesn't?
Best way to divide CPU along all sql instances on 1 server
Strangeness with gears
What is the maximum number of PC-controlled undead?
Can a spacecraft use an accelerometer to determine its orientation?
Can I legally make a real mobile app based on a fictional app from a TV show?
Blocking people from taking pictures of me with smartphone
Why aren’t emergency services using callsigns?
Ex-contractor published company source code and secrets online
Is refreshing multiple times a test case for web applications?
Unique combinations of a list of tuples
Author changing name
How many different ways are there to checkmate in the early game?
First amendment and employment: Can an employer terminate you for speech?
Alternative Proof of Burnside's Lemma
Ordering a word list
Drawing complex inscribed and circumscribed polygons in TikZ
During the Space Shuttle Columbia Disaster of 2003, Why Did The Flight Director Say, "Lock the doors."?
How to vertically align the three columns of my table top, top, middle
Align content with the bottom of a tableHow to vertically align multiline columnTable heading too low if on the top of the pageVertically align text to the toptabu package - gaps in vertical linesWhat options are there to globally format tables also allowing local overrides?Table spanning two columns creates too many gapsHow to vertically align text in table ?Change placement of multi-column header
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
I would like the formulae in the third column to be vertically aligned to the middle, i.e. the formulae should be vertically at the middle of the two lines of the descriptions.
documentclass{article}
usepackage{amsmath}
usepackage{tabularx,booktabs}
usepackage{caption}
begin{document}
begin{table}[htb]
centering
caption{I would like the formulae here to be vertically at the middle of the two lines of text}
begin{tabularx}{linewidth}{lX>{$}c<{$}}
toprule
Name & Description & multicolumn{1}{c}{Formula}\
midrule
Ducks & Something which goes on two lines, something which goes on two lines &
A=dfrac{B}{C}\
Lions & Something which goes on two lines, something which goes on two lines &
D=dfrac{E}{F}\
bottomrule
end{tabularx}
end{table}
begin{table}[htb]
centering
caption{Here the formulae are correctly aligned with the description, but I would like the name at the top like in the previous table}
begin{tabular}{lm{24em}>{$}c<{$}}
toprule
Name & Description & multicolumn{1}{c}{Formula}\
midrule
Ducks & Something which goes on two lines, something which goes on two lines &
A=dfrac{B}{C}\
Lions & Something which goes on two lines, something which goes on two lines &
D=dfrac{E}{F}\
bottomrule
end{tabular}
end{table}
end{document}
tables vertical-alignment columns
add a comment |
I would like the formulae in the third column to be vertically aligned to the middle, i.e. the formulae should be vertically at the middle of the two lines of the descriptions.
documentclass{article}
usepackage{amsmath}
usepackage{tabularx,booktabs}
usepackage{caption}
begin{document}
begin{table}[htb]
centering
caption{I would like the formulae here to be vertically at the middle of the two lines of text}
begin{tabularx}{linewidth}{lX>{$}c<{$}}
toprule
Name & Description & multicolumn{1}{c}{Formula}\
midrule
Ducks & Something which goes on two lines, something which goes on two lines &
A=dfrac{B}{C}\
Lions & Something which goes on two lines, something which goes on two lines &
D=dfrac{E}{F}\
bottomrule
end{tabularx}
end{table}
begin{table}[htb]
centering
caption{Here the formulae are correctly aligned with the description, but I would like the name at the top like in the previous table}
begin{tabular}{lm{24em}>{$}c<{$}}
toprule
Name & Description & multicolumn{1}{c}{Formula}\
midrule
Ducks & Something which goes on two lines, something which goes on two lines &
A=dfrac{B}{C}\
Lions & Something which goes on two lines, something which goes on two lines &
D=dfrac{E}{F}\
bottomrule
end{tabular}
end{table}
end{document}
tables vertical-alignment columns
What do you mean by ‘vertically aligned’? For me, they are.
– Bernard
9 hours ago
@Bernard I would like the formulae to be vertically at the middle of the two lines of text
– CarLaTeX
9 hours ago
Do you want the first column top-aligned?
– Bernard
9 hours ago
@Bernard Yes, exactly!
– CarLaTeX
9 hours ago
@Bernard I've edited my question, please see if it's clearer now
– CarLaTeX
9 hours ago
add a comment |
I would like the formulae in the third column to be vertically aligned to the middle, i.e. the formulae should be vertically at the middle of the two lines of the descriptions.
documentclass{article}
usepackage{amsmath}
usepackage{tabularx,booktabs}
usepackage{caption}
begin{document}
begin{table}[htb]
centering
caption{I would like the formulae here to be vertically at the middle of the two lines of text}
begin{tabularx}{linewidth}{lX>{$}c<{$}}
toprule
Name & Description & multicolumn{1}{c}{Formula}\
midrule
Ducks & Something which goes on two lines, something which goes on two lines &
A=dfrac{B}{C}\
Lions & Something which goes on two lines, something which goes on two lines &
D=dfrac{E}{F}\
bottomrule
end{tabularx}
end{table}
begin{table}[htb]
centering
caption{Here the formulae are correctly aligned with the description, but I would like the name at the top like in the previous table}
begin{tabular}{lm{24em}>{$}c<{$}}
toprule
Name & Description & multicolumn{1}{c}{Formula}\
midrule
Ducks & Something which goes on two lines, something which goes on two lines &
A=dfrac{B}{C}\
Lions & Something which goes on two lines, something which goes on two lines &
D=dfrac{E}{F}\
bottomrule
end{tabular}
end{table}
end{document}
tables vertical-alignment columns
I would like the formulae in the third column to be vertically aligned to the middle, i.e. the formulae should be vertically at the middle of the two lines of the descriptions.
documentclass{article}
usepackage{amsmath}
usepackage{tabularx,booktabs}
usepackage{caption}
begin{document}
begin{table}[htb]
centering
caption{I would like the formulae here to be vertically at the middle of the two lines of text}
begin{tabularx}{linewidth}{lX>{$}c<{$}}
toprule
Name & Description & multicolumn{1}{c}{Formula}\
midrule
Ducks & Something which goes on two lines, something which goes on two lines &
A=dfrac{B}{C}\
Lions & Something which goes on two lines, something which goes on two lines &
D=dfrac{E}{F}\
bottomrule
end{tabularx}
end{table}
begin{table}[htb]
centering
caption{Here the formulae are correctly aligned with the description, but I would like the name at the top like in the previous table}
begin{tabular}{lm{24em}>{$}c<{$}}
toprule
Name & Description & multicolumn{1}{c}{Formula}\
midrule
Ducks & Something which goes on two lines, something which goes on two lines &
A=dfrac{B}{C}\
Lions & Something which goes on two lines, something which goes on two lines &
D=dfrac{E}{F}\
bottomrule
end{tabular}
end{table}
end{document}
tables vertical-alignment columns
tables vertical-alignment columns
edited 9 hours ago
CarLaTeX
asked 10 hours ago
CarLaTeXCarLaTeX
37.4k5 gold badges60 silver badges164 bronze badges
37.4k5 gold badges60 silver badges164 bronze badges
What do you mean by ‘vertically aligned’? For me, they are.
– Bernard
9 hours ago
@Bernard I would like the formulae to be vertically at the middle of the two lines of text
– CarLaTeX
9 hours ago
Do you want the first column top-aligned?
– Bernard
9 hours ago
@Bernard Yes, exactly!
– CarLaTeX
9 hours ago
@Bernard I've edited my question, please see if it's clearer now
– CarLaTeX
9 hours ago
add a comment |
What do you mean by ‘vertically aligned’? For me, they are.
– Bernard
9 hours ago
@Bernard I would like the formulae to be vertically at the middle of the two lines of text
– CarLaTeX
9 hours ago
Do you want the first column top-aligned?
– Bernard
9 hours ago
@Bernard Yes, exactly!
– CarLaTeX
9 hours ago
@Bernard I've edited my question, please see if it's clearer now
– CarLaTeX
9 hours ago
What do you mean by ‘vertically aligned’? For me, they are.
– Bernard
9 hours ago
What do you mean by ‘vertically aligned’? For me, they are.
– Bernard
9 hours ago
@Bernard I would like the formulae to be vertically at the middle of the two lines of text
– CarLaTeX
9 hours ago
@Bernard I would like the formulae to be vertically at the middle of the two lines of text
– CarLaTeX
9 hours ago
Do you want the first column top-aligned?
– Bernard
9 hours ago
Do you want the first column top-aligned?
– Bernard
9 hours ago
@Bernard Yes, exactly!
– CarLaTeX
9 hours ago
@Bernard Yes, exactly!
– CarLaTeX
9 hours ago
@Bernard I've edited my question, please see if it's clearer now
– CarLaTeX
9 hours ago
@Bernard I've edited my question, please see if it's clearer now
– CarLaTeX
9 hours ago
add a comment |
3 Answers
3
active
oldest
votes
Like this:
Edit:
Position of column contents determined by in row baseline, which is (unfortunately) cannot be changed from column to column.
So far I don't see any other possibility as use boxes in the last or the first column, which enables align their baseline. Good candidate for your particular case is adjustbox
:
documentclass{article}
usepackage{amsmath}
usepackage{tabularx,booktabs}
usepackage{caption}
usepackage{adjustbox}
begin{document}
begin{table}[htb]
centering
caption{I would like the formulae here to be vertically at the middle of the two lines of text}
begin{tabularx}{linewidth}{lXc}
toprule
Name & Description & Formula \
midrule
Ducks & Something which goes on two lines, something which goes on two lines &
adjustbox{valign=t}{$A=dfrac{B}{C}$}\
Lions & Something which goes on two lines, something which goes on two lines &
adjustbox{valign=t}{$D=dfrac{E}{F}$}\
bottomrule
end{tabularx}
end{table}
end{document}
For more convenient writing of table you can define new column type:
newcolumntype{E}{>{begin{adjustbox}{valign=t}$}c<{$end{adjustbox}}}
and than wrote table (body) as:
begin{tabularx}{linewidth}{lXE}
toprule
Name & Description & Formula \
midrule
Ducks & Something which goes on two lines, something which goes on two lines &
A=dfrac{B}{C}\
Lions & Something which goes on two lines, something which goes on two lines &
D=dfrac{E}{F}\
bottomrule
end{tabularx}
If the text in cells of the middle column has arbitrary lines or if the equation is simple with only one line, then result is worse. In such a cases possible solution is use of multirow
cells in the first column and manually adjust number of columns which those cells spans and in the second column set baseline in vertical middle:
documentclass{article}
usepackage{amsmath}
usepackage{booktabs, multirow, tabularx}
usepackage{caption}
usepackage{adjustbox}
usepackage{lipsum}
begin{document}
begin{table}[htb]
centering
renewcommandtabularxcolumn[1]{m{#1}} % <---
caption{I would like the formulae here to be vertically at the middle of the two lines of text}
begin{tabularx}{linewidth}{lX>{$}c<{$}}
toprule
Name & Description & Formula \
midrule
multirow{-6}{*}{Ducks} % <--- manually adjusted
& lipsum[66] & A=dfrac{B}{C}\
bottomrule
end{tabularx}
end{table}
end{document}
or use solution proposed in @Bernard's answer.
Quite ingenious! (+1)
– Bernard
9 hours ago
Unfortunately, it only appears to work because 1) there are only two lines in the texts of the second column and 2) the formulas have this particular height. Try with eitherlipsum[1]
in the second column or with$A=B$
for either of the formulas. (Yes, the question is a tough one, and I did upvote it.)
– frougon
8 hours ago
My actual table is like the mock one, so your solution works. Now I have to decide which one to use (both already upvoted).
– CarLaTeX
6 hours ago
@CarLaTeX, thank you for editing my answer.Since in the same time i wrote some more explanation and add new example, I will very glad if you correct my answer again. Well, which answer you will choose, is up to you :-).
– Zarko
6 hours ago
@Zarko I edited it only because there was "shoved" instead of "showed" :):):) I'm not a native English speaker, so I rarely correct
– CarLaTeX
6 hours ago
add a comment |
This is rather hard: the problem is that you want to align the middle box in two ways: on the left along the baseline, on the right along the center. This type of table normally requires either nesting of tables (which is difficult with tabularx) or measuring some of the content to use llap tricks.
We are missing here tabular code based on xcoffins which has more than one handle ...
documentclass{article}
usepackage{amsmath}
usepackage{tabularx,booktabs}
usepackage{caption,xcoffins}
newlengthcolA
begin{document}
begin{table}[htb]
centering
renewcommand{tabularxcolumn}[1]{m{#1}}
settowidthcolA{begin{tabular}{l}Name\Ducks\Lionsend{tabular}}
caption{I would like the formulae here to be vertically at the middle of the two lines of text}
begin{tabularx}{linewidth}{p{dimexprcolA-2tabcolsep}X>{$}c<{$}}
toprule
Name & Description & multicolumn{1}{c}{Formula}\
midrule
&leavevmodellap{makebox[colA][l]{Ducks}}Something which goes on two lines, something which goes on two lines &
A=dfrac{B}{C}\
&leavevmodellap{makebox[colA][l]{Lions}}Something which goes on two lines, something which goes on two lines and on one more line and on one more line and on one more line &
D=dfrac{E}{F}\
bottomrule
end{tabularx}
end{table}
%Only for show some coffin code:
NewCoffinCoffinA
NewCoffinCoffinB
NewCoffinCoffinC
SetHorizontalCoffinCoffinA{Ducks}
SetHorizontalCoffinCoffinC{$D=dfrac{E}{F}$}
SetVerticalCoffinCoffinB{dimexpr textwidth-CoffinWidthCoffinA-CoffinWidthCoffinC-6tabcolsep}{noindent Something which goes on two lines, something which goes on two lines and on one more line and on one more line and on one more line}
JoinCoffinsCoffinA[H,r]CoffinB[T,l](2tabcolsep,0pt)
JoinCoffinsCoffinA[vc,r]CoffinC[vc,l](2tabcolsep,0pt)
noindenthspace*{tabcolsep}TypesetCoffinCoffinA
end{document}
add a comment |
Here a solution based on the redefinition of the X
column type, and two possible hacks for the first column (they may have to be adapted to the real contents):
documentclass{article}
usepackage{amsmath}
usepackage{tabularx, booktabs, makecell}
renewcommand{tabularxcolumn}[1]{m{#1}}
begin{document}
begin{table}[htb]
centering
begin{tabularx}{linewidth}{lX>{$}c<{$}}
toprule
Name & Description & multicolumn{1}{c}{Formula}\
midrule
makecell[l]{Ducks\mbox{}} & Something which goes on two lines, something which goes on two lines &
A=dfrac{B}{C}\
addlinespace
makecell[l]{Lions\mbox{}} & Something which goes on two lines, something which goes on two lines &
D=dfrac{E}{F}\
addlinespace
raisebox{1.4ex}{Lions} & Something which goes on two lines, something which goes on two lines &
D=dfrac{E}{F}\
bottomrule
end{tabularx}
end{table}
end{document}
It not cross my mind to move contents in cell's of the first column +1!
– Zarko
8 hours ago
add a third line to one of the cells ...
– Ulrike Fischer
7 hours ago
@UlrikeFischer: in theX
column?
– Bernard
7 hours ago
yes, naturally there.
– Ulrike Fischer
7 hours 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%2f503692%2fhow-to-vertically-align-the-three-columns-of-my-table-top-top-middle%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
Like this:
Edit:
Position of column contents determined by in row baseline, which is (unfortunately) cannot be changed from column to column.
So far I don't see any other possibility as use boxes in the last or the first column, which enables align their baseline. Good candidate for your particular case is adjustbox
:
documentclass{article}
usepackage{amsmath}
usepackage{tabularx,booktabs}
usepackage{caption}
usepackage{adjustbox}
begin{document}
begin{table}[htb]
centering
caption{I would like the formulae here to be vertically at the middle of the two lines of text}
begin{tabularx}{linewidth}{lXc}
toprule
Name & Description & Formula \
midrule
Ducks & Something which goes on two lines, something which goes on two lines &
adjustbox{valign=t}{$A=dfrac{B}{C}$}\
Lions & Something which goes on two lines, something which goes on two lines &
adjustbox{valign=t}{$D=dfrac{E}{F}$}\
bottomrule
end{tabularx}
end{table}
end{document}
For more convenient writing of table you can define new column type:
newcolumntype{E}{>{begin{adjustbox}{valign=t}$}c<{$end{adjustbox}}}
and than wrote table (body) as:
begin{tabularx}{linewidth}{lXE}
toprule
Name & Description & Formula \
midrule
Ducks & Something which goes on two lines, something which goes on two lines &
A=dfrac{B}{C}\
Lions & Something which goes on two lines, something which goes on two lines &
D=dfrac{E}{F}\
bottomrule
end{tabularx}
If the text in cells of the middle column has arbitrary lines or if the equation is simple with only one line, then result is worse. In such a cases possible solution is use of multirow
cells in the first column and manually adjust number of columns which those cells spans and in the second column set baseline in vertical middle:
documentclass{article}
usepackage{amsmath}
usepackage{booktabs, multirow, tabularx}
usepackage{caption}
usepackage{adjustbox}
usepackage{lipsum}
begin{document}
begin{table}[htb]
centering
renewcommandtabularxcolumn[1]{m{#1}} % <---
caption{I would like the formulae here to be vertically at the middle of the two lines of text}
begin{tabularx}{linewidth}{lX>{$}c<{$}}
toprule
Name & Description & Formula \
midrule
multirow{-6}{*}{Ducks} % <--- manually adjusted
& lipsum[66] & A=dfrac{B}{C}\
bottomrule
end{tabularx}
end{table}
end{document}
or use solution proposed in @Bernard's answer.
Quite ingenious! (+1)
– Bernard
9 hours ago
Unfortunately, it only appears to work because 1) there are only two lines in the texts of the second column and 2) the formulas have this particular height. Try with eitherlipsum[1]
in the second column or with$A=B$
for either of the formulas. (Yes, the question is a tough one, and I did upvote it.)
– frougon
8 hours ago
My actual table is like the mock one, so your solution works. Now I have to decide which one to use (both already upvoted).
– CarLaTeX
6 hours ago
@CarLaTeX, thank you for editing my answer.Since in the same time i wrote some more explanation and add new example, I will very glad if you correct my answer again. Well, which answer you will choose, is up to you :-).
– Zarko
6 hours ago
@Zarko I edited it only because there was "shoved" instead of "showed" :):):) I'm not a native English speaker, so I rarely correct
– CarLaTeX
6 hours ago
add a comment |
Like this:
Edit:
Position of column contents determined by in row baseline, which is (unfortunately) cannot be changed from column to column.
So far I don't see any other possibility as use boxes in the last or the first column, which enables align their baseline. Good candidate for your particular case is adjustbox
:
documentclass{article}
usepackage{amsmath}
usepackage{tabularx,booktabs}
usepackage{caption}
usepackage{adjustbox}
begin{document}
begin{table}[htb]
centering
caption{I would like the formulae here to be vertically at the middle of the two lines of text}
begin{tabularx}{linewidth}{lXc}
toprule
Name & Description & Formula \
midrule
Ducks & Something which goes on two lines, something which goes on two lines &
adjustbox{valign=t}{$A=dfrac{B}{C}$}\
Lions & Something which goes on two lines, something which goes on two lines &
adjustbox{valign=t}{$D=dfrac{E}{F}$}\
bottomrule
end{tabularx}
end{table}
end{document}
For more convenient writing of table you can define new column type:
newcolumntype{E}{>{begin{adjustbox}{valign=t}$}c<{$end{adjustbox}}}
and than wrote table (body) as:
begin{tabularx}{linewidth}{lXE}
toprule
Name & Description & Formula \
midrule
Ducks & Something which goes on two lines, something which goes on two lines &
A=dfrac{B}{C}\
Lions & Something which goes on two lines, something which goes on two lines &
D=dfrac{E}{F}\
bottomrule
end{tabularx}
If the text in cells of the middle column has arbitrary lines or if the equation is simple with only one line, then result is worse. In such a cases possible solution is use of multirow
cells in the first column and manually adjust number of columns which those cells spans and in the second column set baseline in vertical middle:
documentclass{article}
usepackage{amsmath}
usepackage{booktabs, multirow, tabularx}
usepackage{caption}
usepackage{adjustbox}
usepackage{lipsum}
begin{document}
begin{table}[htb]
centering
renewcommandtabularxcolumn[1]{m{#1}} % <---
caption{I would like the formulae here to be vertically at the middle of the two lines of text}
begin{tabularx}{linewidth}{lX>{$}c<{$}}
toprule
Name & Description & Formula \
midrule
multirow{-6}{*}{Ducks} % <--- manually adjusted
& lipsum[66] & A=dfrac{B}{C}\
bottomrule
end{tabularx}
end{table}
end{document}
or use solution proposed in @Bernard's answer.
Quite ingenious! (+1)
– Bernard
9 hours ago
Unfortunately, it only appears to work because 1) there are only two lines in the texts of the second column and 2) the formulas have this particular height. Try with eitherlipsum[1]
in the second column or with$A=B$
for either of the formulas. (Yes, the question is a tough one, and I did upvote it.)
– frougon
8 hours ago
My actual table is like the mock one, so your solution works. Now I have to decide which one to use (both already upvoted).
– CarLaTeX
6 hours ago
@CarLaTeX, thank you for editing my answer.Since in the same time i wrote some more explanation and add new example, I will very glad if you correct my answer again. Well, which answer you will choose, is up to you :-).
– Zarko
6 hours ago
@Zarko I edited it only because there was "shoved" instead of "showed" :):):) I'm not a native English speaker, so I rarely correct
– CarLaTeX
6 hours ago
add a comment |
Like this:
Edit:
Position of column contents determined by in row baseline, which is (unfortunately) cannot be changed from column to column.
So far I don't see any other possibility as use boxes in the last or the first column, which enables align their baseline. Good candidate for your particular case is adjustbox
:
documentclass{article}
usepackage{amsmath}
usepackage{tabularx,booktabs}
usepackage{caption}
usepackage{adjustbox}
begin{document}
begin{table}[htb]
centering
caption{I would like the formulae here to be vertically at the middle of the two lines of text}
begin{tabularx}{linewidth}{lXc}
toprule
Name & Description & Formula \
midrule
Ducks & Something which goes on two lines, something which goes on two lines &
adjustbox{valign=t}{$A=dfrac{B}{C}$}\
Lions & Something which goes on two lines, something which goes on two lines &
adjustbox{valign=t}{$D=dfrac{E}{F}$}\
bottomrule
end{tabularx}
end{table}
end{document}
For more convenient writing of table you can define new column type:
newcolumntype{E}{>{begin{adjustbox}{valign=t}$}c<{$end{adjustbox}}}
and than wrote table (body) as:
begin{tabularx}{linewidth}{lXE}
toprule
Name & Description & Formula \
midrule
Ducks & Something which goes on two lines, something which goes on two lines &
A=dfrac{B}{C}\
Lions & Something which goes on two lines, something which goes on two lines &
D=dfrac{E}{F}\
bottomrule
end{tabularx}
If the text in cells of the middle column has arbitrary lines or if the equation is simple with only one line, then result is worse. In such a cases possible solution is use of multirow
cells in the first column and manually adjust number of columns which those cells spans and in the second column set baseline in vertical middle:
documentclass{article}
usepackage{amsmath}
usepackage{booktabs, multirow, tabularx}
usepackage{caption}
usepackage{adjustbox}
usepackage{lipsum}
begin{document}
begin{table}[htb]
centering
renewcommandtabularxcolumn[1]{m{#1}} % <---
caption{I would like the formulae here to be vertically at the middle of the two lines of text}
begin{tabularx}{linewidth}{lX>{$}c<{$}}
toprule
Name & Description & Formula \
midrule
multirow{-6}{*}{Ducks} % <--- manually adjusted
& lipsum[66] & A=dfrac{B}{C}\
bottomrule
end{tabularx}
end{table}
end{document}
or use solution proposed in @Bernard's answer.
Like this:
Edit:
Position of column contents determined by in row baseline, which is (unfortunately) cannot be changed from column to column.
So far I don't see any other possibility as use boxes in the last or the first column, which enables align their baseline. Good candidate for your particular case is adjustbox
:
documentclass{article}
usepackage{amsmath}
usepackage{tabularx,booktabs}
usepackage{caption}
usepackage{adjustbox}
begin{document}
begin{table}[htb]
centering
caption{I would like the formulae here to be vertically at the middle of the two lines of text}
begin{tabularx}{linewidth}{lXc}
toprule
Name & Description & Formula \
midrule
Ducks & Something which goes on two lines, something which goes on two lines &
adjustbox{valign=t}{$A=dfrac{B}{C}$}\
Lions & Something which goes on two lines, something which goes on two lines &
adjustbox{valign=t}{$D=dfrac{E}{F}$}\
bottomrule
end{tabularx}
end{table}
end{document}
For more convenient writing of table you can define new column type:
newcolumntype{E}{>{begin{adjustbox}{valign=t}$}c<{$end{adjustbox}}}
and than wrote table (body) as:
begin{tabularx}{linewidth}{lXE}
toprule
Name & Description & Formula \
midrule
Ducks & Something which goes on two lines, something which goes on two lines &
A=dfrac{B}{C}\
Lions & Something which goes on two lines, something which goes on two lines &
D=dfrac{E}{F}\
bottomrule
end{tabularx}
If the text in cells of the middle column has arbitrary lines or if the equation is simple with only one line, then result is worse. In such a cases possible solution is use of multirow
cells in the first column and manually adjust number of columns which those cells spans and in the second column set baseline in vertical middle:
documentclass{article}
usepackage{amsmath}
usepackage{booktabs, multirow, tabularx}
usepackage{caption}
usepackage{adjustbox}
usepackage{lipsum}
begin{document}
begin{table}[htb]
centering
renewcommandtabularxcolumn[1]{m{#1}} % <---
caption{I would like the formulae here to be vertically at the middle of the two lines of text}
begin{tabularx}{linewidth}{lX>{$}c<{$}}
toprule
Name & Description & Formula \
midrule
multirow{-6}{*}{Ducks} % <--- manually adjusted
& lipsum[66] & A=dfrac{B}{C}\
bottomrule
end{tabularx}
end{table}
end{document}
or use solution proposed in @Bernard's answer.
edited 6 hours ago
answered 9 hours ago
ZarkoZarko
143k8 gold badges79 silver badges192 bronze badges
143k8 gold badges79 silver badges192 bronze badges
Quite ingenious! (+1)
– Bernard
9 hours ago
Unfortunately, it only appears to work because 1) there are only two lines in the texts of the second column and 2) the formulas have this particular height. Try with eitherlipsum[1]
in the second column or with$A=B$
for either of the formulas. (Yes, the question is a tough one, and I did upvote it.)
– frougon
8 hours ago
My actual table is like the mock one, so your solution works. Now I have to decide which one to use (both already upvoted).
– CarLaTeX
6 hours ago
@CarLaTeX, thank you for editing my answer.Since in the same time i wrote some more explanation and add new example, I will very glad if you correct my answer again. Well, which answer you will choose, is up to you :-).
– Zarko
6 hours ago
@Zarko I edited it only because there was "shoved" instead of "showed" :):):) I'm not a native English speaker, so I rarely correct
– CarLaTeX
6 hours ago
add a comment |
Quite ingenious! (+1)
– Bernard
9 hours ago
Unfortunately, it only appears to work because 1) there are only two lines in the texts of the second column and 2) the formulas have this particular height. Try with eitherlipsum[1]
in the second column or with$A=B$
for either of the formulas. (Yes, the question is a tough one, and I did upvote it.)
– frougon
8 hours ago
My actual table is like the mock one, so your solution works. Now I have to decide which one to use (both already upvoted).
– CarLaTeX
6 hours ago
@CarLaTeX, thank you for editing my answer.Since in the same time i wrote some more explanation and add new example, I will very glad if you correct my answer again. Well, which answer you will choose, is up to you :-).
– Zarko
6 hours ago
@Zarko I edited it only because there was "shoved" instead of "showed" :):):) I'm not a native English speaker, so I rarely correct
– CarLaTeX
6 hours ago
Quite ingenious! (+1)
– Bernard
9 hours ago
Quite ingenious! (+1)
– Bernard
9 hours ago
Unfortunately, it only appears to work because 1) there are only two lines in the texts of the second column and 2) the formulas have this particular height. Try with either
lipsum[1]
in the second column or with $A=B$
for either of the formulas. (Yes, the question is a tough one, and I did upvote it.)– frougon
8 hours ago
Unfortunately, it only appears to work because 1) there are only two lines in the texts of the second column and 2) the formulas have this particular height. Try with either
lipsum[1]
in the second column or with $A=B$
for either of the formulas. (Yes, the question is a tough one, and I did upvote it.)– frougon
8 hours ago
My actual table is like the mock one, so your solution works. Now I have to decide which one to use (both already upvoted).
– CarLaTeX
6 hours ago
My actual table is like the mock one, so your solution works. Now I have to decide which one to use (both already upvoted).
– CarLaTeX
6 hours ago
@CarLaTeX, thank you for editing my answer.Since in the same time i wrote some more explanation and add new example, I will very glad if you correct my answer again. Well, which answer you will choose, is up to you :-).
– Zarko
6 hours ago
@CarLaTeX, thank you for editing my answer.Since in the same time i wrote some more explanation and add new example, I will very glad if you correct my answer again. Well, which answer you will choose, is up to you :-).
– Zarko
6 hours ago
@Zarko I edited it only because there was "shoved" instead of "showed" :):):) I'm not a native English speaker, so I rarely correct
– CarLaTeX
6 hours ago
@Zarko I edited it only because there was "shoved" instead of "showed" :):):) I'm not a native English speaker, so I rarely correct
– CarLaTeX
6 hours ago
add a comment |
This is rather hard: the problem is that you want to align the middle box in two ways: on the left along the baseline, on the right along the center. This type of table normally requires either nesting of tables (which is difficult with tabularx) or measuring some of the content to use llap tricks.
We are missing here tabular code based on xcoffins which has more than one handle ...
documentclass{article}
usepackage{amsmath}
usepackage{tabularx,booktabs}
usepackage{caption,xcoffins}
newlengthcolA
begin{document}
begin{table}[htb]
centering
renewcommand{tabularxcolumn}[1]{m{#1}}
settowidthcolA{begin{tabular}{l}Name\Ducks\Lionsend{tabular}}
caption{I would like the formulae here to be vertically at the middle of the two lines of text}
begin{tabularx}{linewidth}{p{dimexprcolA-2tabcolsep}X>{$}c<{$}}
toprule
Name & Description & multicolumn{1}{c}{Formula}\
midrule
&leavevmodellap{makebox[colA][l]{Ducks}}Something which goes on two lines, something which goes on two lines &
A=dfrac{B}{C}\
&leavevmodellap{makebox[colA][l]{Lions}}Something which goes on two lines, something which goes on two lines and on one more line and on one more line and on one more line &
D=dfrac{E}{F}\
bottomrule
end{tabularx}
end{table}
%Only for show some coffin code:
NewCoffinCoffinA
NewCoffinCoffinB
NewCoffinCoffinC
SetHorizontalCoffinCoffinA{Ducks}
SetHorizontalCoffinCoffinC{$D=dfrac{E}{F}$}
SetVerticalCoffinCoffinB{dimexpr textwidth-CoffinWidthCoffinA-CoffinWidthCoffinC-6tabcolsep}{noindent Something which goes on two lines, something which goes on two lines and on one more line and on one more line and on one more line}
JoinCoffinsCoffinA[H,r]CoffinB[T,l](2tabcolsep,0pt)
JoinCoffinsCoffinA[vc,r]CoffinC[vc,l](2tabcolsep,0pt)
noindenthspace*{tabcolsep}TypesetCoffinCoffinA
end{document}
add a comment |
This is rather hard: the problem is that you want to align the middle box in two ways: on the left along the baseline, on the right along the center. This type of table normally requires either nesting of tables (which is difficult with tabularx) or measuring some of the content to use llap tricks.
We are missing here tabular code based on xcoffins which has more than one handle ...
documentclass{article}
usepackage{amsmath}
usepackage{tabularx,booktabs}
usepackage{caption,xcoffins}
newlengthcolA
begin{document}
begin{table}[htb]
centering
renewcommand{tabularxcolumn}[1]{m{#1}}
settowidthcolA{begin{tabular}{l}Name\Ducks\Lionsend{tabular}}
caption{I would like the formulae here to be vertically at the middle of the two lines of text}
begin{tabularx}{linewidth}{p{dimexprcolA-2tabcolsep}X>{$}c<{$}}
toprule
Name & Description & multicolumn{1}{c}{Formula}\
midrule
&leavevmodellap{makebox[colA][l]{Ducks}}Something which goes on two lines, something which goes on two lines &
A=dfrac{B}{C}\
&leavevmodellap{makebox[colA][l]{Lions}}Something which goes on two lines, something which goes on two lines and on one more line and on one more line and on one more line &
D=dfrac{E}{F}\
bottomrule
end{tabularx}
end{table}
%Only for show some coffin code:
NewCoffinCoffinA
NewCoffinCoffinB
NewCoffinCoffinC
SetHorizontalCoffinCoffinA{Ducks}
SetHorizontalCoffinCoffinC{$D=dfrac{E}{F}$}
SetVerticalCoffinCoffinB{dimexpr textwidth-CoffinWidthCoffinA-CoffinWidthCoffinC-6tabcolsep}{noindent Something which goes on two lines, something which goes on two lines and on one more line and on one more line and on one more line}
JoinCoffinsCoffinA[H,r]CoffinB[T,l](2tabcolsep,0pt)
JoinCoffinsCoffinA[vc,r]CoffinC[vc,l](2tabcolsep,0pt)
noindenthspace*{tabcolsep}TypesetCoffinCoffinA
end{document}
add a comment |
This is rather hard: the problem is that you want to align the middle box in two ways: on the left along the baseline, on the right along the center. This type of table normally requires either nesting of tables (which is difficult with tabularx) or measuring some of the content to use llap tricks.
We are missing here tabular code based on xcoffins which has more than one handle ...
documentclass{article}
usepackage{amsmath}
usepackage{tabularx,booktabs}
usepackage{caption,xcoffins}
newlengthcolA
begin{document}
begin{table}[htb]
centering
renewcommand{tabularxcolumn}[1]{m{#1}}
settowidthcolA{begin{tabular}{l}Name\Ducks\Lionsend{tabular}}
caption{I would like the formulae here to be vertically at the middle of the two lines of text}
begin{tabularx}{linewidth}{p{dimexprcolA-2tabcolsep}X>{$}c<{$}}
toprule
Name & Description & multicolumn{1}{c}{Formula}\
midrule
&leavevmodellap{makebox[colA][l]{Ducks}}Something which goes on two lines, something which goes on two lines &
A=dfrac{B}{C}\
&leavevmodellap{makebox[colA][l]{Lions}}Something which goes on two lines, something which goes on two lines and on one more line and on one more line and on one more line &
D=dfrac{E}{F}\
bottomrule
end{tabularx}
end{table}
%Only for show some coffin code:
NewCoffinCoffinA
NewCoffinCoffinB
NewCoffinCoffinC
SetHorizontalCoffinCoffinA{Ducks}
SetHorizontalCoffinCoffinC{$D=dfrac{E}{F}$}
SetVerticalCoffinCoffinB{dimexpr textwidth-CoffinWidthCoffinA-CoffinWidthCoffinC-6tabcolsep}{noindent Something which goes on two lines, something which goes on two lines and on one more line and on one more line and on one more line}
JoinCoffinsCoffinA[H,r]CoffinB[T,l](2tabcolsep,0pt)
JoinCoffinsCoffinA[vc,r]CoffinC[vc,l](2tabcolsep,0pt)
noindenthspace*{tabcolsep}TypesetCoffinCoffinA
end{document}
This is rather hard: the problem is that you want to align the middle box in two ways: on the left along the baseline, on the right along the center. This type of table normally requires either nesting of tables (which is difficult with tabularx) or measuring some of the content to use llap tricks.
We are missing here tabular code based on xcoffins which has more than one handle ...
documentclass{article}
usepackage{amsmath}
usepackage{tabularx,booktabs}
usepackage{caption,xcoffins}
newlengthcolA
begin{document}
begin{table}[htb]
centering
renewcommand{tabularxcolumn}[1]{m{#1}}
settowidthcolA{begin{tabular}{l}Name\Ducks\Lionsend{tabular}}
caption{I would like the formulae here to be vertically at the middle of the two lines of text}
begin{tabularx}{linewidth}{p{dimexprcolA-2tabcolsep}X>{$}c<{$}}
toprule
Name & Description & multicolumn{1}{c}{Formula}\
midrule
&leavevmodellap{makebox[colA][l]{Ducks}}Something which goes on two lines, something which goes on two lines &
A=dfrac{B}{C}\
&leavevmodellap{makebox[colA][l]{Lions}}Something which goes on two lines, something which goes on two lines and on one more line and on one more line and on one more line &
D=dfrac{E}{F}\
bottomrule
end{tabularx}
end{table}
%Only for show some coffin code:
NewCoffinCoffinA
NewCoffinCoffinB
NewCoffinCoffinC
SetHorizontalCoffinCoffinA{Ducks}
SetHorizontalCoffinCoffinC{$D=dfrac{E}{F}$}
SetVerticalCoffinCoffinB{dimexpr textwidth-CoffinWidthCoffinA-CoffinWidthCoffinC-6tabcolsep}{noindent Something which goes on two lines, something which goes on two lines and on one more line and on one more line and on one more line}
JoinCoffinsCoffinA[H,r]CoffinB[T,l](2tabcolsep,0pt)
JoinCoffinsCoffinA[vc,r]CoffinC[vc,l](2tabcolsep,0pt)
noindenthspace*{tabcolsep}TypesetCoffinCoffinA
end{document}
answered 6 hours ago
Ulrike FischerUlrike Fischer
212k9 gold badges319 silver badges718 bronze badges
212k9 gold badges319 silver badges718 bronze badges
add a comment |
add a comment |
Here a solution based on the redefinition of the X
column type, and two possible hacks for the first column (they may have to be adapted to the real contents):
documentclass{article}
usepackage{amsmath}
usepackage{tabularx, booktabs, makecell}
renewcommand{tabularxcolumn}[1]{m{#1}}
begin{document}
begin{table}[htb]
centering
begin{tabularx}{linewidth}{lX>{$}c<{$}}
toprule
Name & Description & multicolumn{1}{c}{Formula}\
midrule
makecell[l]{Ducks\mbox{}} & Something which goes on two lines, something which goes on two lines &
A=dfrac{B}{C}\
addlinespace
makecell[l]{Lions\mbox{}} & Something which goes on two lines, something which goes on two lines &
D=dfrac{E}{F}\
addlinespace
raisebox{1.4ex}{Lions} & Something which goes on two lines, something which goes on two lines &
D=dfrac{E}{F}\
bottomrule
end{tabularx}
end{table}
end{document}
It not cross my mind to move contents in cell's of the first column +1!
– Zarko
8 hours ago
add a third line to one of the cells ...
– Ulrike Fischer
7 hours ago
@UlrikeFischer: in theX
column?
– Bernard
7 hours ago
yes, naturally there.
– Ulrike Fischer
7 hours ago
add a comment |
Here a solution based on the redefinition of the X
column type, and two possible hacks for the first column (they may have to be adapted to the real contents):
documentclass{article}
usepackage{amsmath}
usepackage{tabularx, booktabs, makecell}
renewcommand{tabularxcolumn}[1]{m{#1}}
begin{document}
begin{table}[htb]
centering
begin{tabularx}{linewidth}{lX>{$}c<{$}}
toprule
Name & Description & multicolumn{1}{c}{Formula}\
midrule
makecell[l]{Ducks\mbox{}} & Something which goes on two lines, something which goes on two lines &
A=dfrac{B}{C}\
addlinespace
makecell[l]{Lions\mbox{}} & Something which goes on two lines, something which goes on two lines &
D=dfrac{E}{F}\
addlinespace
raisebox{1.4ex}{Lions} & Something which goes on two lines, something which goes on two lines &
D=dfrac{E}{F}\
bottomrule
end{tabularx}
end{table}
end{document}
It not cross my mind to move contents in cell's of the first column +1!
– Zarko
8 hours ago
add a third line to one of the cells ...
– Ulrike Fischer
7 hours ago
@UlrikeFischer: in theX
column?
– Bernard
7 hours ago
yes, naturally there.
– Ulrike Fischer
7 hours ago
add a comment |
Here a solution based on the redefinition of the X
column type, and two possible hacks for the first column (they may have to be adapted to the real contents):
documentclass{article}
usepackage{amsmath}
usepackage{tabularx, booktabs, makecell}
renewcommand{tabularxcolumn}[1]{m{#1}}
begin{document}
begin{table}[htb]
centering
begin{tabularx}{linewidth}{lX>{$}c<{$}}
toprule
Name & Description & multicolumn{1}{c}{Formula}\
midrule
makecell[l]{Ducks\mbox{}} & Something which goes on two lines, something which goes on two lines &
A=dfrac{B}{C}\
addlinespace
makecell[l]{Lions\mbox{}} & Something which goes on two lines, something which goes on two lines &
D=dfrac{E}{F}\
addlinespace
raisebox{1.4ex}{Lions} & Something which goes on two lines, something which goes on two lines &
D=dfrac{E}{F}\
bottomrule
end{tabularx}
end{table}
end{document}
Here a solution based on the redefinition of the X
column type, and two possible hacks for the first column (they may have to be adapted to the real contents):
documentclass{article}
usepackage{amsmath}
usepackage{tabularx, booktabs, makecell}
renewcommand{tabularxcolumn}[1]{m{#1}}
begin{document}
begin{table}[htb]
centering
begin{tabularx}{linewidth}{lX>{$}c<{$}}
toprule
Name & Description & multicolumn{1}{c}{Formula}\
midrule
makecell[l]{Ducks\mbox{}} & Something which goes on two lines, something which goes on two lines &
A=dfrac{B}{C}\
addlinespace
makecell[l]{Lions\mbox{}} & Something which goes on two lines, something which goes on two lines &
D=dfrac{E}{F}\
addlinespace
raisebox{1.4ex}{Lions} & Something which goes on two lines, something which goes on two lines &
D=dfrac{E}{F}\
bottomrule
end{tabularx}
end{table}
end{document}
edited 9 hours ago
answered 9 hours ago
BernardBernard
187k7 gold badges84 silver badges221 bronze badges
187k7 gold badges84 silver badges221 bronze badges
It not cross my mind to move contents in cell's of the first column +1!
– Zarko
8 hours ago
add a third line to one of the cells ...
– Ulrike Fischer
7 hours ago
@UlrikeFischer: in theX
column?
– Bernard
7 hours ago
yes, naturally there.
– Ulrike Fischer
7 hours ago
add a comment |
It not cross my mind to move contents in cell's of the first column +1!
– Zarko
8 hours ago
add a third line to one of the cells ...
– Ulrike Fischer
7 hours ago
@UlrikeFischer: in theX
column?
– Bernard
7 hours ago
yes, naturally there.
– Ulrike Fischer
7 hours ago
It not cross my mind to move contents in cell's of the first column +1!
– Zarko
8 hours ago
It not cross my mind to move contents in cell's of the first column +1!
– Zarko
8 hours ago
add a third line to one of the cells ...
– Ulrike Fischer
7 hours ago
add a third line to one of the cells ...
– Ulrike Fischer
7 hours ago
@UlrikeFischer: in the
X
column?– Bernard
7 hours ago
@UlrikeFischer: in the
X
column?– Bernard
7 hours ago
yes, naturally there.
– Ulrike Fischer
7 hours ago
yes, naturally there.
– Ulrike Fischer
7 hours 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%2f503692%2fhow-to-vertically-align-the-three-columns-of-my-table-top-top-middle%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
What do you mean by ‘vertically aligned’? For me, they are.
– Bernard
9 hours ago
@Bernard I would like the formulae to be vertically at the middle of the two lines of text
– CarLaTeX
9 hours ago
Do you want the first column top-aligned?
– Bernard
9 hours ago
@Bernard Yes, exactly!
– CarLaTeX
9 hours ago
@Bernard I've edited my question, please see if it's clearer now
– CarLaTeX
9 hours ago