How to vertically align the three columns of my table top, top, middleAlign 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
Dereferencing a pointer in a 'for' loop initializer creates a segmentation fault
First amendment and employment: Can an employer terminate you for speech?
Are any jet engines used in combat aircraft water cooled?
Was this a rapid SCHEDULED disassembly? How was it done?
Which likelihood function is used in linear regression?
Does this Foo machine halt?
What are the uses and limitations of Persuasion, Insight, and Deception against other PCs?
Generator for parity?
As a 16 year old, how can I keep my money safe from my mother?
Can a spacecraft use an accelerometer to determine its orientation?
Looking for a new job because of relocation - is it okay to tell the real reason?
If a Contingency spell has been cast on a creature, does the Simulacrum spell transfer the contingent spell to its duplicate?
Why are the inside diameters of some pipe larger than the stated size?
Are there any financial disadvantages to living significantly "below your means"?
A stranger from Norway wants to have money delivered to me
In Pokémon Go, why does one of my Pikachu have an option to evolve, but another one doesn't?
What does "sardine box" mean?
PHP santization of textarea input
How should an administrative assistant reply to student addressing them as "Professor" or "Doctor"?
Is it really ~648.69 km/s delta-v to "land" on the surface of the Sun?
How can you evade tax by getting employment income just in equity, then using this equity as collateral to take out loan?
How many different ways are there to checkmate in the early game?
Best gun to modify into a monsterhunter weapon?
Strangeness with gears
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.
documentclassarticle
usepackageamsmath
usepackagetabularx,booktabs
usepackagecaption
begindocument
begintable[htb]
centering
captionI would like the formulae here to be vertically at the middle of the two lines of text
begintabularxlinewidthlX>$c<$
toprule
Name & Description & multicolumn1cFormula\
midrule
Ducks & Something which goes on two lines, something which goes on two lines &
A=dfracBC\
Lions & Something which goes on two lines, something which goes on two lines &
D=dfracEF\
bottomrule
endtabularx
endtable
begintable[htb]
centering
captionHere the formulae are correctly aligned with the description, but I would like the name at the top like in the previous table
begintabularlm24em>$c<$
toprule
Name & Description & multicolumn1cFormula\
midrule
Ducks & Something which goes on two lines, something which goes on two lines &
A=dfracBC\
Lions & Something which goes on two lines, something which goes on two lines &
D=dfracEF\
bottomrule
endtabular
endtable
enddocument
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.
documentclassarticle
usepackageamsmath
usepackagetabularx,booktabs
usepackagecaption
begindocument
begintable[htb]
centering
captionI would like the formulae here to be vertically at the middle of the two lines of text
begintabularxlinewidthlX>$c<$
toprule
Name & Description & multicolumn1cFormula\
midrule
Ducks & Something which goes on two lines, something which goes on two lines &
A=dfracBC\
Lions & Something which goes on two lines, something which goes on two lines &
D=dfracEF\
bottomrule
endtabularx
endtable
begintable[htb]
centering
captionHere the formulae are correctly aligned with the description, but I would like the name at the top like in the previous table
begintabularlm24em>$c<$
toprule
Name & Description & multicolumn1cFormula\
midrule
Ducks & Something which goes on two lines, something which goes on two lines &
A=dfracBC\
Lions & Something which goes on two lines, something which goes on two lines &
D=dfracEF\
bottomrule
endtabular
endtable
enddocument
tables vertical-alignment columns
What do you mean by ‘vertically aligned’? For me, they are.
– Bernard
8 hours ago
@Bernard I would like the formulae to be vertically at the middle of the two lines of text
– CarLaTeX
8 hours ago
Do you want the first column top-aligned?
– Bernard
8 hours ago
@Bernard Yes, exactly!
– CarLaTeX
8 hours ago
@Bernard I've edited my question, please see if it's clearer now
– CarLaTeX
8 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.
documentclassarticle
usepackageamsmath
usepackagetabularx,booktabs
usepackagecaption
begindocument
begintable[htb]
centering
captionI would like the formulae here to be vertically at the middle of the two lines of text
begintabularxlinewidthlX>$c<$
toprule
Name & Description & multicolumn1cFormula\
midrule
Ducks & Something which goes on two lines, something which goes on two lines &
A=dfracBC\
Lions & Something which goes on two lines, something which goes on two lines &
D=dfracEF\
bottomrule
endtabularx
endtable
begintable[htb]
centering
captionHere the formulae are correctly aligned with the description, but I would like the name at the top like in the previous table
begintabularlm24em>$c<$
toprule
Name & Description & multicolumn1cFormula\
midrule
Ducks & Something which goes on two lines, something which goes on two lines &
A=dfracBC\
Lions & Something which goes on two lines, something which goes on two lines &
D=dfracEF\
bottomrule
endtabular
endtable
enddocument
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.
documentclassarticle
usepackageamsmath
usepackagetabularx,booktabs
usepackagecaption
begindocument
begintable[htb]
centering
captionI would like the formulae here to be vertically at the middle of the two lines of text
begintabularxlinewidthlX>$c<$
toprule
Name & Description & multicolumn1cFormula\
midrule
Ducks & Something which goes on two lines, something which goes on two lines &
A=dfracBC\
Lions & Something which goes on two lines, something which goes on two lines &
D=dfracEF\
bottomrule
endtabularx
endtable
begintable[htb]
centering
captionHere the formulae are correctly aligned with the description, but I would like the name at the top like in the previous table
begintabularlm24em>$c<$
toprule
Name & Description & multicolumn1cFormula\
midrule
Ducks & Something which goes on two lines, something which goes on two lines &
A=dfracBC\
Lions & Something which goes on two lines, something which goes on two lines &
D=dfracEF\
bottomrule
endtabular
endtable
enddocument
tables vertical-alignment columns
tables vertical-alignment columns
edited 8 hours ago
CarLaTeX
asked 9 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
8 hours ago
@Bernard I would like the formulae to be vertically at the middle of the two lines of text
– CarLaTeX
8 hours ago
Do you want the first column top-aligned?
– Bernard
8 hours ago
@Bernard Yes, exactly!
– CarLaTeX
8 hours ago
@Bernard I've edited my question, please see if it's clearer now
– CarLaTeX
8 hours ago
add a comment |
What do you mean by ‘vertically aligned’? For me, they are.
– Bernard
8 hours ago
@Bernard I would like the formulae to be vertically at the middle of the two lines of text
– CarLaTeX
8 hours ago
Do you want the first column top-aligned?
– Bernard
8 hours ago
@Bernard Yes, exactly!
– CarLaTeX
8 hours ago
@Bernard I've edited my question, please see if it's clearer now
– CarLaTeX
8 hours ago
What do you mean by ‘vertically aligned’? For me, they are.
– Bernard
8 hours ago
What do you mean by ‘vertically aligned’? For me, they are.
– Bernard
8 hours ago
@Bernard I would like the formulae to be vertically at the middle of the two lines of text
– CarLaTeX
8 hours ago
@Bernard I would like the formulae to be vertically at the middle of the two lines of text
– CarLaTeX
8 hours ago
Do you want the first column top-aligned?
– Bernard
8 hours ago
Do you want the first column top-aligned?
– Bernard
8 hours ago
@Bernard Yes, exactly!
– CarLaTeX
8 hours ago
@Bernard Yes, exactly!
– CarLaTeX
8 hours ago
@Bernard I've edited my question, please see if it's clearer now
– CarLaTeX
8 hours ago
@Bernard I've edited my question, please see if it's clearer now
– CarLaTeX
8 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
:
documentclassarticle
usepackageamsmath
usepackagetabularx,booktabs
usepackagecaption
usepackageadjustbox
begindocument
begintable[htb]
centering
captionI would like the formulae here to be vertically at the middle of the two lines of text
begintabularxlinewidthlXc
toprule
Name & Description & Formula \
midrule
Ducks & Something which goes on two lines, something which goes on two lines &
adjustboxvalign=t$A=dfracBC$\
Lions & Something which goes on two lines, something which goes on two lines &
adjustboxvalign=t$D=dfracEF$\
bottomrule
endtabularx
endtable
enddocument
For more convenient writing of table you can define new column type:
newcolumntypeE>beginadjustboxvalign=t$c<$endadjustbox
and than wrote table (body) as:
begintabularxlinewidthlXE
toprule
Name & Description & Formula \
midrule
Ducks & Something which goes on two lines, something which goes on two lines &
A=dfracBC\
Lions & Something which goes on two lines, something which goes on two lines &
D=dfracEF\
bottomrule
endtabularx
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:
documentclassarticle
usepackageamsmath
usepackagebooktabs, multirow, tabularx
usepackagecaption
usepackageadjustbox
usepackagelipsum
begindocument
begintable[htb]
centering
renewcommandtabularxcolumn[1]m#1 % <---
captionI would like the formulae here to be vertically at the middle of the two lines of text
begintabularxlinewidthlX>$c<$
toprule
Name & Description & Formula \
midrule
multirow-6*Ducks % <--- manually adjusted
& lipsum[66] & A=dfracBC\
bottomrule
endtabularx
endtable
enddocument
or use solution proposed in @Bernard's answer.
Quite ingenious! (+1)
– Bernard
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 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
7 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
5 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
5 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 ...
documentclassarticle
usepackageamsmath
usepackagetabularx,booktabs
usepackagecaption,xcoffins
newlengthcolA
begindocument
begintable[htb]
centering
renewcommandtabularxcolumn[1]m#1
settowidthcolAbegintabularlName\Ducks\Lionsendtabular
captionI would like the formulae here to be vertically at the middle of the two lines of text
begintabularxlinewidthpdimexprcolA-2tabcolsepX>$c<$
toprule
Name & Description & multicolumn1cFormula\
midrule
&leavevmodellapmakebox[colA][l]DucksSomething which goes on two lines, something which goes on two lines &
A=dfracBC\
&leavevmodellapmakebox[colA][l]LionsSomething 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=dfracEF\
bottomrule
endtabularx
endtable
%Only for show some coffin code:
NewCoffinCoffinA
NewCoffinCoffinB
NewCoffinCoffinC
SetHorizontalCoffinCoffinADucks
SetHorizontalCoffinCoffinC$D=dfracEF$
SetVerticalCoffinCoffinBdimexpr textwidth-CoffinWidthCoffinA-CoffinWidthCoffinC-6tabcolsepnoindent 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*tabcolsepTypesetCoffinCoffinA
enddocument
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):
documentclassarticle
usepackageamsmath
usepackagetabularx, booktabs, makecell
renewcommandtabularxcolumn[1]m#1
begindocument
begintable[htb]
centering
begintabularxlinewidthlX>$c<$
toprule
Name & Description & multicolumn1cFormula\
midrule
makecell[l]Ducks\mbox & Something which goes on two lines, something which goes on two lines &
A=dfracBC\
addlinespace
makecell[l]Lions\mbox & Something which goes on two lines, something which goes on two lines &
D=dfracEF\
addlinespace
raisebox1.4exLions & Something which goes on two lines, something which goes on two lines &
D=dfracEF\
bottomrule
endtabularx
endtable
enddocument
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
6 hours ago
@UlrikeFischer: in theX
column?
– Bernard
6 hours ago
yes, naturally there.
– Ulrike Fischer
6 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
:
documentclassarticle
usepackageamsmath
usepackagetabularx,booktabs
usepackagecaption
usepackageadjustbox
begindocument
begintable[htb]
centering
captionI would like the formulae here to be vertically at the middle of the two lines of text
begintabularxlinewidthlXc
toprule
Name & Description & Formula \
midrule
Ducks & Something which goes on two lines, something which goes on two lines &
adjustboxvalign=t$A=dfracBC$\
Lions & Something which goes on two lines, something which goes on two lines &
adjustboxvalign=t$D=dfracEF$\
bottomrule
endtabularx
endtable
enddocument
For more convenient writing of table you can define new column type:
newcolumntypeE>beginadjustboxvalign=t$c<$endadjustbox
and than wrote table (body) as:
begintabularxlinewidthlXE
toprule
Name & Description & Formula \
midrule
Ducks & Something which goes on two lines, something which goes on two lines &
A=dfracBC\
Lions & Something which goes on two lines, something which goes on two lines &
D=dfracEF\
bottomrule
endtabularx
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:
documentclassarticle
usepackageamsmath
usepackagebooktabs, multirow, tabularx
usepackagecaption
usepackageadjustbox
usepackagelipsum
begindocument
begintable[htb]
centering
renewcommandtabularxcolumn[1]m#1 % <---
captionI would like the formulae here to be vertically at the middle of the two lines of text
begintabularxlinewidthlX>$c<$
toprule
Name & Description & Formula \
midrule
multirow-6*Ducks % <--- manually adjusted
& lipsum[66] & A=dfracBC\
bottomrule
endtabularx
endtable
enddocument
or use solution proposed in @Bernard's answer.
Quite ingenious! (+1)
– Bernard
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 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
7 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
5 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
5 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
:
documentclassarticle
usepackageamsmath
usepackagetabularx,booktabs
usepackagecaption
usepackageadjustbox
begindocument
begintable[htb]
centering
captionI would like the formulae here to be vertically at the middle of the two lines of text
begintabularxlinewidthlXc
toprule
Name & Description & Formula \
midrule
Ducks & Something which goes on two lines, something which goes on two lines &
adjustboxvalign=t$A=dfracBC$\
Lions & Something which goes on two lines, something which goes on two lines &
adjustboxvalign=t$D=dfracEF$\
bottomrule
endtabularx
endtable
enddocument
For more convenient writing of table you can define new column type:
newcolumntypeE>beginadjustboxvalign=t$c<$endadjustbox
and than wrote table (body) as:
begintabularxlinewidthlXE
toprule
Name & Description & Formula \
midrule
Ducks & Something which goes on two lines, something which goes on two lines &
A=dfracBC\
Lions & Something which goes on two lines, something which goes on two lines &
D=dfracEF\
bottomrule
endtabularx
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:
documentclassarticle
usepackageamsmath
usepackagebooktabs, multirow, tabularx
usepackagecaption
usepackageadjustbox
usepackagelipsum
begindocument
begintable[htb]
centering
renewcommandtabularxcolumn[1]m#1 % <---
captionI would like the formulae here to be vertically at the middle of the two lines of text
begintabularxlinewidthlX>$c<$
toprule
Name & Description & Formula \
midrule
multirow-6*Ducks % <--- manually adjusted
& lipsum[66] & A=dfracBC\
bottomrule
endtabularx
endtable
enddocument
or use solution proposed in @Bernard's answer.
Quite ingenious! (+1)
– Bernard
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 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
7 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
5 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
5 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
:
documentclassarticle
usepackageamsmath
usepackagetabularx,booktabs
usepackagecaption
usepackageadjustbox
begindocument
begintable[htb]
centering
captionI would like the formulae here to be vertically at the middle of the two lines of text
begintabularxlinewidthlXc
toprule
Name & Description & Formula \
midrule
Ducks & Something which goes on two lines, something which goes on two lines &
adjustboxvalign=t$A=dfracBC$\
Lions & Something which goes on two lines, something which goes on two lines &
adjustboxvalign=t$D=dfracEF$\
bottomrule
endtabularx
endtable
enddocument
For more convenient writing of table you can define new column type:
newcolumntypeE>beginadjustboxvalign=t$c<$endadjustbox
and than wrote table (body) as:
begintabularxlinewidthlXE
toprule
Name & Description & Formula \
midrule
Ducks & Something which goes on two lines, something which goes on two lines &
A=dfracBC\
Lions & Something which goes on two lines, something which goes on two lines &
D=dfracEF\
bottomrule
endtabularx
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:
documentclassarticle
usepackageamsmath
usepackagebooktabs, multirow, tabularx
usepackagecaption
usepackageadjustbox
usepackagelipsum
begindocument
begintable[htb]
centering
renewcommandtabularxcolumn[1]m#1 % <---
captionI would like the formulae here to be vertically at the middle of the two lines of text
begintabularxlinewidthlX>$c<$
toprule
Name & Description & Formula \
midrule
multirow-6*Ducks % <--- manually adjusted
& lipsum[66] & A=dfracBC\
bottomrule
endtabularx
endtable
enddocument
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
:
documentclassarticle
usepackageamsmath
usepackagetabularx,booktabs
usepackagecaption
usepackageadjustbox
begindocument
begintable[htb]
centering
captionI would like the formulae here to be vertically at the middle of the two lines of text
begintabularxlinewidthlXc
toprule
Name & Description & Formula \
midrule
Ducks & Something which goes on two lines, something which goes on two lines &
adjustboxvalign=t$A=dfracBC$\
Lions & Something which goes on two lines, something which goes on two lines &
adjustboxvalign=t$D=dfracEF$\
bottomrule
endtabularx
endtable
enddocument
For more convenient writing of table you can define new column type:
newcolumntypeE>beginadjustboxvalign=t$c<$endadjustbox
and than wrote table (body) as:
begintabularxlinewidthlXE
toprule
Name & Description & Formula \
midrule
Ducks & Something which goes on two lines, something which goes on two lines &
A=dfracBC\
Lions & Something which goes on two lines, something which goes on two lines &
D=dfracEF\
bottomrule
endtabularx
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:
documentclassarticle
usepackageamsmath
usepackagebooktabs, multirow, tabularx
usepackagecaption
usepackageadjustbox
usepackagelipsum
begindocument
begintable[htb]
centering
renewcommandtabularxcolumn[1]m#1 % <---
captionI would like the formulae here to be vertically at the middle of the two lines of text
begintabularxlinewidthlX>$c<$
toprule
Name & Description & Formula \
midrule
multirow-6*Ducks % <--- manually adjusted
& lipsum[66] & A=dfracBC\
bottomrule
endtabularx
endtable
enddocument
or use solution proposed in @Bernard's answer.
edited 6 hours ago
answered 8 hours ago
ZarkoZarko
143k8 gold badges79 silver badges192 bronze badges
143k8 gold badges79 silver badges192 bronze badges
Quite ingenious! (+1)
– Bernard
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 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
7 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
5 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
5 hours ago
add a comment |
Quite ingenious! (+1)
– Bernard
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 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
7 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
5 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
5 hours ago
Quite ingenious! (+1)
– Bernard
8 hours ago
Quite ingenious! (+1)
– Bernard
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
7 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
7 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
5 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
5 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
5 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
5 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 ...
documentclassarticle
usepackageamsmath
usepackagetabularx,booktabs
usepackagecaption,xcoffins
newlengthcolA
begindocument
begintable[htb]
centering
renewcommandtabularxcolumn[1]m#1
settowidthcolAbegintabularlName\Ducks\Lionsendtabular
captionI would like the formulae here to be vertically at the middle of the two lines of text
begintabularxlinewidthpdimexprcolA-2tabcolsepX>$c<$
toprule
Name & Description & multicolumn1cFormula\
midrule
&leavevmodellapmakebox[colA][l]DucksSomething which goes on two lines, something which goes on two lines &
A=dfracBC\
&leavevmodellapmakebox[colA][l]LionsSomething 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=dfracEF\
bottomrule
endtabularx
endtable
%Only for show some coffin code:
NewCoffinCoffinA
NewCoffinCoffinB
NewCoffinCoffinC
SetHorizontalCoffinCoffinADucks
SetHorizontalCoffinCoffinC$D=dfracEF$
SetVerticalCoffinCoffinBdimexpr textwidth-CoffinWidthCoffinA-CoffinWidthCoffinC-6tabcolsepnoindent 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*tabcolsepTypesetCoffinCoffinA
enddocument
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 ...
documentclassarticle
usepackageamsmath
usepackagetabularx,booktabs
usepackagecaption,xcoffins
newlengthcolA
begindocument
begintable[htb]
centering
renewcommandtabularxcolumn[1]m#1
settowidthcolAbegintabularlName\Ducks\Lionsendtabular
captionI would like the formulae here to be vertically at the middle of the two lines of text
begintabularxlinewidthpdimexprcolA-2tabcolsepX>$c<$
toprule
Name & Description & multicolumn1cFormula\
midrule
&leavevmodellapmakebox[colA][l]DucksSomething which goes on two lines, something which goes on two lines &
A=dfracBC\
&leavevmodellapmakebox[colA][l]LionsSomething 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=dfracEF\
bottomrule
endtabularx
endtable
%Only for show some coffin code:
NewCoffinCoffinA
NewCoffinCoffinB
NewCoffinCoffinC
SetHorizontalCoffinCoffinADucks
SetHorizontalCoffinCoffinC$D=dfracEF$
SetVerticalCoffinCoffinBdimexpr textwidth-CoffinWidthCoffinA-CoffinWidthCoffinC-6tabcolsepnoindent 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*tabcolsepTypesetCoffinCoffinA
enddocument
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 ...
documentclassarticle
usepackageamsmath
usepackagetabularx,booktabs
usepackagecaption,xcoffins
newlengthcolA
begindocument
begintable[htb]
centering
renewcommandtabularxcolumn[1]m#1
settowidthcolAbegintabularlName\Ducks\Lionsendtabular
captionI would like the formulae here to be vertically at the middle of the two lines of text
begintabularxlinewidthpdimexprcolA-2tabcolsepX>$c<$
toprule
Name & Description & multicolumn1cFormula\
midrule
&leavevmodellapmakebox[colA][l]DucksSomething which goes on two lines, something which goes on two lines &
A=dfracBC\
&leavevmodellapmakebox[colA][l]LionsSomething 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=dfracEF\
bottomrule
endtabularx
endtable
%Only for show some coffin code:
NewCoffinCoffinA
NewCoffinCoffinB
NewCoffinCoffinC
SetHorizontalCoffinCoffinADucks
SetHorizontalCoffinCoffinC$D=dfracEF$
SetVerticalCoffinCoffinBdimexpr textwidth-CoffinWidthCoffinA-CoffinWidthCoffinC-6tabcolsepnoindent 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*tabcolsepTypesetCoffinCoffinA
enddocument
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 ...
documentclassarticle
usepackageamsmath
usepackagetabularx,booktabs
usepackagecaption,xcoffins
newlengthcolA
begindocument
begintable[htb]
centering
renewcommandtabularxcolumn[1]m#1
settowidthcolAbegintabularlName\Ducks\Lionsendtabular
captionI would like the formulae here to be vertically at the middle of the two lines of text
begintabularxlinewidthpdimexprcolA-2tabcolsepX>$c<$
toprule
Name & Description & multicolumn1cFormula\
midrule
&leavevmodellapmakebox[colA][l]DucksSomething which goes on two lines, something which goes on two lines &
A=dfracBC\
&leavevmodellapmakebox[colA][l]LionsSomething 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=dfracEF\
bottomrule
endtabularx
endtable
%Only for show some coffin code:
NewCoffinCoffinA
NewCoffinCoffinB
NewCoffinCoffinC
SetHorizontalCoffinCoffinADucks
SetHorizontalCoffinCoffinC$D=dfracEF$
SetVerticalCoffinCoffinBdimexpr textwidth-CoffinWidthCoffinA-CoffinWidthCoffinC-6tabcolsepnoindent 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*tabcolsepTypesetCoffinCoffinA
enddocument
answered 5 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):
documentclassarticle
usepackageamsmath
usepackagetabularx, booktabs, makecell
renewcommandtabularxcolumn[1]m#1
begindocument
begintable[htb]
centering
begintabularxlinewidthlX>$c<$
toprule
Name & Description & multicolumn1cFormula\
midrule
makecell[l]Ducks\mbox & Something which goes on two lines, something which goes on two lines &
A=dfracBC\
addlinespace
makecell[l]Lions\mbox & Something which goes on two lines, something which goes on two lines &
D=dfracEF\
addlinespace
raisebox1.4exLions & Something which goes on two lines, something which goes on two lines &
D=dfracEF\
bottomrule
endtabularx
endtable
enddocument
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
6 hours ago
@UlrikeFischer: in theX
column?
– Bernard
6 hours ago
yes, naturally there.
– Ulrike Fischer
6 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):
documentclassarticle
usepackageamsmath
usepackagetabularx, booktabs, makecell
renewcommandtabularxcolumn[1]m#1
begindocument
begintable[htb]
centering
begintabularxlinewidthlX>$c<$
toprule
Name & Description & multicolumn1cFormula\
midrule
makecell[l]Ducks\mbox & Something which goes on two lines, something which goes on two lines &
A=dfracBC\
addlinespace
makecell[l]Lions\mbox & Something which goes on two lines, something which goes on two lines &
D=dfracEF\
addlinespace
raisebox1.4exLions & Something which goes on two lines, something which goes on two lines &
D=dfracEF\
bottomrule
endtabularx
endtable
enddocument
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
6 hours ago
@UlrikeFischer: in theX
column?
– Bernard
6 hours ago
yes, naturally there.
– Ulrike Fischer
6 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):
documentclassarticle
usepackageamsmath
usepackagetabularx, booktabs, makecell
renewcommandtabularxcolumn[1]m#1
begindocument
begintable[htb]
centering
begintabularxlinewidthlX>$c<$
toprule
Name & Description & multicolumn1cFormula\
midrule
makecell[l]Ducks\mbox & Something which goes on two lines, something which goes on two lines &
A=dfracBC\
addlinespace
makecell[l]Lions\mbox & Something which goes on two lines, something which goes on two lines &
D=dfracEF\
addlinespace
raisebox1.4exLions & Something which goes on two lines, something which goes on two lines &
D=dfracEF\
bottomrule
endtabularx
endtable
enddocument
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):
documentclassarticle
usepackageamsmath
usepackagetabularx, booktabs, makecell
renewcommandtabularxcolumn[1]m#1
begindocument
begintable[htb]
centering
begintabularxlinewidthlX>$c<$
toprule
Name & Description & multicolumn1cFormula\
midrule
makecell[l]Ducks\mbox & Something which goes on two lines, something which goes on two lines &
A=dfracBC\
addlinespace
makecell[l]Lions\mbox & Something which goes on two lines, something which goes on two lines &
D=dfracEF\
addlinespace
raisebox1.4exLions & Something which goes on two lines, something which goes on two lines &
D=dfracEF\
bottomrule
endtabularx
endtable
enddocument
edited 8 hours ago
answered 8 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
6 hours ago
@UlrikeFischer: in theX
column?
– Bernard
6 hours ago
yes, naturally there.
– Ulrike Fischer
6 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
6 hours ago
@UlrikeFischer: in theX
column?
– Bernard
6 hours ago
yes, naturally there.
– Ulrike Fischer
6 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
6 hours ago
add a third line to one of the cells ...
– Ulrike Fischer
6 hours ago
@UlrikeFischer: in the
X
column?– Bernard
6 hours ago
@UlrikeFischer: in the
X
column?– Bernard
6 hours ago
yes, naturally there.
– Ulrike Fischer
6 hours ago
yes, naturally there.
– Ulrike Fischer
6 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
8 hours ago
@Bernard I would like the formulae to be vertically at the middle of the two lines of text
– CarLaTeX
8 hours ago
Do you want the first column top-aligned?
– Bernard
8 hours ago
@Bernard Yes, exactly!
– CarLaTeX
8 hours ago
@Bernard I've edited my question, please see if it's clearer now
– CarLaTeX
8 hours ago