Adding labels to a table: columns and rows
Can anybody help me? I know how to build the table but I don’t know how to add the “Users” and “Movies” labels.
This is what I've tried so far:
begin{table}[H]
centering
text{ textbf{Movies}}
begin{tabular}{c | c | c | c | c | c | c | c | c | }
multicolumn{1}{c}{} & multicolumn{1}{c}{1} & multicolumn{1}{c}{2}
& multicolumn{1}{c}{3} & multicolumn{1}{c}{4} & multicolumn{1}{c}{5}
& multicolumn{1}{c}{6} & multicolumn{1}{c}{7} & multicolumn{1}{c}{8} \ hhline{~*8{|-}|}
1 & & 5 & & 2 & 4 & & & \ hhline{~*8{|-}|}
2 & 4 & & 3 & 1 & & & 3 & \ hhline{~*8{|-}|}
3 & & 5 & 4 & & 5 & & 4 &\ hhline{~*8{|-}|}
4 & & & & & & 1 & 1 & 2 \ hhline{~*8{|-}|}
5 & 3 & & color{blue}textbf{?} & & color{blue}textbf{?} & 3 & & 0 \ hhline{~*8{|-}|}
6 & & color{blue}textbf{?} & 2 & & 4 & &color{blue}textbf{?} & \ hhline{~*8{|-}|}
end{tabular}
Thanks!
tables
New contributor
add a comment |
Can anybody help me? I know how to build the table but I don’t know how to add the “Users” and “Movies” labels.
This is what I've tried so far:
begin{table}[H]
centering
text{ textbf{Movies}}
begin{tabular}{c | c | c | c | c | c | c | c | c | }
multicolumn{1}{c}{} & multicolumn{1}{c}{1} & multicolumn{1}{c}{2}
& multicolumn{1}{c}{3} & multicolumn{1}{c}{4} & multicolumn{1}{c}{5}
& multicolumn{1}{c}{6} & multicolumn{1}{c}{7} & multicolumn{1}{c}{8} \ hhline{~*8{|-}|}
1 & & 5 & & 2 & 4 & & & \ hhline{~*8{|-}|}
2 & 4 & & 3 & 1 & & & 3 & \ hhline{~*8{|-}|}
3 & & 5 & 4 & & 5 & & 4 &\ hhline{~*8{|-}|}
4 & & & & & & 1 & 1 & 2 \ hhline{~*8{|-}|}
5 & 3 & & color{blue}textbf{?} & & color{blue}textbf{?} & 3 & & 0 \ hhline{~*8{|-}|}
6 & & color{blue}textbf{?} & 2 & & 4 & &color{blue}textbf{?} & \ hhline{~*8{|-}|}
end{tabular}
Thanks!
tables
New contributor
You can have it withmultirow
andmulticolumn
, but I'd use TikZ for that. Anyway: what have you tried so far? Please add a minimal code.
– JouleV
49 mins ago
` begin{tabular}{c | c | c | c | c | c | c | c | c | } multicolumn{1}{c}{} & multicolumn{1}{c}{1} & multicolumn{1}{c}{2} & multicolumn{1}{c}{3} & multicolumn{1}{c}{4} & multicolumn{1}{c}{5} & multicolumn{1}{c}{6} & multicolumn{1}{c}{7} & multicolumn{1}{c}{8} \ hhline{~*8{|-}|} 1 & & 5 & & 2 & 4 & & & \ hhline{~*8{|-}|} 2 & 4 & & 3 & 1 & & & 3 & \ hhline{~*8{|-}|} 3 & & 5 & 4 & & 5 & & 4 &\ hhline{~*8{|-}|} 4 & & & & & & 1 & 1 & 2 \ hhline{~*8{|-}|} 5 & 3 & & color{blue}textbf{?} & & color{blue}textbf{?} & 3 & & 0 `
– naveganteX
44 mins ago
@JouleV I have added the code!
– naveganteX
38 mins ago
add a comment |
Can anybody help me? I know how to build the table but I don’t know how to add the “Users” and “Movies” labels.
This is what I've tried so far:
begin{table}[H]
centering
text{ textbf{Movies}}
begin{tabular}{c | c | c | c | c | c | c | c | c | }
multicolumn{1}{c}{} & multicolumn{1}{c}{1} & multicolumn{1}{c}{2}
& multicolumn{1}{c}{3} & multicolumn{1}{c}{4} & multicolumn{1}{c}{5}
& multicolumn{1}{c}{6} & multicolumn{1}{c}{7} & multicolumn{1}{c}{8} \ hhline{~*8{|-}|}
1 & & 5 & & 2 & 4 & & & \ hhline{~*8{|-}|}
2 & 4 & & 3 & 1 & & & 3 & \ hhline{~*8{|-}|}
3 & & 5 & 4 & & 5 & & 4 &\ hhline{~*8{|-}|}
4 & & & & & & 1 & 1 & 2 \ hhline{~*8{|-}|}
5 & 3 & & color{blue}textbf{?} & & color{blue}textbf{?} & 3 & & 0 \ hhline{~*8{|-}|}
6 & & color{blue}textbf{?} & 2 & & 4 & &color{blue}textbf{?} & \ hhline{~*8{|-}|}
end{tabular}
Thanks!
tables
New contributor
Can anybody help me? I know how to build the table but I don’t know how to add the “Users” and “Movies” labels.
This is what I've tried so far:
begin{table}[H]
centering
text{ textbf{Movies}}
begin{tabular}{c | c | c | c | c | c | c | c | c | }
multicolumn{1}{c}{} & multicolumn{1}{c}{1} & multicolumn{1}{c}{2}
& multicolumn{1}{c}{3} & multicolumn{1}{c}{4} & multicolumn{1}{c}{5}
& multicolumn{1}{c}{6} & multicolumn{1}{c}{7} & multicolumn{1}{c}{8} \ hhline{~*8{|-}|}
1 & & 5 & & 2 & 4 & & & \ hhline{~*8{|-}|}
2 & 4 & & 3 & 1 & & & 3 & \ hhline{~*8{|-}|}
3 & & 5 & 4 & & 5 & & 4 &\ hhline{~*8{|-}|}
4 & & & & & & 1 & 1 & 2 \ hhline{~*8{|-}|}
5 & 3 & & color{blue}textbf{?} & & color{blue}textbf{?} & 3 & & 0 \ hhline{~*8{|-}|}
6 & & color{blue}textbf{?} & 2 & & 4 & &color{blue}textbf{?} & \ hhline{~*8{|-}|}
end{tabular}
Thanks!
tables
tables
New contributor
New contributor
edited 39 mins ago
naveganteX
New contributor
asked 53 mins ago
naveganteXnaveganteX
183
183
New contributor
New contributor
You can have it withmultirow
andmulticolumn
, but I'd use TikZ for that. Anyway: what have you tried so far? Please add a minimal code.
– JouleV
49 mins ago
` begin{tabular}{c | c | c | c | c | c | c | c | c | } multicolumn{1}{c}{} & multicolumn{1}{c}{1} & multicolumn{1}{c}{2} & multicolumn{1}{c}{3} & multicolumn{1}{c}{4} & multicolumn{1}{c}{5} & multicolumn{1}{c}{6} & multicolumn{1}{c}{7} & multicolumn{1}{c}{8} \ hhline{~*8{|-}|} 1 & & 5 & & 2 & 4 & & & \ hhline{~*8{|-}|} 2 & 4 & & 3 & 1 & & & 3 & \ hhline{~*8{|-}|} 3 & & 5 & 4 & & 5 & & 4 &\ hhline{~*8{|-}|} 4 & & & & & & 1 & 1 & 2 \ hhline{~*8{|-}|} 5 & 3 & & color{blue}textbf{?} & & color{blue}textbf{?} & 3 & & 0 `
– naveganteX
44 mins ago
@JouleV I have added the code!
– naveganteX
38 mins ago
add a comment |
You can have it withmultirow
andmulticolumn
, but I'd use TikZ for that. Anyway: what have you tried so far? Please add a minimal code.
– JouleV
49 mins ago
` begin{tabular}{c | c | c | c | c | c | c | c | c | } multicolumn{1}{c}{} & multicolumn{1}{c}{1} & multicolumn{1}{c}{2} & multicolumn{1}{c}{3} & multicolumn{1}{c}{4} & multicolumn{1}{c}{5} & multicolumn{1}{c}{6} & multicolumn{1}{c}{7} & multicolumn{1}{c}{8} \ hhline{~*8{|-}|} 1 & & 5 & & 2 & 4 & & & \ hhline{~*8{|-}|} 2 & 4 & & 3 & 1 & & & 3 & \ hhline{~*8{|-}|} 3 & & 5 & 4 & & 5 & & 4 &\ hhline{~*8{|-}|} 4 & & & & & & 1 & 1 & 2 \ hhline{~*8{|-}|} 5 & 3 & & color{blue}textbf{?} & & color{blue}textbf{?} & 3 & & 0 `
– naveganteX
44 mins ago
@JouleV I have added the code!
– naveganteX
38 mins ago
You can have it with
multirow
and multicolumn
, but I'd use TikZ for that. Anyway: what have you tried so far? Please add a minimal code.– JouleV
49 mins ago
You can have it with
multirow
and multicolumn
, but I'd use TikZ for that. Anyway: what have you tried so far? Please add a minimal code.– JouleV
49 mins ago
` begin{tabular}{c | c | c | c | c | c | c | c | c | } multicolumn{1}{c}{} & multicolumn{1}{c}{1} & multicolumn{1}{c}{2} & multicolumn{1}{c}{3} & multicolumn{1}{c}{4} & multicolumn{1}{c}{5} & multicolumn{1}{c}{6} & multicolumn{1}{c}{7} & multicolumn{1}{c}{8} \ hhline{~*8{|-}|} 1 & & 5 & & 2 & 4 & & & \ hhline{~*8{|-}|} 2 & 4 & & 3 & 1 & & & 3 & \ hhline{~*8{|-}|} 3 & & 5 & 4 & & 5 & & 4 &\ hhline{~*8{|-}|} 4 & & & & & & 1 & 1 & 2 \ hhline{~*8{|-}|} 5 & 3 & & color{blue}textbf{?} & & color{blue}textbf{?} & 3 & & 0 `
– naveganteX
44 mins ago
` begin{tabular}{c | c | c | c | c | c | c | c | c | } multicolumn{1}{c}{} & multicolumn{1}{c}{1} & multicolumn{1}{c}{2} & multicolumn{1}{c}{3} & multicolumn{1}{c}{4} & multicolumn{1}{c}{5} & multicolumn{1}{c}{6} & multicolumn{1}{c}{7} & multicolumn{1}{c}{8} \ hhline{~*8{|-}|} 1 & & 5 & & 2 & 4 & & & \ hhline{~*8{|-}|} 2 & 4 & & 3 & 1 & & & 3 & \ hhline{~*8{|-}|} 3 & & 5 & 4 & & 5 & & 4 &\ hhline{~*8{|-}|} 4 & & & & & & 1 & 1 & 2 \ hhline{~*8{|-}|} 5 & 3 & & color{blue}textbf{?} & & color{blue}textbf{?} & 3 & & 0 `
– naveganteX
44 mins ago
@JouleV I have added the code!
– naveganteX
38 mins ago
@JouleV I have added the code!
– naveganteX
38 mins ago
add a comment |
2 Answers
2
active
oldest
votes
This is my recommended version, which doesn't use any tables at all, but a powerful tool called TikZ:
documentclass[tikz]{standalone}
usetikzlibrary{matrix}
begin{document}
sffamily
begin{tikzpicture}
matrix (m) [matrix of nodes,nodes in empty cells,nodes={minimum size=.75cm,anchor=center}] {%
& 5 & & 2 & 4 & & & \
4 & & 3 & 1 & & & 3 & \
& 5 & 4 & & 5 & & 4 &\
& & & & & 1 & 1 & 2 \
3 & & color{blue}textbf{?} & & color{blue}textbf{?} & 3 & & 0 \
& color{blue}textbf{?} & 2 & & 4 & &color{blue}textbf{?} & \
};
draw[step=0.75] (m-1-1.north west) grid (m-6-8.south east);
begin{scope}[font=scriptsize]
foreach i in {1,...,8} path (m-1-i.north) node[above] {i};
foreach i in {1,...,6} path (m-i-1.west) node[left] {i};
end{scope}
path (m-1-5.north west) node[above=1em] {Movies};
path (m-3-1.south west) node[left=1em] {Users};
end{tikzpicture}
end{document}
I don't nest tables, but use a multirow
to center "Movies" and "Users":
documentclass{article}
usepackage{xcolor}
usepackage{array}
usepackage{multirow}
renewcommandarraystretch{1.5}
begin{document}
sffamily
begin{tabular}{cc|c|c|c|c|c|c|c|c|}
&multicolumn{1}{c}{} & multicolumn{8}{c}{Movies}\
&multicolumn{1}{c}{} & multicolumn{1}{c}{1} & multicolumn{1}{c}{2}
& multicolumn{1}{c}{3} & multicolumn{1}{c}{4} & multicolumn{1}{c}{5}
& multicolumn{1}{c}{6} & multicolumn{1}{c}{7} & multicolumn{1}{c}{8} \ cline{3-10}
multirow{6}{*}{Users}&1 & & 5 & & 2 & 4 & & & \ cline{3-10}
&2 & 4 & & 3 & 1 & & & 3 & \ cline{3-10}
&3 & & 5 & 4 & & 5 & & 4 &\ cline{3-10}
&4 & & & & & & 1 & 1 & 2 \ cline{3-10}
&5 & 3 & & color{blue}textbf{?} & & color{blue}textbf{?} & 3 & & 0 \ cline{3-10}
&6 & & color{blue}textbf{?} & 2 & & 4 & &color{blue}textbf{?} & \ cline{3-10}
end{tabular}
end{document}
You are the man! Thank you so much! I had heard about TikZ but I didn't know it had these capabilities!
– naveganteX
30 mins ago
@naveganteX and it can do much more. Welcome to TeX.SE!
– JouleV
29 mins ago
add a comment |
You can nest tables.
documentclass{beamer}
usepackage{xcolor}
usepackage{array}
usepackage{hhline}
begin{document}
begin{frame}[t]
frametitle{Tables can be nested}
begin{tabular}{cc}
& Movies\
Users&
begin{tabular}{c | c | c | c | c | c | c | c | c | }
multicolumn{1}{c}{} & multicolumn{1}{c}{1} & multicolumn{1}{c}{2}
& multicolumn{1}{c}{3} & multicolumn{1}{c}{4} & multicolumn{1}{c}{5}
& multicolumn{1}{c}{6} & multicolumn{1}{c}{7} & multicolumn{1}{c}{8} \ hhline{~*8{|-}|}
1 & & 5 & & 2 & 4 & & & \ hhline{~*8{|-}|}
2 & 4 & & 3 & 1 & & & 3 & \ hhline{~*8{|-}|}
3 & & 5 & 4 & & 5 & & 4 &\ hhline{~*8{|-}|}
4 & & & & & & 1 & 1 & 2 \ hhline{~*8{|-}|}
5 & 3 & & color{blue}textbf{?} & & color{blue}textbf{?} & 3 & & 0 \ hhline{~*8{|-}|}
6 & & color{blue}textbf{?} & 2 & & 4 & &color{blue}textbf{?} & \ hhline{~*8{|-}|}
end{tabular}
end{tabular}
end{frame}
end{document}
Thank you very much!
– naveganteX
28 mins 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
});
}
});
naveganteX is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
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%2f484051%2fadding-labels-to-a-table-columns-and-rows%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
This is my recommended version, which doesn't use any tables at all, but a powerful tool called TikZ:
documentclass[tikz]{standalone}
usetikzlibrary{matrix}
begin{document}
sffamily
begin{tikzpicture}
matrix (m) [matrix of nodes,nodes in empty cells,nodes={minimum size=.75cm,anchor=center}] {%
& 5 & & 2 & 4 & & & \
4 & & 3 & 1 & & & 3 & \
& 5 & 4 & & 5 & & 4 &\
& & & & & 1 & 1 & 2 \
3 & & color{blue}textbf{?} & & color{blue}textbf{?} & 3 & & 0 \
& color{blue}textbf{?} & 2 & & 4 & &color{blue}textbf{?} & \
};
draw[step=0.75] (m-1-1.north west) grid (m-6-8.south east);
begin{scope}[font=scriptsize]
foreach i in {1,...,8} path (m-1-i.north) node[above] {i};
foreach i in {1,...,6} path (m-i-1.west) node[left] {i};
end{scope}
path (m-1-5.north west) node[above=1em] {Movies};
path (m-3-1.south west) node[left=1em] {Users};
end{tikzpicture}
end{document}
I don't nest tables, but use a multirow
to center "Movies" and "Users":
documentclass{article}
usepackage{xcolor}
usepackage{array}
usepackage{multirow}
renewcommandarraystretch{1.5}
begin{document}
sffamily
begin{tabular}{cc|c|c|c|c|c|c|c|c|}
&multicolumn{1}{c}{} & multicolumn{8}{c}{Movies}\
&multicolumn{1}{c}{} & multicolumn{1}{c}{1} & multicolumn{1}{c}{2}
& multicolumn{1}{c}{3} & multicolumn{1}{c}{4} & multicolumn{1}{c}{5}
& multicolumn{1}{c}{6} & multicolumn{1}{c}{7} & multicolumn{1}{c}{8} \ cline{3-10}
multirow{6}{*}{Users}&1 & & 5 & & 2 & 4 & & & \ cline{3-10}
&2 & 4 & & 3 & 1 & & & 3 & \ cline{3-10}
&3 & & 5 & 4 & & 5 & & 4 &\ cline{3-10}
&4 & & & & & & 1 & 1 & 2 \ cline{3-10}
&5 & 3 & & color{blue}textbf{?} & & color{blue}textbf{?} & 3 & & 0 \ cline{3-10}
&6 & & color{blue}textbf{?} & 2 & & 4 & &color{blue}textbf{?} & \ cline{3-10}
end{tabular}
end{document}
You are the man! Thank you so much! I had heard about TikZ but I didn't know it had these capabilities!
– naveganteX
30 mins ago
@naveganteX and it can do much more. Welcome to TeX.SE!
– JouleV
29 mins ago
add a comment |
This is my recommended version, which doesn't use any tables at all, but a powerful tool called TikZ:
documentclass[tikz]{standalone}
usetikzlibrary{matrix}
begin{document}
sffamily
begin{tikzpicture}
matrix (m) [matrix of nodes,nodes in empty cells,nodes={minimum size=.75cm,anchor=center}] {%
& 5 & & 2 & 4 & & & \
4 & & 3 & 1 & & & 3 & \
& 5 & 4 & & 5 & & 4 &\
& & & & & 1 & 1 & 2 \
3 & & color{blue}textbf{?} & & color{blue}textbf{?} & 3 & & 0 \
& color{blue}textbf{?} & 2 & & 4 & &color{blue}textbf{?} & \
};
draw[step=0.75] (m-1-1.north west) grid (m-6-8.south east);
begin{scope}[font=scriptsize]
foreach i in {1,...,8} path (m-1-i.north) node[above] {i};
foreach i in {1,...,6} path (m-i-1.west) node[left] {i};
end{scope}
path (m-1-5.north west) node[above=1em] {Movies};
path (m-3-1.south west) node[left=1em] {Users};
end{tikzpicture}
end{document}
I don't nest tables, but use a multirow
to center "Movies" and "Users":
documentclass{article}
usepackage{xcolor}
usepackage{array}
usepackage{multirow}
renewcommandarraystretch{1.5}
begin{document}
sffamily
begin{tabular}{cc|c|c|c|c|c|c|c|c|}
&multicolumn{1}{c}{} & multicolumn{8}{c}{Movies}\
&multicolumn{1}{c}{} & multicolumn{1}{c}{1} & multicolumn{1}{c}{2}
& multicolumn{1}{c}{3} & multicolumn{1}{c}{4} & multicolumn{1}{c}{5}
& multicolumn{1}{c}{6} & multicolumn{1}{c}{7} & multicolumn{1}{c}{8} \ cline{3-10}
multirow{6}{*}{Users}&1 & & 5 & & 2 & 4 & & & \ cline{3-10}
&2 & 4 & & 3 & 1 & & & 3 & \ cline{3-10}
&3 & & 5 & 4 & & 5 & & 4 &\ cline{3-10}
&4 & & & & & & 1 & 1 & 2 \ cline{3-10}
&5 & 3 & & color{blue}textbf{?} & & color{blue}textbf{?} & 3 & & 0 \ cline{3-10}
&6 & & color{blue}textbf{?} & 2 & & 4 & &color{blue}textbf{?} & \ cline{3-10}
end{tabular}
end{document}
You are the man! Thank you so much! I had heard about TikZ but I didn't know it had these capabilities!
– naveganteX
30 mins ago
@naveganteX and it can do much more. Welcome to TeX.SE!
– JouleV
29 mins ago
add a comment |
This is my recommended version, which doesn't use any tables at all, but a powerful tool called TikZ:
documentclass[tikz]{standalone}
usetikzlibrary{matrix}
begin{document}
sffamily
begin{tikzpicture}
matrix (m) [matrix of nodes,nodes in empty cells,nodes={minimum size=.75cm,anchor=center}] {%
& 5 & & 2 & 4 & & & \
4 & & 3 & 1 & & & 3 & \
& 5 & 4 & & 5 & & 4 &\
& & & & & 1 & 1 & 2 \
3 & & color{blue}textbf{?} & & color{blue}textbf{?} & 3 & & 0 \
& color{blue}textbf{?} & 2 & & 4 & &color{blue}textbf{?} & \
};
draw[step=0.75] (m-1-1.north west) grid (m-6-8.south east);
begin{scope}[font=scriptsize]
foreach i in {1,...,8} path (m-1-i.north) node[above] {i};
foreach i in {1,...,6} path (m-i-1.west) node[left] {i};
end{scope}
path (m-1-5.north west) node[above=1em] {Movies};
path (m-3-1.south west) node[left=1em] {Users};
end{tikzpicture}
end{document}
I don't nest tables, but use a multirow
to center "Movies" and "Users":
documentclass{article}
usepackage{xcolor}
usepackage{array}
usepackage{multirow}
renewcommandarraystretch{1.5}
begin{document}
sffamily
begin{tabular}{cc|c|c|c|c|c|c|c|c|}
&multicolumn{1}{c}{} & multicolumn{8}{c}{Movies}\
&multicolumn{1}{c}{} & multicolumn{1}{c}{1} & multicolumn{1}{c}{2}
& multicolumn{1}{c}{3} & multicolumn{1}{c}{4} & multicolumn{1}{c}{5}
& multicolumn{1}{c}{6} & multicolumn{1}{c}{7} & multicolumn{1}{c}{8} \ cline{3-10}
multirow{6}{*}{Users}&1 & & 5 & & 2 & 4 & & & \ cline{3-10}
&2 & 4 & & 3 & 1 & & & 3 & \ cline{3-10}
&3 & & 5 & 4 & & 5 & & 4 &\ cline{3-10}
&4 & & & & & & 1 & 1 & 2 \ cline{3-10}
&5 & 3 & & color{blue}textbf{?} & & color{blue}textbf{?} & 3 & & 0 \ cline{3-10}
&6 & & color{blue}textbf{?} & 2 & & 4 & &color{blue}textbf{?} & \ cline{3-10}
end{tabular}
end{document}
This is my recommended version, which doesn't use any tables at all, but a powerful tool called TikZ:
documentclass[tikz]{standalone}
usetikzlibrary{matrix}
begin{document}
sffamily
begin{tikzpicture}
matrix (m) [matrix of nodes,nodes in empty cells,nodes={minimum size=.75cm,anchor=center}] {%
& 5 & & 2 & 4 & & & \
4 & & 3 & 1 & & & 3 & \
& 5 & 4 & & 5 & & 4 &\
& & & & & 1 & 1 & 2 \
3 & & color{blue}textbf{?} & & color{blue}textbf{?} & 3 & & 0 \
& color{blue}textbf{?} & 2 & & 4 & &color{blue}textbf{?} & \
};
draw[step=0.75] (m-1-1.north west) grid (m-6-8.south east);
begin{scope}[font=scriptsize]
foreach i in {1,...,8} path (m-1-i.north) node[above] {i};
foreach i in {1,...,6} path (m-i-1.west) node[left] {i};
end{scope}
path (m-1-5.north west) node[above=1em] {Movies};
path (m-3-1.south west) node[left=1em] {Users};
end{tikzpicture}
end{document}
I don't nest tables, but use a multirow
to center "Movies" and "Users":
documentclass{article}
usepackage{xcolor}
usepackage{array}
usepackage{multirow}
renewcommandarraystretch{1.5}
begin{document}
sffamily
begin{tabular}{cc|c|c|c|c|c|c|c|c|}
&multicolumn{1}{c}{} & multicolumn{8}{c}{Movies}\
&multicolumn{1}{c}{} & multicolumn{1}{c}{1} & multicolumn{1}{c}{2}
& multicolumn{1}{c}{3} & multicolumn{1}{c}{4} & multicolumn{1}{c}{5}
& multicolumn{1}{c}{6} & multicolumn{1}{c}{7} & multicolumn{1}{c}{8} \ cline{3-10}
multirow{6}{*}{Users}&1 & & 5 & & 2 & 4 & & & \ cline{3-10}
&2 & 4 & & 3 & 1 & & & 3 & \ cline{3-10}
&3 & & 5 & 4 & & 5 & & 4 &\ cline{3-10}
&4 & & & & & & 1 & 1 & 2 \ cline{3-10}
&5 & 3 & & color{blue}textbf{?} & & color{blue}textbf{?} & 3 & & 0 \ cline{3-10}
&6 & & color{blue}textbf{?} & 2 & & 4 & &color{blue}textbf{?} & \ cline{3-10}
end{tabular}
end{document}
edited 7 mins ago
answered 32 mins ago
JouleVJouleV
12.1k22662
12.1k22662
You are the man! Thank you so much! I had heard about TikZ but I didn't know it had these capabilities!
– naveganteX
30 mins ago
@naveganteX and it can do much more. Welcome to TeX.SE!
– JouleV
29 mins ago
add a comment |
You are the man! Thank you so much! I had heard about TikZ but I didn't know it had these capabilities!
– naveganteX
30 mins ago
@naveganteX and it can do much more. Welcome to TeX.SE!
– JouleV
29 mins ago
You are the man! Thank you so much! I had heard about TikZ but I didn't know it had these capabilities!
– naveganteX
30 mins ago
You are the man! Thank you so much! I had heard about TikZ but I didn't know it had these capabilities!
– naveganteX
30 mins ago
@naveganteX and it can do much more. Welcome to TeX.SE!
– JouleV
29 mins ago
@naveganteX and it can do much more. Welcome to TeX.SE!
– JouleV
29 mins ago
add a comment |
You can nest tables.
documentclass{beamer}
usepackage{xcolor}
usepackage{array}
usepackage{hhline}
begin{document}
begin{frame}[t]
frametitle{Tables can be nested}
begin{tabular}{cc}
& Movies\
Users&
begin{tabular}{c | c | c | c | c | c | c | c | c | }
multicolumn{1}{c}{} & multicolumn{1}{c}{1} & multicolumn{1}{c}{2}
& multicolumn{1}{c}{3} & multicolumn{1}{c}{4} & multicolumn{1}{c}{5}
& multicolumn{1}{c}{6} & multicolumn{1}{c}{7} & multicolumn{1}{c}{8} \ hhline{~*8{|-}|}
1 & & 5 & & 2 & 4 & & & \ hhline{~*8{|-}|}
2 & 4 & & 3 & 1 & & & 3 & \ hhline{~*8{|-}|}
3 & & 5 & 4 & & 5 & & 4 &\ hhline{~*8{|-}|}
4 & & & & & & 1 & 1 & 2 \ hhline{~*8{|-}|}
5 & 3 & & color{blue}textbf{?} & & color{blue}textbf{?} & 3 & & 0 \ hhline{~*8{|-}|}
6 & & color{blue}textbf{?} & 2 & & 4 & &color{blue}textbf{?} & \ hhline{~*8{|-}|}
end{tabular}
end{tabular}
end{frame}
end{document}
Thank you very much!
– naveganteX
28 mins ago
add a comment |
You can nest tables.
documentclass{beamer}
usepackage{xcolor}
usepackage{array}
usepackage{hhline}
begin{document}
begin{frame}[t]
frametitle{Tables can be nested}
begin{tabular}{cc}
& Movies\
Users&
begin{tabular}{c | c | c | c | c | c | c | c | c | }
multicolumn{1}{c}{} & multicolumn{1}{c}{1} & multicolumn{1}{c}{2}
& multicolumn{1}{c}{3} & multicolumn{1}{c}{4} & multicolumn{1}{c}{5}
& multicolumn{1}{c}{6} & multicolumn{1}{c}{7} & multicolumn{1}{c}{8} \ hhline{~*8{|-}|}
1 & & 5 & & 2 & 4 & & & \ hhline{~*8{|-}|}
2 & 4 & & 3 & 1 & & & 3 & \ hhline{~*8{|-}|}
3 & & 5 & 4 & & 5 & & 4 &\ hhline{~*8{|-}|}
4 & & & & & & 1 & 1 & 2 \ hhline{~*8{|-}|}
5 & 3 & & color{blue}textbf{?} & & color{blue}textbf{?} & 3 & & 0 \ hhline{~*8{|-}|}
6 & & color{blue}textbf{?} & 2 & & 4 & &color{blue}textbf{?} & \ hhline{~*8{|-}|}
end{tabular}
end{tabular}
end{frame}
end{document}
Thank you very much!
– naveganteX
28 mins ago
add a comment |
You can nest tables.
documentclass{beamer}
usepackage{xcolor}
usepackage{array}
usepackage{hhline}
begin{document}
begin{frame}[t]
frametitle{Tables can be nested}
begin{tabular}{cc}
& Movies\
Users&
begin{tabular}{c | c | c | c | c | c | c | c | c | }
multicolumn{1}{c}{} & multicolumn{1}{c}{1} & multicolumn{1}{c}{2}
& multicolumn{1}{c}{3} & multicolumn{1}{c}{4} & multicolumn{1}{c}{5}
& multicolumn{1}{c}{6} & multicolumn{1}{c}{7} & multicolumn{1}{c}{8} \ hhline{~*8{|-}|}
1 & & 5 & & 2 & 4 & & & \ hhline{~*8{|-}|}
2 & 4 & & 3 & 1 & & & 3 & \ hhline{~*8{|-}|}
3 & & 5 & 4 & & 5 & & 4 &\ hhline{~*8{|-}|}
4 & & & & & & 1 & 1 & 2 \ hhline{~*8{|-}|}
5 & 3 & & color{blue}textbf{?} & & color{blue}textbf{?} & 3 & & 0 \ hhline{~*8{|-}|}
6 & & color{blue}textbf{?} & 2 & & 4 & &color{blue}textbf{?} & \ hhline{~*8{|-}|}
end{tabular}
end{tabular}
end{frame}
end{document}
You can nest tables.
documentclass{beamer}
usepackage{xcolor}
usepackage{array}
usepackage{hhline}
begin{document}
begin{frame}[t]
frametitle{Tables can be nested}
begin{tabular}{cc}
& Movies\
Users&
begin{tabular}{c | c | c | c | c | c | c | c | c | }
multicolumn{1}{c}{} & multicolumn{1}{c}{1} & multicolumn{1}{c}{2}
& multicolumn{1}{c}{3} & multicolumn{1}{c}{4} & multicolumn{1}{c}{5}
& multicolumn{1}{c}{6} & multicolumn{1}{c}{7} & multicolumn{1}{c}{8} \ hhline{~*8{|-}|}
1 & & 5 & & 2 & 4 & & & \ hhline{~*8{|-}|}
2 & 4 & & 3 & 1 & & & 3 & \ hhline{~*8{|-}|}
3 & & 5 & 4 & & 5 & & 4 &\ hhline{~*8{|-}|}
4 & & & & & & 1 & 1 & 2 \ hhline{~*8{|-}|}
5 & 3 & & color{blue}textbf{?} & & color{blue}textbf{?} & 3 & & 0 \ hhline{~*8{|-}|}
6 & & color{blue}textbf{?} & 2 & & 4 & &color{blue}textbf{?} & \ hhline{~*8{|-}|}
end{tabular}
end{tabular}
end{frame}
end{document}
answered 31 mins ago
marmotmarmot
116k5149281
116k5149281
Thank you very much!
– naveganteX
28 mins ago
add a comment |
Thank you very much!
– naveganteX
28 mins ago
Thank you very much!
– naveganteX
28 mins ago
Thank you very much!
– naveganteX
28 mins ago
add a comment |
naveganteX is a new contributor. Be nice, and check out our Code of Conduct.
naveganteX is a new contributor. Be nice, and check out our Code of Conduct.
naveganteX is a new contributor. Be nice, and check out our Code of Conduct.
naveganteX is a new contributor. Be nice, and check out our Code of Conduct.
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');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
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%2f484051%2fadding-labels-to-a-table-columns-and-rows%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
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');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
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');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
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
You can have it with
multirow
andmulticolumn
, but I'd use TikZ for that. Anyway: what have you tried so far? Please add a minimal code.– JouleV
49 mins ago
` begin{tabular}{c | c | c | c | c | c | c | c | c | } multicolumn{1}{c}{} & multicolumn{1}{c}{1} & multicolumn{1}{c}{2} & multicolumn{1}{c}{3} & multicolumn{1}{c}{4} & multicolumn{1}{c}{5} & multicolumn{1}{c}{6} & multicolumn{1}{c}{7} & multicolumn{1}{c}{8} \ hhline{~*8{|-}|} 1 & & 5 & & 2 & 4 & & & \ hhline{~*8{|-}|} 2 & 4 & & 3 & 1 & & & 3 & \ hhline{~*8{|-}|} 3 & & 5 & 4 & & 5 & & 4 &\ hhline{~*8{|-}|} 4 & & & & & & 1 & 1 & 2 \ hhline{~*8{|-}|} 5 & 3 & & color{blue}textbf{?} & & color{blue}textbf{?} & 3 & & 0 `
– naveganteX
44 mins ago
@JouleV I have added the code!
– naveganteX
38 mins ago