How to merge row in the first column in LaTeX
I want to create table like this in Latex.
This is my script for create table.
begin{table}
centering
caption{Table}
begin{tabular}{|c|c|l|} hline
multirow{3}{*}{DEF}&multicolumn{3}{|c|}{ ABC} \ hline
A&B&C\ hline
1& 4 & 7 \ hline
2& 5 & 8 \ hline
3& 6 & 9 \ hline
end{tabular}
end{table}
When I run this script it show error like this.
! Extra alignment tab has been changed to cr.<template> endtemplate ...row{3}{}{DEF}&multicolumn{3}{|c|}{ ABC}
How to create table like this picture?
tables multirow
add a comment |
I want to create table like this in Latex.
This is my script for create table.
begin{table}
centering
caption{Table}
begin{tabular}{|c|c|l|} hline
multirow{3}{*}{DEF}&multicolumn{3}{|c|}{ ABC} \ hline
A&B&C\ hline
1& 4 & 7 \ hline
2& 5 & 8 \ hline
3& 6 & 9 \ hline
end{tabular}
end{table}
When I run this script it show error like this.
! Extra alignment tab has been changed to cr.<template> endtemplate ...row{3}{}{DEF}&multicolumn{3}{|c|}{ ABC}
How to create table like this picture?
tables multirow
1
Hey, and welcome to tex.SX. Please provide compilable code (i.e. withbegin{document}
. This will make it easier for us to help you
– sheß
Mar 6 at 17:51
add a comment |
I want to create table like this in Latex.
This is my script for create table.
begin{table}
centering
caption{Table}
begin{tabular}{|c|c|l|} hline
multirow{3}{*}{DEF}&multicolumn{3}{|c|}{ ABC} \ hline
A&B&C\ hline
1& 4 & 7 \ hline
2& 5 & 8 \ hline
3& 6 & 9 \ hline
end{tabular}
end{table}
When I run this script it show error like this.
! Extra alignment tab has been changed to cr.<template> endtemplate ...row{3}{}{DEF}&multicolumn{3}{|c|}{ ABC}
How to create table like this picture?
tables multirow
I want to create table like this in Latex.
This is my script for create table.
begin{table}
centering
caption{Table}
begin{tabular}{|c|c|l|} hline
multirow{3}{*}{DEF}&multicolumn{3}{|c|}{ ABC} \ hline
A&B&C\ hline
1& 4 & 7 \ hline
2& 5 & 8 \ hline
3& 6 & 9 \ hline
end{tabular}
end{table}
When I run this script it show error like this.
! Extra alignment tab has been changed to cr.<template> endtemplate ...row{3}{}{DEF}&multicolumn{3}{|c|}{ ABC}
How to create table like this picture?
tables multirow
tables multirow
asked Mar 6 at 17:44
user58519user58519
332
332
1
Hey, and welcome to tex.SX. Please provide compilable code (i.e. withbegin{document}
. This will make it easier for us to help you
– sheß
Mar 6 at 17:51
add a comment |
1
Hey, and welcome to tex.SX. Please provide compilable code (i.e. withbegin{document}
. This will make it easier for us to help you
– sheß
Mar 6 at 17:51
1
1
Hey, and welcome to tex.SX. Please provide compilable code (i.e. with
begin{document}
. This will make it easier for us to help you– sheß
Mar 6 at 17:51
Hey, and welcome to tex.SX. Please provide compilable code (i.e. with
begin{document}
. This will make it easier for us to help you– sheß
Mar 6 at 17:51
add a comment |
3 Answers
3
active
oldest
votes
You can decipher the following template.
documentclass[preview,border=12pt,12pt]{standalone}
usepackage{array,multirow}
letmc=multicolumn
letmr=multirow
letcl=cline
begin{document}
begin{tabular}{|*6{c|}l}
cl{3-6}
mc{2}{c|}{mr{2}{*}{empty}} & mc{4}{c|}{Primes} \cl{3-6}
mc{2}{c|}{} & 2 & 3 & 5 & 7 \cl{1-6}
mr{2}{*}{Powers} & 504 & 3 & 2 & 0 & 1 \cl{2-6}
& 540 & 2 & 3 & 1 & 0 \cl{1-6}
mr{2}{*}{Powers} & HCF & 2 & 2 & 0 & 0 & min \cl{2-6}
& LCM & 3 & 3 & 1 & 1 & max \cl{1-6}
end{tabular}
end{document}
Warning
mr
can be nested in mc
but the reverse is not possible!
References
My code above was inspired by an example from Wikipedia as follows.
begin{tabular}{cc|c|c|c|c|l}
cline{3-6}
& & multicolumn{4}{ c| }{Primes} \ cline{3-6}
& & 2 & 3 & 5 & 7 \ cline{1-6}
multicolumn{1}{ |c }{multirow{2}{*}{Powers} } &
multicolumn{1}{ |c| }{504} & 3 & 2 & 0 & 1 & \ cline{2-6}
multicolumn{1}{ |c }{} &
multicolumn{1}{ |c| }{540} & 2 & 3 & 1 & 0 & \ cline{1-6}
multicolumn{1}{ |c }{multirow{2}{*}{Powers} } &
multicolumn{1}{ |c| }{gcd} & 2 & 2 & 0 & 0 & min \ cline{2-6}
multicolumn{1}{ |c }{} &
multicolumn{1}{ |c| }{lcm} & 3 & 3 & 1 & 1 & max \ cline{1-6}
end{tabular}
However, as you can see and compare, my code is much much simpler and well refactored yet still readable, right?
add a comment |
What you try to do can be done with this:
documentclass{standalone}
usepackage{multirow}
begin{document}
begin{tabular}{|c|c|c|c|c} hline
& & multicolumn{3}{|c|}{ ABC} \ hline
& & A&B&C\ hline
multirow{3}{*}{DEF} & D &1& 4 & 7 \ cline{2-5}
&E& 2& 5 & 8 \ cline{2-5}
&F& 3& 6 & 9 \ cline{2-5}
end{tabular}
end{document}
But! LaTeX can make tables that are much nicer that this Excel-style layout. Consider doing something like this, which still nice to look at if you have more than 3 columns.
documentclass{standalone}
usepackage{multirow}
usepackage{booktabs}
begin{document}
begin{tabular}{lcccccc}
toprule
& multicolumn{3}{c}{ ABC} & multicolumn{3}{c}{ ABC} \cmidrule(lr){2-4} cmidrule(lr){5-7}
& A&B&C & A2&B2&C2\ midrule
DEF:\
;D &1& 4 & 7 &1& 4 & 7 \
;E& 2& 5 & 8 &1& 4 & 7 \
;F& 3& 6 & 9 &1& 4 & 7 \
XYZ:\
;X &1& 4 & 7 &1& 4 & 7 \
;Y& 2& 5 & 8 &1& 4 & 7 \
;Z& 3& 6 & 9 &1& 4 & 7 \ bottomrule
end{tabular}
end{document}
add a comment |
multirow
command, needs to be act on its own column...
So you need to add an extra column on the left side in each column and thus an extra &
needed on each left side of every row of your table and an extra columntype (lets say c
) at the beginning of your tabular's arguments.
Also, multicolumn in your example will should be 3 rows tall and should start from the row (1,4,7). But then an hline
on one of this or the next rows, would add a line in the "multirowed" cell too, and this is not wanted. So, we have to change some hline
s with cline{2-4}
that is a line from column 2 to column 4 and not from 1st to last.
Finally, you can add empty multicolumn{1}{c|}{}
as first element of your first two rows, in order to change their behavior from |c|
to c|
and remove this way the unwanted vertical line from their left side:
documentclass{article}
usepackage{multirow}
begin{document}
begin{table}
centering
caption{Table}
begin{tabular}{|c|c|c|l|} cline{2-4}
multicolumn{1}{c|}{}&multicolumn{3}{|c|}{ ABC} \ cline{2-4}
multicolumn{1}{c|}{}&A&B&C\ hline
multirow{3}{*}{DEF}&1& 4 & 7 \ cline{2-4}
&2& 5 & 8 \ cline{2-4}
&3& 6 & 9 \ hline
end{tabular}
end{table}
end{document}
PS: Tried to show you what was your mistakes and not to find a way to show your table more beautiful.
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%2f478062%2fhow-to-merge-row-in-the-first-column-in-latex%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
You can decipher the following template.
documentclass[preview,border=12pt,12pt]{standalone}
usepackage{array,multirow}
letmc=multicolumn
letmr=multirow
letcl=cline
begin{document}
begin{tabular}{|*6{c|}l}
cl{3-6}
mc{2}{c|}{mr{2}{*}{empty}} & mc{4}{c|}{Primes} \cl{3-6}
mc{2}{c|}{} & 2 & 3 & 5 & 7 \cl{1-6}
mr{2}{*}{Powers} & 504 & 3 & 2 & 0 & 1 \cl{2-6}
& 540 & 2 & 3 & 1 & 0 \cl{1-6}
mr{2}{*}{Powers} & HCF & 2 & 2 & 0 & 0 & min \cl{2-6}
& LCM & 3 & 3 & 1 & 1 & max \cl{1-6}
end{tabular}
end{document}
Warning
mr
can be nested in mc
but the reverse is not possible!
References
My code above was inspired by an example from Wikipedia as follows.
begin{tabular}{cc|c|c|c|c|l}
cline{3-6}
& & multicolumn{4}{ c| }{Primes} \ cline{3-6}
& & 2 & 3 & 5 & 7 \ cline{1-6}
multicolumn{1}{ |c }{multirow{2}{*}{Powers} } &
multicolumn{1}{ |c| }{504} & 3 & 2 & 0 & 1 & \ cline{2-6}
multicolumn{1}{ |c }{} &
multicolumn{1}{ |c| }{540} & 2 & 3 & 1 & 0 & \ cline{1-6}
multicolumn{1}{ |c }{multirow{2}{*}{Powers} } &
multicolumn{1}{ |c| }{gcd} & 2 & 2 & 0 & 0 & min \ cline{2-6}
multicolumn{1}{ |c }{} &
multicolumn{1}{ |c| }{lcm} & 3 & 3 & 1 & 1 & max \ cline{1-6}
end{tabular}
However, as you can see and compare, my code is much much simpler and well refactored yet still readable, right?
add a comment |
You can decipher the following template.
documentclass[preview,border=12pt,12pt]{standalone}
usepackage{array,multirow}
letmc=multicolumn
letmr=multirow
letcl=cline
begin{document}
begin{tabular}{|*6{c|}l}
cl{3-6}
mc{2}{c|}{mr{2}{*}{empty}} & mc{4}{c|}{Primes} \cl{3-6}
mc{2}{c|}{} & 2 & 3 & 5 & 7 \cl{1-6}
mr{2}{*}{Powers} & 504 & 3 & 2 & 0 & 1 \cl{2-6}
& 540 & 2 & 3 & 1 & 0 \cl{1-6}
mr{2}{*}{Powers} & HCF & 2 & 2 & 0 & 0 & min \cl{2-6}
& LCM & 3 & 3 & 1 & 1 & max \cl{1-6}
end{tabular}
end{document}
Warning
mr
can be nested in mc
but the reverse is not possible!
References
My code above was inspired by an example from Wikipedia as follows.
begin{tabular}{cc|c|c|c|c|l}
cline{3-6}
& & multicolumn{4}{ c| }{Primes} \ cline{3-6}
& & 2 & 3 & 5 & 7 \ cline{1-6}
multicolumn{1}{ |c }{multirow{2}{*}{Powers} } &
multicolumn{1}{ |c| }{504} & 3 & 2 & 0 & 1 & \ cline{2-6}
multicolumn{1}{ |c }{} &
multicolumn{1}{ |c| }{540} & 2 & 3 & 1 & 0 & \ cline{1-6}
multicolumn{1}{ |c }{multirow{2}{*}{Powers} } &
multicolumn{1}{ |c| }{gcd} & 2 & 2 & 0 & 0 & min \ cline{2-6}
multicolumn{1}{ |c }{} &
multicolumn{1}{ |c| }{lcm} & 3 & 3 & 1 & 1 & max \ cline{1-6}
end{tabular}
However, as you can see and compare, my code is much much simpler and well refactored yet still readable, right?
add a comment |
You can decipher the following template.
documentclass[preview,border=12pt,12pt]{standalone}
usepackage{array,multirow}
letmc=multicolumn
letmr=multirow
letcl=cline
begin{document}
begin{tabular}{|*6{c|}l}
cl{3-6}
mc{2}{c|}{mr{2}{*}{empty}} & mc{4}{c|}{Primes} \cl{3-6}
mc{2}{c|}{} & 2 & 3 & 5 & 7 \cl{1-6}
mr{2}{*}{Powers} & 504 & 3 & 2 & 0 & 1 \cl{2-6}
& 540 & 2 & 3 & 1 & 0 \cl{1-6}
mr{2}{*}{Powers} & HCF & 2 & 2 & 0 & 0 & min \cl{2-6}
& LCM & 3 & 3 & 1 & 1 & max \cl{1-6}
end{tabular}
end{document}
Warning
mr
can be nested in mc
but the reverse is not possible!
References
My code above was inspired by an example from Wikipedia as follows.
begin{tabular}{cc|c|c|c|c|l}
cline{3-6}
& & multicolumn{4}{ c| }{Primes} \ cline{3-6}
& & 2 & 3 & 5 & 7 \ cline{1-6}
multicolumn{1}{ |c }{multirow{2}{*}{Powers} } &
multicolumn{1}{ |c| }{504} & 3 & 2 & 0 & 1 & \ cline{2-6}
multicolumn{1}{ |c }{} &
multicolumn{1}{ |c| }{540} & 2 & 3 & 1 & 0 & \ cline{1-6}
multicolumn{1}{ |c }{multirow{2}{*}{Powers} } &
multicolumn{1}{ |c| }{gcd} & 2 & 2 & 0 & 0 & min \ cline{2-6}
multicolumn{1}{ |c }{} &
multicolumn{1}{ |c| }{lcm} & 3 & 3 & 1 & 1 & max \ cline{1-6}
end{tabular}
However, as you can see and compare, my code is much much simpler and well refactored yet still readable, right?
You can decipher the following template.
documentclass[preview,border=12pt,12pt]{standalone}
usepackage{array,multirow}
letmc=multicolumn
letmr=multirow
letcl=cline
begin{document}
begin{tabular}{|*6{c|}l}
cl{3-6}
mc{2}{c|}{mr{2}{*}{empty}} & mc{4}{c|}{Primes} \cl{3-6}
mc{2}{c|}{} & 2 & 3 & 5 & 7 \cl{1-6}
mr{2}{*}{Powers} & 504 & 3 & 2 & 0 & 1 \cl{2-6}
& 540 & 2 & 3 & 1 & 0 \cl{1-6}
mr{2}{*}{Powers} & HCF & 2 & 2 & 0 & 0 & min \cl{2-6}
& LCM & 3 & 3 & 1 & 1 & max \cl{1-6}
end{tabular}
end{document}
Warning
mr
can be nested in mc
but the reverse is not possible!
References
My code above was inspired by an example from Wikipedia as follows.
begin{tabular}{cc|c|c|c|c|l}
cline{3-6}
& & multicolumn{4}{ c| }{Primes} \ cline{3-6}
& & 2 & 3 & 5 & 7 \ cline{1-6}
multicolumn{1}{ |c }{multirow{2}{*}{Powers} } &
multicolumn{1}{ |c| }{504} & 3 & 2 & 0 & 1 & \ cline{2-6}
multicolumn{1}{ |c }{} &
multicolumn{1}{ |c| }{540} & 2 & 3 & 1 & 0 & \ cline{1-6}
multicolumn{1}{ |c }{multirow{2}{*}{Powers} } &
multicolumn{1}{ |c| }{gcd} & 2 & 2 & 0 & 0 & min \ cline{2-6}
multicolumn{1}{ |c }{} &
multicolumn{1}{ |c| }{lcm} & 3 & 3 & 1 & 1 & max \ cline{1-6}
end{tabular}
However, as you can see and compare, my code is much much simpler and well refactored yet still readable, right?
edited Mar 6 at 18:39
answered Mar 6 at 17:54
The Inventor of GodThe Inventor of God
4,79611042
4,79611042
add a comment |
add a comment |
What you try to do can be done with this:
documentclass{standalone}
usepackage{multirow}
begin{document}
begin{tabular}{|c|c|c|c|c} hline
& & multicolumn{3}{|c|}{ ABC} \ hline
& & A&B&C\ hline
multirow{3}{*}{DEF} & D &1& 4 & 7 \ cline{2-5}
&E& 2& 5 & 8 \ cline{2-5}
&F& 3& 6 & 9 \ cline{2-5}
end{tabular}
end{document}
But! LaTeX can make tables that are much nicer that this Excel-style layout. Consider doing something like this, which still nice to look at if you have more than 3 columns.
documentclass{standalone}
usepackage{multirow}
usepackage{booktabs}
begin{document}
begin{tabular}{lcccccc}
toprule
& multicolumn{3}{c}{ ABC} & multicolumn{3}{c}{ ABC} \cmidrule(lr){2-4} cmidrule(lr){5-7}
& A&B&C & A2&B2&C2\ midrule
DEF:\
;D &1& 4 & 7 &1& 4 & 7 \
;E& 2& 5 & 8 &1& 4 & 7 \
;F& 3& 6 & 9 &1& 4 & 7 \
XYZ:\
;X &1& 4 & 7 &1& 4 & 7 \
;Y& 2& 5 & 8 &1& 4 & 7 \
;Z& 3& 6 & 9 &1& 4 & 7 \ bottomrule
end{tabular}
end{document}
add a comment |
What you try to do can be done with this:
documentclass{standalone}
usepackage{multirow}
begin{document}
begin{tabular}{|c|c|c|c|c} hline
& & multicolumn{3}{|c|}{ ABC} \ hline
& & A&B&C\ hline
multirow{3}{*}{DEF} & D &1& 4 & 7 \ cline{2-5}
&E& 2& 5 & 8 \ cline{2-5}
&F& 3& 6 & 9 \ cline{2-5}
end{tabular}
end{document}
But! LaTeX can make tables that are much nicer that this Excel-style layout. Consider doing something like this, which still nice to look at if you have more than 3 columns.
documentclass{standalone}
usepackage{multirow}
usepackage{booktabs}
begin{document}
begin{tabular}{lcccccc}
toprule
& multicolumn{3}{c}{ ABC} & multicolumn{3}{c}{ ABC} \cmidrule(lr){2-4} cmidrule(lr){5-7}
& A&B&C & A2&B2&C2\ midrule
DEF:\
;D &1& 4 & 7 &1& 4 & 7 \
;E& 2& 5 & 8 &1& 4 & 7 \
;F& 3& 6 & 9 &1& 4 & 7 \
XYZ:\
;X &1& 4 & 7 &1& 4 & 7 \
;Y& 2& 5 & 8 &1& 4 & 7 \
;Z& 3& 6 & 9 &1& 4 & 7 \ bottomrule
end{tabular}
end{document}
add a comment |
What you try to do can be done with this:
documentclass{standalone}
usepackage{multirow}
begin{document}
begin{tabular}{|c|c|c|c|c} hline
& & multicolumn{3}{|c|}{ ABC} \ hline
& & A&B&C\ hline
multirow{3}{*}{DEF} & D &1& 4 & 7 \ cline{2-5}
&E& 2& 5 & 8 \ cline{2-5}
&F& 3& 6 & 9 \ cline{2-5}
end{tabular}
end{document}
But! LaTeX can make tables that are much nicer that this Excel-style layout. Consider doing something like this, which still nice to look at if you have more than 3 columns.
documentclass{standalone}
usepackage{multirow}
usepackage{booktabs}
begin{document}
begin{tabular}{lcccccc}
toprule
& multicolumn{3}{c}{ ABC} & multicolumn{3}{c}{ ABC} \cmidrule(lr){2-4} cmidrule(lr){5-7}
& A&B&C & A2&B2&C2\ midrule
DEF:\
;D &1& 4 & 7 &1& 4 & 7 \
;E& 2& 5 & 8 &1& 4 & 7 \
;F& 3& 6 & 9 &1& 4 & 7 \
XYZ:\
;X &1& 4 & 7 &1& 4 & 7 \
;Y& 2& 5 & 8 &1& 4 & 7 \
;Z& 3& 6 & 9 &1& 4 & 7 \ bottomrule
end{tabular}
end{document}
What you try to do can be done with this:
documentclass{standalone}
usepackage{multirow}
begin{document}
begin{tabular}{|c|c|c|c|c} hline
& & multicolumn{3}{|c|}{ ABC} \ hline
& & A&B&C\ hline
multirow{3}{*}{DEF} & D &1& 4 & 7 \ cline{2-5}
&E& 2& 5 & 8 \ cline{2-5}
&F& 3& 6 & 9 \ cline{2-5}
end{tabular}
end{document}
But! LaTeX can make tables that are much nicer that this Excel-style layout. Consider doing something like this, which still nice to look at if you have more than 3 columns.
documentclass{standalone}
usepackage{multirow}
usepackage{booktabs}
begin{document}
begin{tabular}{lcccccc}
toprule
& multicolumn{3}{c}{ ABC} & multicolumn{3}{c}{ ABC} \cmidrule(lr){2-4} cmidrule(lr){5-7}
& A&B&C & A2&B2&C2\ midrule
DEF:\
;D &1& 4 & 7 &1& 4 & 7 \
;E& 2& 5 & 8 &1& 4 & 7 \
;F& 3& 6 & 9 &1& 4 & 7 \
XYZ:\
;X &1& 4 & 7 &1& 4 & 7 \
;Y& 2& 5 & 8 &1& 4 & 7 \
;Z& 3& 6 & 9 &1& 4 & 7 \ bottomrule
end{tabular}
end{document}
edited Mar 6 at 18:13
answered Mar 6 at 18:03
sheßsheß
2,20311435
2,20311435
add a comment |
add a comment |
multirow
command, needs to be act on its own column...
So you need to add an extra column on the left side in each column and thus an extra &
needed on each left side of every row of your table and an extra columntype (lets say c
) at the beginning of your tabular's arguments.
Also, multicolumn in your example will should be 3 rows tall and should start from the row (1,4,7). But then an hline
on one of this or the next rows, would add a line in the "multirowed" cell too, and this is not wanted. So, we have to change some hline
s with cline{2-4}
that is a line from column 2 to column 4 and not from 1st to last.
Finally, you can add empty multicolumn{1}{c|}{}
as first element of your first two rows, in order to change their behavior from |c|
to c|
and remove this way the unwanted vertical line from their left side:
documentclass{article}
usepackage{multirow}
begin{document}
begin{table}
centering
caption{Table}
begin{tabular}{|c|c|c|l|} cline{2-4}
multicolumn{1}{c|}{}&multicolumn{3}{|c|}{ ABC} \ cline{2-4}
multicolumn{1}{c|}{}&A&B&C\ hline
multirow{3}{*}{DEF}&1& 4 & 7 \ cline{2-4}
&2& 5 & 8 \ cline{2-4}
&3& 6 & 9 \ hline
end{tabular}
end{table}
end{document}
PS: Tried to show you what was your mistakes and not to find a way to show your table more beautiful.
add a comment |
multirow
command, needs to be act on its own column...
So you need to add an extra column on the left side in each column and thus an extra &
needed on each left side of every row of your table and an extra columntype (lets say c
) at the beginning of your tabular's arguments.
Also, multicolumn in your example will should be 3 rows tall and should start from the row (1,4,7). But then an hline
on one of this or the next rows, would add a line in the "multirowed" cell too, and this is not wanted. So, we have to change some hline
s with cline{2-4}
that is a line from column 2 to column 4 and not from 1st to last.
Finally, you can add empty multicolumn{1}{c|}{}
as first element of your first two rows, in order to change their behavior from |c|
to c|
and remove this way the unwanted vertical line from their left side:
documentclass{article}
usepackage{multirow}
begin{document}
begin{table}
centering
caption{Table}
begin{tabular}{|c|c|c|l|} cline{2-4}
multicolumn{1}{c|}{}&multicolumn{3}{|c|}{ ABC} \ cline{2-4}
multicolumn{1}{c|}{}&A&B&C\ hline
multirow{3}{*}{DEF}&1& 4 & 7 \ cline{2-4}
&2& 5 & 8 \ cline{2-4}
&3& 6 & 9 \ hline
end{tabular}
end{table}
end{document}
PS: Tried to show you what was your mistakes and not to find a way to show your table more beautiful.
add a comment |
multirow
command, needs to be act on its own column...
So you need to add an extra column on the left side in each column and thus an extra &
needed on each left side of every row of your table and an extra columntype (lets say c
) at the beginning of your tabular's arguments.
Also, multicolumn in your example will should be 3 rows tall and should start from the row (1,4,7). But then an hline
on one of this or the next rows, would add a line in the "multirowed" cell too, and this is not wanted. So, we have to change some hline
s with cline{2-4}
that is a line from column 2 to column 4 and not from 1st to last.
Finally, you can add empty multicolumn{1}{c|}{}
as first element of your first two rows, in order to change their behavior from |c|
to c|
and remove this way the unwanted vertical line from their left side:
documentclass{article}
usepackage{multirow}
begin{document}
begin{table}
centering
caption{Table}
begin{tabular}{|c|c|c|l|} cline{2-4}
multicolumn{1}{c|}{}&multicolumn{3}{|c|}{ ABC} \ cline{2-4}
multicolumn{1}{c|}{}&A&B&C\ hline
multirow{3}{*}{DEF}&1& 4 & 7 \ cline{2-4}
&2& 5 & 8 \ cline{2-4}
&3& 6 & 9 \ hline
end{tabular}
end{table}
end{document}
PS: Tried to show you what was your mistakes and not to find a way to show your table more beautiful.
multirow
command, needs to be act on its own column...
So you need to add an extra column on the left side in each column and thus an extra &
needed on each left side of every row of your table and an extra columntype (lets say c
) at the beginning of your tabular's arguments.
Also, multicolumn in your example will should be 3 rows tall and should start from the row (1,4,7). But then an hline
on one of this or the next rows, would add a line in the "multirowed" cell too, and this is not wanted. So, we have to change some hline
s with cline{2-4}
that is a line from column 2 to column 4 and not from 1st to last.
Finally, you can add empty multicolumn{1}{c|}{}
as first element of your first two rows, in order to change their behavior from |c|
to c|
and remove this way the unwanted vertical line from their left side:
documentclass{article}
usepackage{multirow}
begin{document}
begin{table}
centering
caption{Table}
begin{tabular}{|c|c|c|l|} cline{2-4}
multicolumn{1}{c|}{}&multicolumn{3}{|c|}{ ABC} \ cline{2-4}
multicolumn{1}{c|}{}&A&B&C\ hline
multirow{3}{*}{DEF}&1& 4 & 7 \ cline{2-4}
&2& 5 & 8 \ cline{2-4}
&3& 6 & 9 \ hline
end{tabular}
end{table}
end{document}
PS: Tried to show you what was your mistakes and not to find a way to show your table more beautiful.
answered Mar 6 at 18:13
koleygrkoleygr
12.6k11038
12.6k11038
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%2f478062%2fhow-to-merge-row-in-the-first-column-in-latex%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
1
Hey, and welcome to tex.SX. Please provide compilable code (i.e. with
begin{document}
. This will make it easier for us to help you– sheß
Mar 6 at 17:51