How to vertically-center the text of the cells?
I have a simple table as follows:
begin{table*}
centering
begin{tabular}{|l|c|c|c|c|p{2in}|}
...
...
end{tabular}
caption{The factors the camera solver depends on to evaluate the rules.}
label{table:factors}
end{table*}
How is it possible to vertically-center the text of the cells?
tables vertical-alignment
|
show 1 more comment
I have a simple table as follows:
begin{table*}
centering
begin{tabular}{|l|c|c|c|c|p{2in}|}
...
...
end{tabular}
caption{The factors the camera solver depends on to evaluate the rules.}
label{table:factors}
end{table*}
How is it possible to vertically-center the text of the cells?
tables vertical-alignment
2
This earlier question might be of help to you.
– morbusg
Dec 16 '10 at 12:34
3
Looking closer at your example, I realize you obviously have the array package loaded.p{...}
aligns the content toward the top,m{...}
aligns the content toward the center, whileb{...}
aligns it toward the bottom.
– Jimi Oke
Dec 17 '10 at 23:19
1
@Jimi: the example works even without array. Thep
specifier is standard.
– Stefan Kottwitz♦
Dec 18 '10 at 15:35
1
Question, actually. How in the world would a person who knows nothing about code go about this? I'm drowning in information, here.
– user44066
Jan 12 '14 at 23:33
1
@Amy it's not as bad as it looks. You can just copy the code into your document and see if it works. After some time you will get used to Latex code more and more. I would start with the small things first by making tables in an -- for you -- acceptable format, without worrying too much about perfection, which can be done later.
– TomM
Jan 13 '14 at 0:16
|
show 1 more comment
I have a simple table as follows:
begin{table*}
centering
begin{tabular}{|l|c|c|c|c|p{2in}|}
...
...
end{tabular}
caption{The factors the camera solver depends on to evaluate the rules.}
label{table:factors}
end{table*}
How is it possible to vertically-center the text of the cells?
tables vertical-alignment
I have a simple table as follows:
begin{table*}
centering
begin{tabular}{|l|c|c|c|c|p{2in}|}
...
...
end{tabular}
caption{The factors the camera solver depends on to evaluate the rules.}
label{table:factors}
end{table*}
How is it possible to vertically-center the text of the cells?
tables vertical-alignment
tables vertical-alignment
edited Jun 1 '11 at 13:32
xport
21.9k30139261
21.9k30139261
asked Dec 16 '10 at 9:46
RafidRafid
2,18772731
2,18772731
2
This earlier question might be of help to you.
– morbusg
Dec 16 '10 at 12:34
3
Looking closer at your example, I realize you obviously have the array package loaded.p{...}
aligns the content toward the top,m{...}
aligns the content toward the center, whileb{...}
aligns it toward the bottom.
– Jimi Oke
Dec 17 '10 at 23:19
1
@Jimi: the example works even without array. Thep
specifier is standard.
– Stefan Kottwitz♦
Dec 18 '10 at 15:35
1
Question, actually. How in the world would a person who knows nothing about code go about this? I'm drowning in information, here.
– user44066
Jan 12 '14 at 23:33
1
@Amy it's not as bad as it looks. You can just copy the code into your document and see if it works. After some time you will get used to Latex code more and more. I would start with the small things first by making tables in an -- for you -- acceptable format, without worrying too much about perfection, which can be done later.
– TomM
Jan 13 '14 at 0:16
|
show 1 more comment
2
This earlier question might be of help to you.
– morbusg
Dec 16 '10 at 12:34
3
Looking closer at your example, I realize you obviously have the array package loaded.p{...}
aligns the content toward the top,m{...}
aligns the content toward the center, whileb{...}
aligns it toward the bottom.
– Jimi Oke
Dec 17 '10 at 23:19
1
@Jimi: the example works even without array. Thep
specifier is standard.
– Stefan Kottwitz♦
Dec 18 '10 at 15:35
1
Question, actually. How in the world would a person who knows nothing about code go about this? I'm drowning in information, here.
– user44066
Jan 12 '14 at 23:33
1
@Amy it's not as bad as it looks. You can just copy the code into your document and see if it works. After some time you will get used to Latex code more and more. I would start with the small things first by making tables in an -- for you -- acceptable format, without worrying too much about perfection, which can be done later.
– TomM
Jan 13 '14 at 0:16
2
2
This earlier question might be of help to you.
– morbusg
Dec 16 '10 at 12:34
This earlier question might be of help to you.
– morbusg
Dec 16 '10 at 12:34
3
3
Looking closer at your example, I realize you obviously have the array package loaded.
p{...}
aligns the content toward the top, m{...}
aligns the content toward the center, while b{...}
aligns it toward the bottom.– Jimi Oke
Dec 17 '10 at 23:19
Looking closer at your example, I realize you obviously have the array package loaded.
p{...}
aligns the content toward the top, m{...}
aligns the content toward the center, while b{...}
aligns it toward the bottom.– Jimi Oke
Dec 17 '10 at 23:19
1
1
@Jimi: the example works even without array. The
p
specifier is standard.– Stefan Kottwitz♦
Dec 18 '10 at 15:35
@Jimi: the example works even without array. The
p
specifier is standard.– Stefan Kottwitz♦
Dec 18 '10 at 15:35
1
1
Question, actually. How in the world would a person who knows nothing about code go about this? I'm drowning in information, here.
– user44066
Jan 12 '14 at 23:33
Question, actually. How in the world would a person who knows nothing about code go about this? I'm drowning in information, here.
– user44066
Jan 12 '14 at 23:33
1
1
@Amy it's not as bad as it looks. You can just copy the code into your document and see if it works. After some time you will get used to Latex code more and more. I would start with the small things first by making tables in an -- for you -- acceptable format, without worrying too much about perfection, which can be done later.
– TomM
Jan 13 '14 at 0:16
@Amy it's not as bad as it looks. You can just copy the code into your document and see if it works. After some time you will get used to Latex code more and more. I would start with the small things first by making tables in an -- for you -- acceptable format, without worrying too much about perfection, which can be done later.
– TomM
Jan 13 '14 at 0:16
|
show 1 more comment
6 Answers
6
active
oldest
votes
documentclass{article}
usepackage[a4paper,vmargin=2cm,hmargin=1cm,showframe]{geometry}
usepackage[demo]{graphicx}
usepackage[table]{xcolor}
usepackage{array}
usepackage{longtable}
parindent=0pt
defcorrection#1{%
abovedisplayshortskip=#1baselineskiprelaxbelowdisplayshortskip=#1baselineskiprelax%
abovedisplayskip=#1baselineskiprelaxbelowdisplayskip=#1baselineskiprelax}
arrayrulewidth=1ptrelax
tabcolsep=5ptrelax
arrayrulecolor{red}
fboxsep=tabcolseprelax
fboxrule=arrayrulewidthrelax
newcolumntype{A}[2]{%
>{minipage{dimexpr#1linewidth-2tabcolsep-#2arrayrulewidthrelax}vspacetabcolsep}%
c<{vspacetabcolsependminipage}}
newenvironment{Table}[4]{%
longtable{%
|A{#1}{1.5}% for figure
|>{centering$displaystyle}A{#2}{1}<{$}% for inline equation
|>{correction{-1}strut[}A{#3}{1}<{]strut}% for displayed equation
|>{centering}A{#4}{1.5}% for text
|}hlineignorespaces}{%
endlongtableignorespacesafterend}
newcommand{dummy}{%
It is practically a big lie that LaTeX
makes you focus on the content without
bothering about the layout.}
newcommand{Row}{%
includegraphics[width=linewidth]{newton}&
frac{a+b}{a-b}=0&
int_a^b f(x), textrm{d}x=frac{b-a}{b+a}&
fcolorbox{cyan}{yellow}{parbox{dimexprlinewidth-2fboxsep-2fboxrulerelax}{dummy}}
tabularnewlinehline}
begin{document}
begin{Table}{0.25}{0.25}{0.25}{0.25}
Row
Row
end{Table}
defx{centering$displaystyleint_a^bf(x),textrm{d}x=frac{a-b}{a+b}$}
longtable{|A{0.2}{1.5}*2{|A{0.25}{1}}|A{0.3}{1.5}|}hline
x & x & multicolumn{2}{A{0.55}{1.5}|}{x} tabularnewlinehline
multicolumn{2}{|A{0.45}{1.5}|}{x} & x & xtabularnewlinehline
x & multicolumn{2}{A{0.5}{1}|}{x} & xtabularnewlinehline
multicolumn{4}{|A{1}{2}|}{x}tabularnewlinehline
endlongtable
end{document}
57
Your solution is working absolutely fine, but isn't there a simpler solution? Aligning contents vertically feels time like simpler than the proposed solution.
– Rafid
Dec 16 '10 at 19:42
3
@xport: Your edits have nothing to do with Rafid's question. For his question, the widths of the columns just don't matter. I think it's not good to include stuff that's really unrelated.
– Hendrik Vogt
Dec 28 '10 at 22:25
12
This answer should have some explaining text so it is easier to understand.
– dinosaur
Sep 15 '16 at 23:20
4
Unfortunately, this kind of answer is what may scare people away from LaTeX.
– gerrit
Jul 14 '18 at 20:24
4
This kind of answer shows that LaTeX is just plain bad at tables. It's great at many things, but doing anything with tables is an overcomplicated mess and a huge distraction from what I'm actually trying to do, every time. Gah.
– Josh Swanson
Jul 26 '18 at 22:27
|
show 1 more comment
One easy way to this would be to use the array
package, specifying your column width with m{...}
. For example:
begin{tabular}{ m{4cm} m{1cm} }
... & ... \end{tabular}
will give you a four centimeter-long column and a one centimeter-long column. In each cell, the contents will be vertically aligned to the center. Note, however, that the cell contents will be horizontally aligned left. If you also want to align all the cell contents toward the center in a horizontal sense, then you could do something like this:
begin{tabular}{ >{centeringarraybackslash} m{4cm} >{centeringarraybackslash} m{4cm} }
... & ... \end{tabular}
The point of arraybackslash
is to return \
to its original meaning because the centering
command alters this and could possibly give you a noalign
error during compilation.
If you have several columns and do not want your source to look cluttered, you could define new columns before your tabular environment, for example:
newcolumntype{C}{ >{centeringarraybackslash} m{4cm} }
newcolumntype{D}{ >{centeringarraybackslash} m{1cm} }
begin{tabular}{ C D }
... & ... \end{tabular}
There is a lot of useful information on tables in the wiki LaTeX guide, if you want to explore this further.
Are you sure that an image inclusion will be EXATCLY vertically centered using your method above?
– xport
Dec 19 '10 at 22:42
1
@xport: It might be relative to the first and last baselines of the cells, not the exact totalheight.
– Martin Scharrer♦
Jul 10 '11 at 15:53
8
When using this method, people should be cautious NOT to mix other column types such asp
. The height of a row AND vertical-alignment follows that of the cell with the maximum height in that row. It is fine if anm
column cell has the maximum height, but otherwise the vertical-align would not work.
– Achimnol
Dec 27 '12 at 15:22
If you just want equally spaced columns and the whole table's width to be textwidth, can't do that with a general m{something}?
– Zack Fair
Feb 25 '17 at 4:59
1
@jimioke How does one align vertically with defining a space ie can it be written asm{}
– 3kstc
Apr 30 '18 at 4:13
add a comment |
There is a command vcenter
which vertically centers its content in horizontal mode. It can only be used in mathmode.
Here is an example with Plain XeTeX (compile with xetex yourfilename.tex
)
{ offinterlineskip
deftrule{noalign{hrule}}
defhcenter#1{hfil#1hfil}
halign{vrule#&&hcenter{$vcenter{hbox{#}}$}vrulecrtrule
&Lorem ipsum dolor sit amet&XeTeXpicfile "test-pattern.jpg" &
TeX&$E=mc^2$&$displaystyle{a^2-b^2over c^2}$crtrule
&Etiam quam lacus&vrule width 4em height 5ex depth 2ex&eTeX &
$Ene mc^2$&{it &} ceteracrtrule}
}
bye
add a comment |
If you just want to center the text because you are not happy with the default row height, you can put the following command before each tabular environment:
renewcommand{arraystretch}{number}
where number is the factor to multiply the default row height.
add a comment |
I just found this solution for a spacing Problem. When the spaceing is set at a big enough distance, the text is centered, or at least seems like.
Huge Text in Tabular touches table border
Here is my example:
usepackage{makecell}%To keep spacing of text in tables
setcellgapes{4pt}%parameter for the spacing
begin{table}[h]
makegapedcells
centering
resizebox{textwidth}{!}{%resizing the whole table
begin{tabular}{|c|c|c|c|c|c|c|c|c|}
hline
multicolumn{9}{|c|}{Huge Relaisplatine} \
hline
Relay Nr. & Part & Test-Id & specialcell[c]{Signal-Name \for Testcases} & Conn. & Pin & specialcell[c]{Pin-\Func.} & R Value & specialcell[c]{Influenced \ Signal/Voltage } \
hline
& & & & & 1 & N.C. & Open & Open \
cline{6-9}
%hline
0 & RIO & RIO_VOLT_SDAR & RIO_GPP_VCORE & P2 & 3 & COM & 0 $Omega$ & SIGN08116 \
cline{6-9}
%hline
& & & & & 5 & N.O. & 0 $Omega$ & GND \
%cline{6-9}
hline
& & & & & 7 & N.C. & Open & Open \
cline{6-9}
1 & RIO & RIO_VOLT_SDAR & RIO_ETH_+1V2 & P2 & 9 & COM & 0 $Omega$ & SIGN0818 \
cline{6-9}
& & & & & 11 & N.O. & 0 $Omega$ & GND \
hline
& & & & & 13 & N.C. & Open & Open \
cline{6-9}
2 & RIO & RIO_VOLT_SDAR & RIO_CLOCK_+3V3 & P2 & 15 & COM & 0 $Omega$ & SIGN0817 \
cline{6-9}
& & & & & 17 & N.O. & 0 $Omega$ & GND \
hline
& & & & & & N.C. & Open & Open \
cline{6-9}
3 & RIO & RIO_VOLT_SDAR & RIO_HICURR1 & P3 & PCB-Cable & COM & 0 $Omega$ & RIO_+3V3 \
cline{6-9}
& & & & & PCB-Cable & N.O. & 0 $Omega$ & GND \
hline
& & & & & & N.C. & Open & Open \
cline{6-9}
4 & RIO & RIO_VOLT_SDAR & RIO_HICURR2 & P3 & PCB-Cable & COM & 0 $Omega$ & RIO_+3V3 \
cline{6-9}
& & & & & PCB-Cable & N.O. & 0 $Omega$ & GND \
hline
& & & & & 14 & N.C. & Open & Open \
cline{6-9}
5 & RIO & RIO_VOLT_SDAR & BAT_LOW TBD & P2 & 16 & COM & 0 $Omega$ & TBD \
cline{6-9}
& & & & & 18 & N.O. & 0 $Omega$ & \
hline
& & & & & 8 & N.C. & Open & Open \
cline{6-9}
6 & RIO & RIO_VOLT_SDAR & BAT_EMPTY TBD & P2 & 10 & COM & 0 $Omega$ & TBD \
cline{6-9}
& & & & & 12 & N.O. & 0 $Omega$ & \
hline
& & & & & 2 & N.C. & Open & Open \
cline{6-9}
7 & RIO & RIO_VOLT_SDAR & RIO_DSP_+3V3 & P2 & 4 & COM & 0 $Omega$ & SIGN08150 \
cline{6-9}
& & & & & 6 & N.O. & 0 $Omega$ & Open \
hline
end{tabular}
}
caption{Verkabelung der ersten Relaisplatine an X400/PortA}
end{table}
Gives me:
add a comment |
Putting a tabular in the cell of a tabular centers the content of the cell horizontally and vertically.
begin{tabular}{|l|c|c|}
hline
begin{tabular}{l}
text in cell 1
end{tabular} &
begin{tabular}{l}
first line of text in cell 2 \
second line of text in cell 2
end{tabular} &
begin{tabular}{l}
first line of text in cell 3 \
second line of text in cell 3 \
third line of text in cell 3 \
end{tabular}
\
hline
begin{tabular}{l}
first line of text in cell 4 \
second line of text in cell 4
end{tabular} &
begin{tabular}{l}
first line of text in cell 5 \
second line of text in cell 5 \
third line of text in cell 5 \
end{tabular} &
begin{tabular}{l}
first line of text in cell 6 \
second line of text in cell 6 \
end{tabular} \
hline
end{tabular}
gives:
so you can define a macro centered
newcommand{centered}[1]{begin{tabular}{l} #1 end{tabular}}
and use it like this:
begin{tabular}{|l|c|c|}
hline
centered{ text in cell 1 } &
centered{
first line of text in cell 2 \
second line of text in cell 2} &
centered{
first line of text in cell 3 \
second line of text in cell 3 \
third line of text in cell 3 \ } \
hline
centered{
first line of text in cell 4 \
second line of text in cell 4 } &
centered{
first line of text in cell 5 \
second line of text in cell 5 \
third line of text in cell 5 \ } &
centered{
first line of text in cell 6 \
second line of text in cell 6 \ } \
hline
end{tabular}
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%2f7208%2fhow-to-vertically-center-the-text-of-the-cells%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
6 Answers
6
active
oldest
votes
6 Answers
6
active
oldest
votes
active
oldest
votes
active
oldest
votes
documentclass{article}
usepackage[a4paper,vmargin=2cm,hmargin=1cm,showframe]{geometry}
usepackage[demo]{graphicx}
usepackage[table]{xcolor}
usepackage{array}
usepackage{longtable}
parindent=0pt
defcorrection#1{%
abovedisplayshortskip=#1baselineskiprelaxbelowdisplayshortskip=#1baselineskiprelax%
abovedisplayskip=#1baselineskiprelaxbelowdisplayskip=#1baselineskiprelax}
arrayrulewidth=1ptrelax
tabcolsep=5ptrelax
arrayrulecolor{red}
fboxsep=tabcolseprelax
fboxrule=arrayrulewidthrelax
newcolumntype{A}[2]{%
>{minipage{dimexpr#1linewidth-2tabcolsep-#2arrayrulewidthrelax}vspacetabcolsep}%
c<{vspacetabcolsependminipage}}
newenvironment{Table}[4]{%
longtable{%
|A{#1}{1.5}% for figure
|>{centering$displaystyle}A{#2}{1}<{$}% for inline equation
|>{correction{-1}strut[}A{#3}{1}<{]strut}% for displayed equation
|>{centering}A{#4}{1.5}% for text
|}hlineignorespaces}{%
endlongtableignorespacesafterend}
newcommand{dummy}{%
It is practically a big lie that LaTeX
makes you focus on the content without
bothering about the layout.}
newcommand{Row}{%
includegraphics[width=linewidth]{newton}&
frac{a+b}{a-b}=0&
int_a^b f(x), textrm{d}x=frac{b-a}{b+a}&
fcolorbox{cyan}{yellow}{parbox{dimexprlinewidth-2fboxsep-2fboxrulerelax}{dummy}}
tabularnewlinehline}
begin{document}
begin{Table}{0.25}{0.25}{0.25}{0.25}
Row
Row
end{Table}
defx{centering$displaystyleint_a^bf(x),textrm{d}x=frac{a-b}{a+b}$}
longtable{|A{0.2}{1.5}*2{|A{0.25}{1}}|A{0.3}{1.5}|}hline
x & x & multicolumn{2}{A{0.55}{1.5}|}{x} tabularnewlinehline
multicolumn{2}{|A{0.45}{1.5}|}{x} & x & xtabularnewlinehline
x & multicolumn{2}{A{0.5}{1}|}{x} & xtabularnewlinehline
multicolumn{4}{|A{1}{2}|}{x}tabularnewlinehline
endlongtable
end{document}
57
Your solution is working absolutely fine, but isn't there a simpler solution? Aligning contents vertically feels time like simpler than the proposed solution.
– Rafid
Dec 16 '10 at 19:42
3
@xport: Your edits have nothing to do with Rafid's question. For his question, the widths of the columns just don't matter. I think it's not good to include stuff that's really unrelated.
– Hendrik Vogt
Dec 28 '10 at 22:25
12
This answer should have some explaining text so it is easier to understand.
– dinosaur
Sep 15 '16 at 23:20
4
Unfortunately, this kind of answer is what may scare people away from LaTeX.
– gerrit
Jul 14 '18 at 20:24
4
This kind of answer shows that LaTeX is just plain bad at tables. It's great at many things, but doing anything with tables is an overcomplicated mess and a huge distraction from what I'm actually trying to do, every time. Gah.
– Josh Swanson
Jul 26 '18 at 22:27
|
show 1 more comment
documentclass{article}
usepackage[a4paper,vmargin=2cm,hmargin=1cm,showframe]{geometry}
usepackage[demo]{graphicx}
usepackage[table]{xcolor}
usepackage{array}
usepackage{longtable}
parindent=0pt
defcorrection#1{%
abovedisplayshortskip=#1baselineskiprelaxbelowdisplayshortskip=#1baselineskiprelax%
abovedisplayskip=#1baselineskiprelaxbelowdisplayskip=#1baselineskiprelax}
arrayrulewidth=1ptrelax
tabcolsep=5ptrelax
arrayrulecolor{red}
fboxsep=tabcolseprelax
fboxrule=arrayrulewidthrelax
newcolumntype{A}[2]{%
>{minipage{dimexpr#1linewidth-2tabcolsep-#2arrayrulewidthrelax}vspacetabcolsep}%
c<{vspacetabcolsependminipage}}
newenvironment{Table}[4]{%
longtable{%
|A{#1}{1.5}% for figure
|>{centering$displaystyle}A{#2}{1}<{$}% for inline equation
|>{correction{-1}strut[}A{#3}{1}<{]strut}% for displayed equation
|>{centering}A{#4}{1.5}% for text
|}hlineignorespaces}{%
endlongtableignorespacesafterend}
newcommand{dummy}{%
It is practically a big lie that LaTeX
makes you focus on the content without
bothering about the layout.}
newcommand{Row}{%
includegraphics[width=linewidth]{newton}&
frac{a+b}{a-b}=0&
int_a^b f(x), textrm{d}x=frac{b-a}{b+a}&
fcolorbox{cyan}{yellow}{parbox{dimexprlinewidth-2fboxsep-2fboxrulerelax}{dummy}}
tabularnewlinehline}
begin{document}
begin{Table}{0.25}{0.25}{0.25}{0.25}
Row
Row
end{Table}
defx{centering$displaystyleint_a^bf(x),textrm{d}x=frac{a-b}{a+b}$}
longtable{|A{0.2}{1.5}*2{|A{0.25}{1}}|A{0.3}{1.5}|}hline
x & x & multicolumn{2}{A{0.55}{1.5}|}{x} tabularnewlinehline
multicolumn{2}{|A{0.45}{1.5}|}{x} & x & xtabularnewlinehline
x & multicolumn{2}{A{0.5}{1}|}{x} & xtabularnewlinehline
multicolumn{4}{|A{1}{2}|}{x}tabularnewlinehline
endlongtable
end{document}
57
Your solution is working absolutely fine, but isn't there a simpler solution? Aligning contents vertically feels time like simpler than the proposed solution.
– Rafid
Dec 16 '10 at 19:42
3
@xport: Your edits have nothing to do with Rafid's question. For his question, the widths of the columns just don't matter. I think it's not good to include stuff that's really unrelated.
– Hendrik Vogt
Dec 28 '10 at 22:25
12
This answer should have some explaining text so it is easier to understand.
– dinosaur
Sep 15 '16 at 23:20
4
Unfortunately, this kind of answer is what may scare people away from LaTeX.
– gerrit
Jul 14 '18 at 20:24
4
This kind of answer shows that LaTeX is just plain bad at tables. It's great at many things, but doing anything with tables is an overcomplicated mess and a huge distraction from what I'm actually trying to do, every time. Gah.
– Josh Swanson
Jul 26 '18 at 22:27
|
show 1 more comment
documentclass{article}
usepackage[a4paper,vmargin=2cm,hmargin=1cm,showframe]{geometry}
usepackage[demo]{graphicx}
usepackage[table]{xcolor}
usepackage{array}
usepackage{longtable}
parindent=0pt
defcorrection#1{%
abovedisplayshortskip=#1baselineskiprelaxbelowdisplayshortskip=#1baselineskiprelax%
abovedisplayskip=#1baselineskiprelaxbelowdisplayskip=#1baselineskiprelax}
arrayrulewidth=1ptrelax
tabcolsep=5ptrelax
arrayrulecolor{red}
fboxsep=tabcolseprelax
fboxrule=arrayrulewidthrelax
newcolumntype{A}[2]{%
>{minipage{dimexpr#1linewidth-2tabcolsep-#2arrayrulewidthrelax}vspacetabcolsep}%
c<{vspacetabcolsependminipage}}
newenvironment{Table}[4]{%
longtable{%
|A{#1}{1.5}% for figure
|>{centering$displaystyle}A{#2}{1}<{$}% for inline equation
|>{correction{-1}strut[}A{#3}{1}<{]strut}% for displayed equation
|>{centering}A{#4}{1.5}% for text
|}hlineignorespaces}{%
endlongtableignorespacesafterend}
newcommand{dummy}{%
It is practically a big lie that LaTeX
makes you focus on the content without
bothering about the layout.}
newcommand{Row}{%
includegraphics[width=linewidth]{newton}&
frac{a+b}{a-b}=0&
int_a^b f(x), textrm{d}x=frac{b-a}{b+a}&
fcolorbox{cyan}{yellow}{parbox{dimexprlinewidth-2fboxsep-2fboxrulerelax}{dummy}}
tabularnewlinehline}
begin{document}
begin{Table}{0.25}{0.25}{0.25}{0.25}
Row
Row
end{Table}
defx{centering$displaystyleint_a^bf(x),textrm{d}x=frac{a-b}{a+b}$}
longtable{|A{0.2}{1.5}*2{|A{0.25}{1}}|A{0.3}{1.5}|}hline
x & x & multicolumn{2}{A{0.55}{1.5}|}{x} tabularnewlinehline
multicolumn{2}{|A{0.45}{1.5}|}{x} & x & xtabularnewlinehline
x & multicolumn{2}{A{0.5}{1}|}{x} & xtabularnewlinehline
multicolumn{4}{|A{1}{2}|}{x}tabularnewlinehline
endlongtable
end{document}
documentclass{article}
usepackage[a4paper,vmargin=2cm,hmargin=1cm,showframe]{geometry}
usepackage[demo]{graphicx}
usepackage[table]{xcolor}
usepackage{array}
usepackage{longtable}
parindent=0pt
defcorrection#1{%
abovedisplayshortskip=#1baselineskiprelaxbelowdisplayshortskip=#1baselineskiprelax%
abovedisplayskip=#1baselineskiprelaxbelowdisplayskip=#1baselineskiprelax}
arrayrulewidth=1ptrelax
tabcolsep=5ptrelax
arrayrulecolor{red}
fboxsep=tabcolseprelax
fboxrule=arrayrulewidthrelax
newcolumntype{A}[2]{%
>{minipage{dimexpr#1linewidth-2tabcolsep-#2arrayrulewidthrelax}vspacetabcolsep}%
c<{vspacetabcolsependminipage}}
newenvironment{Table}[4]{%
longtable{%
|A{#1}{1.5}% for figure
|>{centering$displaystyle}A{#2}{1}<{$}% for inline equation
|>{correction{-1}strut[}A{#3}{1}<{]strut}% for displayed equation
|>{centering}A{#4}{1.5}% for text
|}hlineignorespaces}{%
endlongtableignorespacesafterend}
newcommand{dummy}{%
It is practically a big lie that LaTeX
makes you focus on the content without
bothering about the layout.}
newcommand{Row}{%
includegraphics[width=linewidth]{newton}&
frac{a+b}{a-b}=0&
int_a^b f(x), textrm{d}x=frac{b-a}{b+a}&
fcolorbox{cyan}{yellow}{parbox{dimexprlinewidth-2fboxsep-2fboxrulerelax}{dummy}}
tabularnewlinehline}
begin{document}
begin{Table}{0.25}{0.25}{0.25}{0.25}
Row
Row
end{Table}
defx{centering$displaystyleint_a^bf(x),textrm{d}x=frac{a-b}{a+b}$}
longtable{|A{0.2}{1.5}*2{|A{0.25}{1}}|A{0.3}{1.5}|}hline
x & x & multicolumn{2}{A{0.55}{1.5}|}{x} tabularnewlinehline
multicolumn{2}{|A{0.45}{1.5}|}{x} & x & xtabularnewlinehline
x & multicolumn{2}{A{0.5}{1}|}{x} & xtabularnewlinehline
multicolumn{4}{|A{1}{2}|}{x}tabularnewlinehline
endlongtable
end{document}
edited Aug 17 '11 at 2:56
community wiki
16 revs
xport
57
Your solution is working absolutely fine, but isn't there a simpler solution? Aligning contents vertically feels time like simpler than the proposed solution.
– Rafid
Dec 16 '10 at 19:42
3
@xport: Your edits have nothing to do with Rafid's question. For his question, the widths of the columns just don't matter. I think it's not good to include stuff that's really unrelated.
– Hendrik Vogt
Dec 28 '10 at 22:25
12
This answer should have some explaining text so it is easier to understand.
– dinosaur
Sep 15 '16 at 23:20
4
Unfortunately, this kind of answer is what may scare people away from LaTeX.
– gerrit
Jul 14 '18 at 20:24
4
This kind of answer shows that LaTeX is just plain bad at tables. It's great at many things, but doing anything with tables is an overcomplicated mess and a huge distraction from what I'm actually trying to do, every time. Gah.
– Josh Swanson
Jul 26 '18 at 22:27
|
show 1 more comment
57
Your solution is working absolutely fine, but isn't there a simpler solution? Aligning contents vertically feels time like simpler than the proposed solution.
– Rafid
Dec 16 '10 at 19:42
3
@xport: Your edits have nothing to do with Rafid's question. For his question, the widths of the columns just don't matter. I think it's not good to include stuff that's really unrelated.
– Hendrik Vogt
Dec 28 '10 at 22:25
12
This answer should have some explaining text so it is easier to understand.
– dinosaur
Sep 15 '16 at 23:20
4
Unfortunately, this kind of answer is what may scare people away from LaTeX.
– gerrit
Jul 14 '18 at 20:24
4
This kind of answer shows that LaTeX is just plain bad at tables. It's great at many things, but doing anything with tables is an overcomplicated mess and a huge distraction from what I'm actually trying to do, every time. Gah.
– Josh Swanson
Jul 26 '18 at 22:27
57
57
Your solution is working absolutely fine, but isn't there a simpler solution? Aligning contents vertically feels time like simpler than the proposed solution.
– Rafid
Dec 16 '10 at 19:42
Your solution is working absolutely fine, but isn't there a simpler solution? Aligning contents vertically feels time like simpler than the proposed solution.
– Rafid
Dec 16 '10 at 19:42
3
3
@xport: Your edits have nothing to do with Rafid's question. For his question, the widths of the columns just don't matter. I think it's not good to include stuff that's really unrelated.
– Hendrik Vogt
Dec 28 '10 at 22:25
@xport: Your edits have nothing to do with Rafid's question. For his question, the widths of the columns just don't matter. I think it's not good to include stuff that's really unrelated.
– Hendrik Vogt
Dec 28 '10 at 22:25
12
12
This answer should have some explaining text so it is easier to understand.
– dinosaur
Sep 15 '16 at 23:20
This answer should have some explaining text so it is easier to understand.
– dinosaur
Sep 15 '16 at 23:20
4
4
Unfortunately, this kind of answer is what may scare people away from LaTeX.
– gerrit
Jul 14 '18 at 20:24
Unfortunately, this kind of answer is what may scare people away from LaTeX.
– gerrit
Jul 14 '18 at 20:24
4
4
This kind of answer shows that LaTeX is just plain bad at tables. It's great at many things, but doing anything with tables is an overcomplicated mess and a huge distraction from what I'm actually trying to do, every time. Gah.
– Josh Swanson
Jul 26 '18 at 22:27
This kind of answer shows that LaTeX is just plain bad at tables. It's great at many things, but doing anything with tables is an overcomplicated mess and a huge distraction from what I'm actually trying to do, every time. Gah.
– Josh Swanson
Jul 26 '18 at 22:27
|
show 1 more comment
One easy way to this would be to use the array
package, specifying your column width with m{...}
. For example:
begin{tabular}{ m{4cm} m{1cm} }
... & ... \end{tabular}
will give you a four centimeter-long column and a one centimeter-long column. In each cell, the contents will be vertically aligned to the center. Note, however, that the cell contents will be horizontally aligned left. If you also want to align all the cell contents toward the center in a horizontal sense, then you could do something like this:
begin{tabular}{ >{centeringarraybackslash} m{4cm} >{centeringarraybackslash} m{4cm} }
... & ... \end{tabular}
The point of arraybackslash
is to return \
to its original meaning because the centering
command alters this and could possibly give you a noalign
error during compilation.
If you have several columns and do not want your source to look cluttered, you could define new columns before your tabular environment, for example:
newcolumntype{C}{ >{centeringarraybackslash} m{4cm} }
newcolumntype{D}{ >{centeringarraybackslash} m{1cm} }
begin{tabular}{ C D }
... & ... \end{tabular}
There is a lot of useful information on tables in the wiki LaTeX guide, if you want to explore this further.
Are you sure that an image inclusion will be EXATCLY vertically centered using your method above?
– xport
Dec 19 '10 at 22:42
1
@xport: It might be relative to the first and last baselines of the cells, not the exact totalheight.
– Martin Scharrer♦
Jul 10 '11 at 15:53
8
When using this method, people should be cautious NOT to mix other column types such asp
. The height of a row AND vertical-alignment follows that of the cell with the maximum height in that row. It is fine if anm
column cell has the maximum height, but otherwise the vertical-align would not work.
– Achimnol
Dec 27 '12 at 15:22
If you just want equally spaced columns and the whole table's width to be textwidth, can't do that with a general m{something}?
– Zack Fair
Feb 25 '17 at 4:59
1
@jimioke How does one align vertically with defining a space ie can it be written asm{}
– 3kstc
Apr 30 '18 at 4:13
add a comment |
One easy way to this would be to use the array
package, specifying your column width with m{...}
. For example:
begin{tabular}{ m{4cm} m{1cm} }
... & ... \end{tabular}
will give you a four centimeter-long column and a one centimeter-long column. In each cell, the contents will be vertically aligned to the center. Note, however, that the cell contents will be horizontally aligned left. If you also want to align all the cell contents toward the center in a horizontal sense, then you could do something like this:
begin{tabular}{ >{centeringarraybackslash} m{4cm} >{centeringarraybackslash} m{4cm} }
... & ... \end{tabular}
The point of arraybackslash
is to return \
to its original meaning because the centering
command alters this and could possibly give you a noalign
error during compilation.
If you have several columns and do not want your source to look cluttered, you could define new columns before your tabular environment, for example:
newcolumntype{C}{ >{centeringarraybackslash} m{4cm} }
newcolumntype{D}{ >{centeringarraybackslash} m{1cm} }
begin{tabular}{ C D }
... & ... \end{tabular}
There is a lot of useful information on tables in the wiki LaTeX guide, if you want to explore this further.
Are you sure that an image inclusion will be EXATCLY vertically centered using your method above?
– xport
Dec 19 '10 at 22:42
1
@xport: It might be relative to the first and last baselines of the cells, not the exact totalheight.
– Martin Scharrer♦
Jul 10 '11 at 15:53
8
When using this method, people should be cautious NOT to mix other column types such asp
. The height of a row AND vertical-alignment follows that of the cell with the maximum height in that row. It is fine if anm
column cell has the maximum height, but otherwise the vertical-align would not work.
– Achimnol
Dec 27 '12 at 15:22
If you just want equally spaced columns and the whole table's width to be textwidth, can't do that with a general m{something}?
– Zack Fair
Feb 25 '17 at 4:59
1
@jimioke How does one align vertically with defining a space ie can it be written asm{}
– 3kstc
Apr 30 '18 at 4:13
add a comment |
One easy way to this would be to use the array
package, specifying your column width with m{...}
. For example:
begin{tabular}{ m{4cm} m{1cm} }
... & ... \end{tabular}
will give you a four centimeter-long column and a one centimeter-long column. In each cell, the contents will be vertically aligned to the center. Note, however, that the cell contents will be horizontally aligned left. If you also want to align all the cell contents toward the center in a horizontal sense, then you could do something like this:
begin{tabular}{ >{centeringarraybackslash} m{4cm} >{centeringarraybackslash} m{4cm} }
... & ... \end{tabular}
The point of arraybackslash
is to return \
to its original meaning because the centering
command alters this and could possibly give you a noalign
error during compilation.
If you have several columns and do not want your source to look cluttered, you could define new columns before your tabular environment, for example:
newcolumntype{C}{ >{centeringarraybackslash} m{4cm} }
newcolumntype{D}{ >{centeringarraybackslash} m{1cm} }
begin{tabular}{ C D }
... & ... \end{tabular}
There is a lot of useful information on tables in the wiki LaTeX guide, if you want to explore this further.
One easy way to this would be to use the array
package, specifying your column width with m{...}
. For example:
begin{tabular}{ m{4cm} m{1cm} }
... & ... \end{tabular}
will give you a four centimeter-long column and a one centimeter-long column. In each cell, the contents will be vertically aligned to the center. Note, however, that the cell contents will be horizontally aligned left. If you also want to align all the cell contents toward the center in a horizontal sense, then you could do something like this:
begin{tabular}{ >{centeringarraybackslash} m{4cm} >{centeringarraybackslash} m{4cm} }
... & ... \end{tabular}
The point of arraybackslash
is to return \
to its original meaning because the centering
command alters this and could possibly give you a noalign
error during compilation.
If you have several columns and do not want your source to look cluttered, you could define new columns before your tabular environment, for example:
newcolumntype{C}{ >{centeringarraybackslash} m{4cm} }
newcolumntype{D}{ >{centeringarraybackslash} m{1cm} }
begin{tabular}{ C D }
... & ... \end{tabular}
There is a lot of useful information on tables in the wiki LaTeX guide, if you want to explore this further.
edited May 16 '18 at 12:37
Phelype Oleinik
23.1k54584
23.1k54584
answered Dec 17 '10 at 22:46
Jimi OkeJimi Oke
1,61311112
1,61311112
Are you sure that an image inclusion will be EXATCLY vertically centered using your method above?
– xport
Dec 19 '10 at 22:42
1
@xport: It might be relative to the first and last baselines of the cells, not the exact totalheight.
– Martin Scharrer♦
Jul 10 '11 at 15:53
8
When using this method, people should be cautious NOT to mix other column types such asp
. The height of a row AND vertical-alignment follows that of the cell with the maximum height in that row. It is fine if anm
column cell has the maximum height, but otherwise the vertical-align would not work.
– Achimnol
Dec 27 '12 at 15:22
If you just want equally spaced columns and the whole table's width to be textwidth, can't do that with a general m{something}?
– Zack Fair
Feb 25 '17 at 4:59
1
@jimioke How does one align vertically with defining a space ie can it be written asm{}
– 3kstc
Apr 30 '18 at 4:13
add a comment |
Are you sure that an image inclusion will be EXATCLY vertically centered using your method above?
– xport
Dec 19 '10 at 22:42
1
@xport: It might be relative to the first and last baselines of the cells, not the exact totalheight.
– Martin Scharrer♦
Jul 10 '11 at 15:53
8
When using this method, people should be cautious NOT to mix other column types such asp
. The height of a row AND vertical-alignment follows that of the cell with the maximum height in that row. It is fine if anm
column cell has the maximum height, but otherwise the vertical-align would not work.
– Achimnol
Dec 27 '12 at 15:22
If you just want equally spaced columns and the whole table's width to be textwidth, can't do that with a general m{something}?
– Zack Fair
Feb 25 '17 at 4:59
1
@jimioke How does one align vertically with defining a space ie can it be written asm{}
– 3kstc
Apr 30 '18 at 4:13
Are you sure that an image inclusion will be EXATCLY vertically centered using your method above?
– xport
Dec 19 '10 at 22:42
Are you sure that an image inclusion will be EXATCLY vertically centered using your method above?
– xport
Dec 19 '10 at 22:42
1
1
@xport: It might be relative to the first and last baselines of the cells, not the exact totalheight.
– Martin Scharrer♦
Jul 10 '11 at 15:53
@xport: It might be relative to the first and last baselines of the cells, not the exact totalheight.
– Martin Scharrer♦
Jul 10 '11 at 15:53
8
8
When using this method, people should be cautious NOT to mix other column types such as
p
. The height of a row AND vertical-alignment follows that of the cell with the maximum height in that row. It is fine if an m
column cell has the maximum height, but otherwise the vertical-align would not work.– Achimnol
Dec 27 '12 at 15:22
When using this method, people should be cautious NOT to mix other column types such as
p
. The height of a row AND vertical-alignment follows that of the cell with the maximum height in that row. It is fine if an m
column cell has the maximum height, but otherwise the vertical-align would not work.– Achimnol
Dec 27 '12 at 15:22
If you just want equally spaced columns and the whole table's width to be textwidth, can't do that with a general m{something}?
– Zack Fair
Feb 25 '17 at 4:59
If you just want equally spaced columns and the whole table's width to be textwidth, can't do that with a general m{something}?
– Zack Fair
Feb 25 '17 at 4:59
1
1
@jimioke How does one align vertically with defining a space ie can it be written as
m{}
– 3kstc
Apr 30 '18 at 4:13
@jimioke How does one align vertically with defining a space ie can it be written as
m{}
– 3kstc
Apr 30 '18 at 4:13
add a comment |
There is a command vcenter
which vertically centers its content in horizontal mode. It can only be used in mathmode.
Here is an example with Plain XeTeX (compile with xetex yourfilename.tex
)
{ offinterlineskip
deftrule{noalign{hrule}}
defhcenter#1{hfil#1hfil}
halign{vrule#&&hcenter{$vcenter{hbox{#}}$}vrulecrtrule
&Lorem ipsum dolor sit amet&XeTeXpicfile "test-pattern.jpg" &
TeX&$E=mc^2$&$displaystyle{a^2-b^2over c^2}$crtrule
&Etiam quam lacus&vrule width 4em height 5ex depth 2ex&eTeX &
$Ene mc^2$&{it &} ceteracrtrule}
}
bye
add a comment |
There is a command vcenter
which vertically centers its content in horizontal mode. It can only be used in mathmode.
Here is an example with Plain XeTeX (compile with xetex yourfilename.tex
)
{ offinterlineskip
deftrule{noalign{hrule}}
defhcenter#1{hfil#1hfil}
halign{vrule#&&hcenter{$vcenter{hbox{#}}$}vrulecrtrule
&Lorem ipsum dolor sit amet&XeTeXpicfile "test-pattern.jpg" &
TeX&$E=mc^2$&$displaystyle{a^2-b^2over c^2}$crtrule
&Etiam quam lacus&vrule width 4em height 5ex depth 2ex&eTeX &
$Ene mc^2$&{it &} ceteracrtrule}
}
bye
add a comment |
There is a command vcenter
which vertically centers its content in horizontal mode. It can only be used in mathmode.
Here is an example with Plain XeTeX (compile with xetex yourfilename.tex
)
{ offinterlineskip
deftrule{noalign{hrule}}
defhcenter#1{hfil#1hfil}
halign{vrule#&&hcenter{$vcenter{hbox{#}}$}vrulecrtrule
&Lorem ipsum dolor sit amet&XeTeXpicfile "test-pattern.jpg" &
TeX&$E=mc^2$&$displaystyle{a^2-b^2over c^2}$crtrule
&Etiam quam lacus&vrule width 4em height 5ex depth 2ex&eTeX &
$Ene mc^2$&{it &} ceteracrtrule}
}
bye
There is a command vcenter
which vertically centers its content in horizontal mode. It can only be used in mathmode.
Here is an example with Plain XeTeX (compile with xetex yourfilename.tex
)
{ offinterlineskip
deftrule{noalign{hrule}}
defhcenter#1{hfil#1hfil}
halign{vrule#&&hcenter{$vcenter{hbox{#}}$}vrulecrtrule
&Lorem ipsum dolor sit amet&XeTeXpicfile "test-pattern.jpg" &
TeX&$E=mc^2$&$displaystyle{a^2-b^2over c^2}$crtrule
&Etiam quam lacus&vrule width 4em height 5ex depth 2ex&eTeX &
$Ene mc^2$&{it &} ceteracrtrule}
}
bye
edited Jun 2 '11 at 8:48
answered Jun 2 '11 at 8:24
morbusgmorbusg
20.1k362137
20.1k362137
add a comment |
add a comment |
If you just want to center the text because you are not happy with the default row height, you can put the following command before each tabular environment:
renewcommand{arraystretch}{number}
where number is the factor to multiply the default row height.
add a comment |
If you just want to center the text because you are not happy with the default row height, you can put the following command before each tabular environment:
renewcommand{arraystretch}{number}
where number is the factor to multiply the default row height.
add a comment |
If you just want to center the text because you are not happy with the default row height, you can put the following command before each tabular environment:
renewcommand{arraystretch}{number}
where number is the factor to multiply the default row height.
If you just want to center the text because you are not happy with the default row height, you can put the following command before each tabular environment:
renewcommand{arraystretch}{number}
where number is the factor to multiply the default row height.
edited Feb 11 '17 at 19:09
Stefan Pinnow
19.8k83276
19.8k83276
answered Dec 12 '16 at 15:33
user120955user120955
311
311
add a comment |
add a comment |
I just found this solution for a spacing Problem. When the spaceing is set at a big enough distance, the text is centered, or at least seems like.
Huge Text in Tabular touches table border
Here is my example:
usepackage{makecell}%To keep spacing of text in tables
setcellgapes{4pt}%parameter for the spacing
begin{table}[h]
makegapedcells
centering
resizebox{textwidth}{!}{%resizing the whole table
begin{tabular}{|c|c|c|c|c|c|c|c|c|}
hline
multicolumn{9}{|c|}{Huge Relaisplatine} \
hline
Relay Nr. & Part & Test-Id & specialcell[c]{Signal-Name \for Testcases} & Conn. & Pin & specialcell[c]{Pin-\Func.} & R Value & specialcell[c]{Influenced \ Signal/Voltage } \
hline
& & & & & 1 & N.C. & Open & Open \
cline{6-9}
%hline
0 & RIO & RIO_VOLT_SDAR & RIO_GPP_VCORE & P2 & 3 & COM & 0 $Omega$ & SIGN08116 \
cline{6-9}
%hline
& & & & & 5 & N.O. & 0 $Omega$ & GND \
%cline{6-9}
hline
& & & & & 7 & N.C. & Open & Open \
cline{6-9}
1 & RIO & RIO_VOLT_SDAR & RIO_ETH_+1V2 & P2 & 9 & COM & 0 $Omega$ & SIGN0818 \
cline{6-9}
& & & & & 11 & N.O. & 0 $Omega$ & GND \
hline
& & & & & 13 & N.C. & Open & Open \
cline{6-9}
2 & RIO & RIO_VOLT_SDAR & RIO_CLOCK_+3V3 & P2 & 15 & COM & 0 $Omega$ & SIGN0817 \
cline{6-9}
& & & & & 17 & N.O. & 0 $Omega$ & GND \
hline
& & & & & & N.C. & Open & Open \
cline{6-9}
3 & RIO & RIO_VOLT_SDAR & RIO_HICURR1 & P3 & PCB-Cable & COM & 0 $Omega$ & RIO_+3V3 \
cline{6-9}
& & & & & PCB-Cable & N.O. & 0 $Omega$ & GND \
hline
& & & & & & N.C. & Open & Open \
cline{6-9}
4 & RIO & RIO_VOLT_SDAR & RIO_HICURR2 & P3 & PCB-Cable & COM & 0 $Omega$ & RIO_+3V3 \
cline{6-9}
& & & & & PCB-Cable & N.O. & 0 $Omega$ & GND \
hline
& & & & & 14 & N.C. & Open & Open \
cline{6-9}
5 & RIO & RIO_VOLT_SDAR & BAT_LOW TBD & P2 & 16 & COM & 0 $Omega$ & TBD \
cline{6-9}
& & & & & 18 & N.O. & 0 $Omega$ & \
hline
& & & & & 8 & N.C. & Open & Open \
cline{6-9}
6 & RIO & RIO_VOLT_SDAR & BAT_EMPTY TBD & P2 & 10 & COM & 0 $Omega$ & TBD \
cline{6-9}
& & & & & 12 & N.O. & 0 $Omega$ & \
hline
& & & & & 2 & N.C. & Open & Open \
cline{6-9}
7 & RIO & RIO_VOLT_SDAR & RIO_DSP_+3V3 & P2 & 4 & COM & 0 $Omega$ & SIGN08150 \
cline{6-9}
& & & & & 6 & N.O. & 0 $Omega$ & Open \
hline
end{tabular}
}
caption{Verkabelung der ersten Relaisplatine an X400/PortA}
end{table}
Gives me:
add a comment |
I just found this solution for a spacing Problem. When the spaceing is set at a big enough distance, the text is centered, or at least seems like.
Huge Text in Tabular touches table border
Here is my example:
usepackage{makecell}%To keep spacing of text in tables
setcellgapes{4pt}%parameter for the spacing
begin{table}[h]
makegapedcells
centering
resizebox{textwidth}{!}{%resizing the whole table
begin{tabular}{|c|c|c|c|c|c|c|c|c|}
hline
multicolumn{9}{|c|}{Huge Relaisplatine} \
hline
Relay Nr. & Part & Test-Id & specialcell[c]{Signal-Name \for Testcases} & Conn. & Pin & specialcell[c]{Pin-\Func.} & R Value & specialcell[c]{Influenced \ Signal/Voltage } \
hline
& & & & & 1 & N.C. & Open & Open \
cline{6-9}
%hline
0 & RIO & RIO_VOLT_SDAR & RIO_GPP_VCORE & P2 & 3 & COM & 0 $Omega$ & SIGN08116 \
cline{6-9}
%hline
& & & & & 5 & N.O. & 0 $Omega$ & GND \
%cline{6-9}
hline
& & & & & 7 & N.C. & Open & Open \
cline{6-9}
1 & RIO & RIO_VOLT_SDAR & RIO_ETH_+1V2 & P2 & 9 & COM & 0 $Omega$ & SIGN0818 \
cline{6-9}
& & & & & 11 & N.O. & 0 $Omega$ & GND \
hline
& & & & & 13 & N.C. & Open & Open \
cline{6-9}
2 & RIO & RIO_VOLT_SDAR & RIO_CLOCK_+3V3 & P2 & 15 & COM & 0 $Omega$ & SIGN0817 \
cline{6-9}
& & & & & 17 & N.O. & 0 $Omega$ & GND \
hline
& & & & & & N.C. & Open & Open \
cline{6-9}
3 & RIO & RIO_VOLT_SDAR & RIO_HICURR1 & P3 & PCB-Cable & COM & 0 $Omega$ & RIO_+3V3 \
cline{6-9}
& & & & & PCB-Cable & N.O. & 0 $Omega$ & GND \
hline
& & & & & & N.C. & Open & Open \
cline{6-9}
4 & RIO & RIO_VOLT_SDAR & RIO_HICURR2 & P3 & PCB-Cable & COM & 0 $Omega$ & RIO_+3V3 \
cline{6-9}
& & & & & PCB-Cable & N.O. & 0 $Omega$ & GND \
hline
& & & & & 14 & N.C. & Open & Open \
cline{6-9}
5 & RIO & RIO_VOLT_SDAR & BAT_LOW TBD & P2 & 16 & COM & 0 $Omega$ & TBD \
cline{6-9}
& & & & & 18 & N.O. & 0 $Omega$ & \
hline
& & & & & 8 & N.C. & Open & Open \
cline{6-9}
6 & RIO & RIO_VOLT_SDAR & BAT_EMPTY TBD & P2 & 10 & COM & 0 $Omega$ & TBD \
cline{6-9}
& & & & & 12 & N.O. & 0 $Omega$ & \
hline
& & & & & 2 & N.C. & Open & Open \
cline{6-9}
7 & RIO & RIO_VOLT_SDAR & RIO_DSP_+3V3 & P2 & 4 & COM & 0 $Omega$ & SIGN08150 \
cline{6-9}
& & & & & 6 & N.O. & 0 $Omega$ & Open \
hline
end{tabular}
}
caption{Verkabelung der ersten Relaisplatine an X400/PortA}
end{table}
Gives me:
add a comment |
I just found this solution for a spacing Problem. When the spaceing is set at a big enough distance, the text is centered, or at least seems like.
Huge Text in Tabular touches table border
Here is my example:
usepackage{makecell}%To keep spacing of text in tables
setcellgapes{4pt}%parameter for the spacing
begin{table}[h]
makegapedcells
centering
resizebox{textwidth}{!}{%resizing the whole table
begin{tabular}{|c|c|c|c|c|c|c|c|c|}
hline
multicolumn{9}{|c|}{Huge Relaisplatine} \
hline
Relay Nr. & Part & Test-Id & specialcell[c]{Signal-Name \for Testcases} & Conn. & Pin & specialcell[c]{Pin-\Func.} & R Value & specialcell[c]{Influenced \ Signal/Voltage } \
hline
& & & & & 1 & N.C. & Open & Open \
cline{6-9}
%hline
0 & RIO & RIO_VOLT_SDAR & RIO_GPP_VCORE & P2 & 3 & COM & 0 $Omega$ & SIGN08116 \
cline{6-9}
%hline
& & & & & 5 & N.O. & 0 $Omega$ & GND \
%cline{6-9}
hline
& & & & & 7 & N.C. & Open & Open \
cline{6-9}
1 & RIO & RIO_VOLT_SDAR & RIO_ETH_+1V2 & P2 & 9 & COM & 0 $Omega$ & SIGN0818 \
cline{6-9}
& & & & & 11 & N.O. & 0 $Omega$ & GND \
hline
& & & & & 13 & N.C. & Open & Open \
cline{6-9}
2 & RIO & RIO_VOLT_SDAR & RIO_CLOCK_+3V3 & P2 & 15 & COM & 0 $Omega$ & SIGN0817 \
cline{6-9}
& & & & & 17 & N.O. & 0 $Omega$ & GND \
hline
& & & & & & N.C. & Open & Open \
cline{6-9}
3 & RIO & RIO_VOLT_SDAR & RIO_HICURR1 & P3 & PCB-Cable & COM & 0 $Omega$ & RIO_+3V3 \
cline{6-9}
& & & & & PCB-Cable & N.O. & 0 $Omega$ & GND \
hline
& & & & & & N.C. & Open & Open \
cline{6-9}
4 & RIO & RIO_VOLT_SDAR & RIO_HICURR2 & P3 & PCB-Cable & COM & 0 $Omega$ & RIO_+3V3 \
cline{6-9}
& & & & & PCB-Cable & N.O. & 0 $Omega$ & GND \
hline
& & & & & 14 & N.C. & Open & Open \
cline{6-9}
5 & RIO & RIO_VOLT_SDAR & BAT_LOW TBD & P2 & 16 & COM & 0 $Omega$ & TBD \
cline{6-9}
& & & & & 18 & N.O. & 0 $Omega$ & \
hline
& & & & & 8 & N.C. & Open & Open \
cline{6-9}
6 & RIO & RIO_VOLT_SDAR & BAT_EMPTY TBD & P2 & 10 & COM & 0 $Omega$ & TBD \
cline{6-9}
& & & & & 12 & N.O. & 0 $Omega$ & \
hline
& & & & & 2 & N.C. & Open & Open \
cline{6-9}
7 & RIO & RIO_VOLT_SDAR & RIO_DSP_+3V3 & P2 & 4 & COM & 0 $Omega$ & SIGN08150 \
cline{6-9}
& & & & & 6 & N.O. & 0 $Omega$ & Open \
hline
end{tabular}
}
caption{Verkabelung der ersten Relaisplatine an X400/PortA}
end{table}
Gives me:
I just found this solution for a spacing Problem. When the spaceing is set at a big enough distance, the text is centered, or at least seems like.
Huge Text in Tabular touches table border
Here is my example:
usepackage{makecell}%To keep spacing of text in tables
setcellgapes{4pt}%parameter for the spacing
begin{table}[h]
makegapedcells
centering
resizebox{textwidth}{!}{%resizing the whole table
begin{tabular}{|c|c|c|c|c|c|c|c|c|}
hline
multicolumn{9}{|c|}{Huge Relaisplatine} \
hline
Relay Nr. & Part & Test-Id & specialcell[c]{Signal-Name \for Testcases} & Conn. & Pin & specialcell[c]{Pin-\Func.} & R Value & specialcell[c]{Influenced \ Signal/Voltage } \
hline
& & & & & 1 & N.C. & Open & Open \
cline{6-9}
%hline
0 & RIO & RIO_VOLT_SDAR & RIO_GPP_VCORE & P2 & 3 & COM & 0 $Omega$ & SIGN08116 \
cline{6-9}
%hline
& & & & & 5 & N.O. & 0 $Omega$ & GND \
%cline{6-9}
hline
& & & & & 7 & N.C. & Open & Open \
cline{6-9}
1 & RIO & RIO_VOLT_SDAR & RIO_ETH_+1V2 & P2 & 9 & COM & 0 $Omega$ & SIGN0818 \
cline{6-9}
& & & & & 11 & N.O. & 0 $Omega$ & GND \
hline
& & & & & 13 & N.C. & Open & Open \
cline{6-9}
2 & RIO & RIO_VOLT_SDAR & RIO_CLOCK_+3V3 & P2 & 15 & COM & 0 $Omega$ & SIGN0817 \
cline{6-9}
& & & & & 17 & N.O. & 0 $Omega$ & GND \
hline
& & & & & & N.C. & Open & Open \
cline{6-9}
3 & RIO & RIO_VOLT_SDAR & RIO_HICURR1 & P3 & PCB-Cable & COM & 0 $Omega$ & RIO_+3V3 \
cline{6-9}
& & & & & PCB-Cable & N.O. & 0 $Omega$ & GND \
hline
& & & & & & N.C. & Open & Open \
cline{6-9}
4 & RIO & RIO_VOLT_SDAR & RIO_HICURR2 & P3 & PCB-Cable & COM & 0 $Omega$ & RIO_+3V3 \
cline{6-9}
& & & & & PCB-Cable & N.O. & 0 $Omega$ & GND \
hline
& & & & & 14 & N.C. & Open & Open \
cline{6-9}
5 & RIO & RIO_VOLT_SDAR & BAT_LOW TBD & P2 & 16 & COM & 0 $Omega$ & TBD \
cline{6-9}
& & & & & 18 & N.O. & 0 $Omega$ & \
hline
& & & & & 8 & N.C. & Open & Open \
cline{6-9}
6 & RIO & RIO_VOLT_SDAR & BAT_EMPTY TBD & P2 & 10 & COM & 0 $Omega$ & TBD \
cline{6-9}
& & & & & 12 & N.O. & 0 $Omega$ & \
hline
& & & & & 2 & N.C. & Open & Open \
cline{6-9}
7 & RIO & RIO_VOLT_SDAR & RIO_DSP_+3V3 & P2 & 4 & COM & 0 $Omega$ & SIGN08150 \
cline{6-9}
& & & & & 6 & N.O. & 0 $Omega$ & Open \
hline
end{tabular}
}
caption{Verkabelung der ersten Relaisplatine an X400/PortA}
end{table}
Gives me:
edited Jul 4 '17 at 15:22
answered Jul 4 '17 at 15:08
Simon GasserSimon Gasser
749
749
add a comment |
add a comment |
Putting a tabular in the cell of a tabular centers the content of the cell horizontally and vertically.
begin{tabular}{|l|c|c|}
hline
begin{tabular}{l}
text in cell 1
end{tabular} &
begin{tabular}{l}
first line of text in cell 2 \
second line of text in cell 2
end{tabular} &
begin{tabular}{l}
first line of text in cell 3 \
second line of text in cell 3 \
third line of text in cell 3 \
end{tabular}
\
hline
begin{tabular}{l}
first line of text in cell 4 \
second line of text in cell 4
end{tabular} &
begin{tabular}{l}
first line of text in cell 5 \
second line of text in cell 5 \
third line of text in cell 5 \
end{tabular} &
begin{tabular}{l}
first line of text in cell 6 \
second line of text in cell 6 \
end{tabular} \
hline
end{tabular}
gives:
so you can define a macro centered
newcommand{centered}[1]{begin{tabular}{l} #1 end{tabular}}
and use it like this:
begin{tabular}{|l|c|c|}
hline
centered{ text in cell 1 } &
centered{
first line of text in cell 2 \
second line of text in cell 2} &
centered{
first line of text in cell 3 \
second line of text in cell 3 \
third line of text in cell 3 \ } \
hline
centered{
first line of text in cell 4 \
second line of text in cell 4 } &
centered{
first line of text in cell 5 \
second line of text in cell 5 \
third line of text in cell 5 \ } &
centered{
first line of text in cell 6 \
second line of text in cell 6 \ } \
hline
end{tabular}
add a comment |
Putting a tabular in the cell of a tabular centers the content of the cell horizontally and vertically.
begin{tabular}{|l|c|c|}
hline
begin{tabular}{l}
text in cell 1
end{tabular} &
begin{tabular}{l}
first line of text in cell 2 \
second line of text in cell 2
end{tabular} &
begin{tabular}{l}
first line of text in cell 3 \
second line of text in cell 3 \
third line of text in cell 3 \
end{tabular}
\
hline
begin{tabular}{l}
first line of text in cell 4 \
second line of text in cell 4
end{tabular} &
begin{tabular}{l}
first line of text in cell 5 \
second line of text in cell 5 \
third line of text in cell 5 \
end{tabular} &
begin{tabular}{l}
first line of text in cell 6 \
second line of text in cell 6 \
end{tabular} \
hline
end{tabular}
gives:
so you can define a macro centered
newcommand{centered}[1]{begin{tabular}{l} #1 end{tabular}}
and use it like this:
begin{tabular}{|l|c|c|}
hline
centered{ text in cell 1 } &
centered{
first line of text in cell 2 \
second line of text in cell 2} &
centered{
first line of text in cell 3 \
second line of text in cell 3 \
third line of text in cell 3 \ } \
hline
centered{
first line of text in cell 4 \
second line of text in cell 4 } &
centered{
first line of text in cell 5 \
second line of text in cell 5 \
third line of text in cell 5 \ } &
centered{
first line of text in cell 6 \
second line of text in cell 6 \ } \
hline
end{tabular}
add a comment |
Putting a tabular in the cell of a tabular centers the content of the cell horizontally and vertically.
begin{tabular}{|l|c|c|}
hline
begin{tabular}{l}
text in cell 1
end{tabular} &
begin{tabular}{l}
first line of text in cell 2 \
second line of text in cell 2
end{tabular} &
begin{tabular}{l}
first line of text in cell 3 \
second line of text in cell 3 \
third line of text in cell 3 \
end{tabular}
\
hline
begin{tabular}{l}
first line of text in cell 4 \
second line of text in cell 4
end{tabular} &
begin{tabular}{l}
first line of text in cell 5 \
second line of text in cell 5 \
third line of text in cell 5 \
end{tabular} &
begin{tabular}{l}
first line of text in cell 6 \
second line of text in cell 6 \
end{tabular} \
hline
end{tabular}
gives:
so you can define a macro centered
newcommand{centered}[1]{begin{tabular}{l} #1 end{tabular}}
and use it like this:
begin{tabular}{|l|c|c|}
hline
centered{ text in cell 1 } &
centered{
first line of text in cell 2 \
second line of text in cell 2} &
centered{
first line of text in cell 3 \
second line of text in cell 3 \
third line of text in cell 3 \ } \
hline
centered{
first line of text in cell 4 \
second line of text in cell 4 } &
centered{
first line of text in cell 5 \
second line of text in cell 5 \
third line of text in cell 5 \ } &
centered{
first line of text in cell 6 \
second line of text in cell 6 \ } \
hline
end{tabular}
Putting a tabular in the cell of a tabular centers the content of the cell horizontally and vertically.
begin{tabular}{|l|c|c|}
hline
begin{tabular}{l}
text in cell 1
end{tabular} &
begin{tabular}{l}
first line of text in cell 2 \
second line of text in cell 2
end{tabular} &
begin{tabular}{l}
first line of text in cell 3 \
second line of text in cell 3 \
third line of text in cell 3 \
end{tabular}
\
hline
begin{tabular}{l}
first line of text in cell 4 \
second line of text in cell 4
end{tabular} &
begin{tabular}{l}
first line of text in cell 5 \
second line of text in cell 5 \
third line of text in cell 5 \
end{tabular} &
begin{tabular}{l}
first line of text in cell 6 \
second line of text in cell 6 \
end{tabular} \
hline
end{tabular}
gives:
so you can define a macro centered
newcommand{centered}[1]{begin{tabular}{l} #1 end{tabular}}
and use it like this:
begin{tabular}{|l|c|c|}
hline
centered{ text in cell 1 } &
centered{
first line of text in cell 2 \
second line of text in cell 2} &
centered{
first line of text in cell 3 \
second line of text in cell 3 \
third line of text in cell 3 \ } \
hline
centered{
first line of text in cell 4 \
second line of text in cell 4 } &
centered{
first line of text in cell 5 \
second line of text in cell 5 \
third line of text in cell 5 \ } &
centered{
first line of text in cell 6 \
second line of text in cell 6 \ } \
hline
end{tabular}
answered Feb 6 at 14:06
Anthony ScemamaAnthony Scemama
1012
1012
add a comment |
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f7208%2fhow-to-vertically-center-the-text-of-the-cells%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
This earlier question might be of help to you.
– morbusg
Dec 16 '10 at 12:34
3
Looking closer at your example, I realize you obviously have the array package loaded.
p{...}
aligns the content toward the top,m{...}
aligns the content toward the center, whileb{...}
aligns it toward the bottom.– Jimi Oke
Dec 17 '10 at 23:19
1
@Jimi: the example works even without array. The
p
specifier is standard.– Stefan Kottwitz♦
Dec 18 '10 at 15:35
1
Question, actually. How in the world would a person who knows nothing about code go about this? I'm drowning in information, here.
– user44066
Jan 12 '14 at 23:33
1
@Amy it's not as bad as it looks. You can just copy the code into your document and see if it works. After some time you will get used to Latex code more and more. I would start with the small things first by making tables in an -- for you -- acceptable format, without worrying too much about perfection, which can be done later.
– TomM
Jan 13 '14 at 0:16