How to code this kind of table? The code for the table is easy for me but I don't know how to put a box in the upper right in every column. Thank you.
I found a way to add a box in the upper right corner, by adding additional columns (one left and one right for symmetry reasons) and rows to the table.
This is my solution, though they are propably more elegant ways to achive this:
\documentclass{article}
\usepackage{array}
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
\begin{document}
\begin{table}
\centering
\begin{tabular}{|c P{15mm} c|c P{15mm}c|cP{15mm}c|cP{15mm}c|c P{15mm}c|}
\hline
& & & & & & & & & & & & & & \\
& & & & A & & & B & & & C & & & Capacity & \\
& & & & & & & & & &
& & & & \\
\hline
& & & & & \multicolumn{1}{|c|}{5} & & & \multicolumn{1}{|c|}{4} & & & \multicolumn{1}{|c|}{3} & & & \\ \cline{6-6} \cline{9-9} \cline{12-12}
& D & & & & & & & & & & & & 100 & \\
& & & & & & & & & & & & & & \\
\hline
& & & & & \multicolumn{1}{|c|}{8} & & & \multicolumn{1}{|c|}{4} & & & \multicolumn{1}{|c|}{3} & & & \\ \cline{6-6} \cline{9-9} \cline{12-12}
& E & & & & & & & & & & & & 300 & \\
& & & & & & & & & & & & & & \\
\hline
& & & & & \multicolumn{1}{|c|}{9} & & & \multicolumn{1}{|c|}{7} & & & \multicolumn{1}{|c|}{5} & & & \\ \cline{6-6} \cline{9-9} \cline{12-12}
& F & & & & & & & & & & & & 300 & \\
& & & & & & & & & & & & & & \\
\hline
\end{tabular}
\end{table}
\end{document}
This is the output:
Related
The verticle line in the third column has 2 gaps. How do I do I make it look full?
Here's the code:
\begin{table}[H]
\centering
\caption{Enzymatic cocktails and the respective tested concentrations in \%(v/v) used in Combined Hydrolysis}
\label{enzymatic cocktails}
\begin{tabular}{#{}ccc#{}}
\toprule
\textbf{Cocktail} & \textbf{Enzymes} & \textbf{Concentration \%(v/v)} \\ \midrule
\multirow{2}{*}{A} & \multicolumn{1}{c|}{Cellulase} & \multirow{8}{*}{\begin{tabular}[c]{#{}c#{}}0.25\\ 0.50\\ 1.00\end{tabular}} \\
& \multicolumn{1}{c|}{$\boldsymbol{\beta}$-glucosidase} & \\ \cmidrule(r){1-2}
\multirow{3}{*}{B} & \multicolumn{1}{c|}{Cellulase} & \\
& \multicolumn{1}{c|}{$\boldsymbol{\beta}$-glucosidase} & \\
& \multicolumn{1}{c|}{xylanase} & \\ \cmidrule(r){1-2}
\multirow{3}{*}{C} & \multicolumn{1}{c|}{Cellulase} & \\
& \multicolumn{1}{c|}{$\boldsymbol{\beta}$-glucosidase} & \\
& \multicolumn{1}{c|}{$\boldsymbol{\beta}$-glucanase and xylanase} & \\ \bottomrule
\end{tabular}
\end{table}
Vertical lines like in c| and horizontal lines such as toprule, bottomrule, midrule, cmidrule from the package booktabs do not match.
\documentclass{article}
\usepackage{multirow}
\begin{document}
\begin{table}%[H]
\centering
\caption{Enzymatic cocktails and the respective tested concentrations in \%(v/v) used in Combined Hydrolysis}
\label{enzymatic_cocktails}
\begin{tabular}{#{}ccc#{}}
\hline
\textbf{Cocktail} & \textbf{Enzymes} & \textbf{Concentration \%(v/v)}\\
\hline
\multirow{2}{*}{A} & \multicolumn{1}{c|}{Cellulase} & %
\multirow{8}{*}{\begin{tabular}[c]{#{}c#{}}0.25\\ 0.50\\ 1.00\end{tabular}}\\
& \multicolumn{1}{c|}{$\mathbb{\beta}$-glucosidase} & \\
\cline{1-2}
\multirow{3}{*}{B} & \multicolumn{1}{c|}{Cellulase} & \\
& \multicolumn{1}{c|}{$\boldsymbol{\beta}$-glucosidase} & \\
& \multicolumn{1}{c|}{xylanase} & \\
\cline{1-2}
\multirow{3}{*}{C} & \multicolumn{1}{c|}{Cellulase} & \\
& \multicolumn{1}{c|}{$\mathbb{\beta}$-glucosidase} & \\
& \multicolumn{1}{c|}{$\mathbb{\beta}$-glucanase and xylanase} & \\
\hline
\end{tabular}
\end{table}
\end{document}
So I went back to hlines in my code. Better would be to use the above mentioned package booktabs and avoid vertical lines instead.
This code:
\subsection*{4.1 1NF}
No, this table is not in 1NF as column Info can and on multiple rows hold multiple values. 1NF Variation would be:
\par
\begin{table}[]
\begin{tabular}{|l|l|l|l|l|l|}
\hline
{\ul \textbf{Student\_ID}} & \textbf{First Name} & \textbf{Last Name} & \textbf{Course} & \textbf{Credits} & \textbf{Grade} \\ \hline
1 & Adam & Brown & Databases & 5 & 8 \\ \hline
1 & Adam & Brown & Algebra & 3 & 7 \\ \hline
1 & Adam & Brown & Algorithms & 5 & 9 \\ \hline
2 & Felicia & Green & Algebra & 3 & 10 \\ \hline
2 & Felicia & Green & Programming & 5 & 6 \\ \hline
3 & Mary & Grey & Databases & 5 & 9 \\ \hline
3 & Mary & Grey & Algorithms & 5 & 7 \\ \hline
3 & Mary & Grey & Web & 3 & 10 \\ \hline
1 & Adam & Brown & Physics & 3 & 10 \\ \hline
\end{tabular}
\end{table}
Produces this result:
Rednder of the LaTeX code above
But I need the table to be after the text.
Can someone tell me what am I doing wrong?
You're missing a floating specifier, e.g. to allow the table [h]ere, at the [t]op, at the [b]ottom or on a separate [p]age:
\begin{table}[htbp]
I a trying to put a table in my report. I want to place it in the middle of the page.
but it is shifted to the right side. How can I fix it? (I am using overleaf)
I really appreciate it if anyone could help me to fix the problem.
This is the code:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{floatrow}
\floatsetup[table]{capposition=top}
\usepackage{natbib}
\usepackage{graphicx}
\usepackage{adjustbox}
\usepackage{tabularx}
\usepackage{caption}
\begin{table}[p]
\centering
\small
\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|}
\hline
\textbf{Sub fault} & \textbf{Lat} & \textbf{Lon} & \textbf{\begin{tabular}[c]{#{}c#{}}Depth\\ (Km)\end{tabular}} & \textbf{\begin{tabular}[c]{#{}c#{}}Strike\\ (Deg.)\end{tabular}} & \textbf{\begin{tabular}[c]{#{}c#{}}Dip \\ (Deg.)\end{tabular}} & \textbf{\begin{tabular}[c]{#{}c#{}}Length\\ (Km)\end{tabular}} & \textbf{\begin{tabular}[c]{#{}c#{}}Width\\ (Km)\end{tabular}} & \textbf{\begin{tabular}[c]{#{}c#{}}Rake \\ (Deg.)\end{tabular}} & \textbf{\begin{tabular}[c]{#{}c#{}}Slip (m)\\ Mw=9.0\end{tabular}} \\ \hline
\textbf{1} & 18.9848 & -65.6921 & 22.1 & 89.59 & 20 & 100 & 50 & 90 & 7.4 \\ \hline
\textbf{2} & 19.4069 & -65.6953 & 5 & 89.59 & 20 & 100 & 50 & 90 & 7.4 \\ \hline
\textbf{3} & 18.9484 & -66.5742 & 22.1 & 84.98 & 20 & 100 & 50 & 90 & 7.4 \\ \hline
\textbf{4} & 19.3688 & -66.6133 & 5 & 84.98 & 20 & 100 & 50 & 90 & 7.4 \\ \hline
\textbf{5} & 18.8738 & -67.5412 & 22.1 & 85.87 & 20 & 100 & 50 & 90 & 7.4 \\ \hline
\textbf{6} & 19.2948 & -67.5734 & 5 & 85.87 & 20 & 100 & 50 & 90 & 7.4 \\ \hline
\textbf{7} & 18.7853 & -68.4547 & 22.1 & 83.64 & 20 & 100 & 50 & 90 & 7.4 \\ \hline
\textbf{8} & 19.2048 & -68.5042 & 5 & 83.64 & 20 & 100 & 50 & 90 & 7.4 \\ \hline
\textbf{9} & 18.8870 & -63.8800 & 22.1 & 95.37 & 20 & 100 & 50 & 90 & 7.4 \\ \hline
\textbf{10} & 19.3072 & -63.8382 & 5 & 95.37 & 20 & 100 & 50 & 90 & 7.4 \\ \hline
\textbf{11} & 18.9650 & -64.8153 & 22.1 & 94.34 & 20 & 100 & 50 & 90 & 7.4 \\ \hline
\textbf{12} & 19.3859 & -64.7814 & 5 & 94.34 & 20 & 100 & 50 & 90 & 7.4 \\ \hline
\textbf{13} & 18.0566 & -61.5491 & 17.94 & 112.84 & 15 & 100 & 50 & 90 & 7.4 \\ \hline
\textbf{14} & 18.4564 & -61.3716 & 5 & 112.34 & 15 & 100 & 50 & 90 & 7.4 \\ \hline
\textbf{15} & 18.4149 & -62.4217 & 17.94 & 117.86 & 15 & 100 & 50 & 90 & 7.4 \\ \hline
\textbf{16} & 18.7985 & -62.2075 & 5 & 117.86 & 15 & 100 & 50 & 90 & 7.4 \\ \hline
\textbf{17} & 18.7844 & -63.1649 & 17.94 & 110.46 & 20 & 100 & 50 & 90 & 7.4 \\ \hline
\textbf{18} & 19.1798 & -63.0087 & 5 & 110.46 & 20 & 100 & 50 & 90 & 7.4 \\ \hline
\textbf{19} & 16.4535 & -59.9029 & 17.94 & 136.99 & 15 & 100 & 50 & 90 & 7.4 \\ \hline
\textbf{20} & 16.7494 & -59.5716 & 5 & 136.99 & 15 & 100 & 50 & 90 & 7.4 \\ \hline
\textbf{21} & 17.0903 & -60.5996 & 17.94 & 138.71 & 15 & 100 & 50 & 90 & 7.4 \\ \hline
\textbf{22} & 17.3766 & -60.2580 & 5 & 138.71 & 15 & 100 & 50 & 90 & 7.4 \\ \hline
\textbf{23} & 17.8560 & -61.1559 & 17.94 & 141.07 & 15 & 100 & 50 & 90 & 7.4 \\ \hline
\textbf{24} & 18.1286 & -60.8008 & 5 & 141.07 & 15 & 100 & 50 & 90 & 7.4 \\ \hline
\end{tabular}
\captionsetup{justification=centering}
\caption{\label{tab:table-name}source parameters for a Mw 9.0 PRT co-seismic source based on 24 sub-faults (Gica eal,2008). Corresponding surface elevation computed with Okadas (1985) method is shown in fig 3}
\end{table}
\clearpage
Your issue here is that the table is too wide to fit within the text block. As such, LaTeX pushes is against the left margin and let it overflow into the right margin. If you don't want to change anything and just centre it, you can wrap the entire tabular inside a \makebox[\linewidth]:
\begin{table}
\centering
\small
\makebox[\linewidth]{%
\begin{tabular}{| *{10}{c|} }
<your table here>
\end{tabular}%
}
\caption{<caption>}
\end{table}
For more details and options, see My table doesn't fit; what are my options?
You can try the following:
\begin{center}
\begin{tabular}{ | c | c | c | }
\hline
symbol & value & unit \\ \hline
$z Na$ & 11 & - \\ \hline
$z F$ & 9 & - \\ \hline
$Emax Na$ & 0.545 & $[MeV]$ \\ \hline
\end{tabular}
\end{center}
Refer: How to center table in latex
How are you,
I am using Google Colab to solve exercises of my university in combination with the pandas library.
According to the documentation of Colab to be able to show some formula using LATEX, you have to introduce it between two dollar signs ($) which works correctly for me. For example here an image of a part of my document that works without problems.
The drawback occurs when I try to generate a table with some values that will serve to explain the problem I am solving but are not rendered. Next I show the image of how it is rendered
As a test try to render a matrix that is the closest thing to a table and I have no problems.
Can the problem occur because Colab is not supporting or is blocking the rendering of tables?
What would be the correct way to generate a table within the text part of Google Colab?
I have found solutions for how to use LATEX in other stackoverflow responses but these solutions do not work for me since I want the table to appear in the text part of my colab document and not within the code part.
Thank you for your answers.
Use array instead of tabular. Tabular environments can be used to display tables that are typeset as text in math mode, but the most common is the use of arrays.
For some unknown reason, in google colab, array is supported and considered as a valid LaTeX command, while tabular is considered as a code sample.
\begin{array}{ccc}
foo&bar&baz\\
1&2&3
\end{array}
\begin{tabular}{ccc}
foo&bar&baz\\
1&2&3
\end{tabular}
Array enters TeX math mode and even plain text is typeset in math mode. To avoid this behavior you can use \text{my text}
\begin{array}{ccc}
\text{foo}&\text{bar}&\text{baz}\\
1&2&3
\end{array}
In co labs using latex for Big O notation, this worked for me
Math(r'\displaystyle \\
\begin{array}{|c|c|c|c|c|c|c|c|}\hline\\ \\
\mathcal{} & \mathcal{A} & \mathcal{B} & \mathcal{O} & o & \Omega & \omega & \Theta \\ \hline\\ \\
a & lg^kn & n^\epsilon & yes\; no & yes\; no & yes\; no & yes\; no & yes\; no \\ \hline\\ \\
b & n^k & c^n & yes\; no & yes\; no & yes\; no & yes\; no & yes\; no \\ \hline\\ \\
c & \sqrt{n} & n^{sin n} & yes\; no & yes\; no & yes\; no & yes\; no & yes\; no \\ \hline\\ \\
d & 2^n & 2^{n/2} & yes\; no & yes\; no & yes\; no & yes\; no & yes\; no \\ \hline\\ \\
e & n^{lg c} & c^{lg n} & yes\; no & yes\; no & yes\; no & yes\; no & yes\; no \\ \hline\\ \\
f & lg(n!) & lg(n^n) & yes\; no & yes\; no & yes\; no & yes\; no & yes\; no \\ \hline\\
\end{array}\\')
Just play around with |c| 's and \hline 's to get nice-looking tables using array in latex.
Below are a few handy templates (works in colab).
Template 1
\begin{array}{|c|c|} \hline
column1 & column2 & column3 & column4 \\ \hline
foo & bar & foo & bar \\
foo & bar & foo & bar \\
foo & bar & foo & bar \\ \hline
\end{array}
Template 2
\begin{array}{|c|} \hline
column1 & column2 & column3 & column4 \\ \hline
foo & bar & foo & bar \\
foo & bar & foo & bar \\
foo & bar & foo & bar \\ \hline
\end{array}
Template 3
\begin{array}{c} \hline
column1 & column2 & column3 & column4 \\ \hline
foo & bar & foo & bar \\
foo & bar & foo & bar \\
foo & bar & foo & bar \\ \hline
\end{array}
Template 4
\begin{array}{|c|c|} \hline
column1 & column2 & column3 & column4 \\ \hline
foo & bar & foo & bar \\ \hline
foo & bar & foo & bar \\\hline
foo & bar & foo & bar \\ \hline
\end{array}
I have the following code:
\begin{table}[ht]
\begin{center}
\begin{tabular}{ | l | l | l | l | l | l | l | }
\hline
\multirow{2}{*}{Oprava} & \multirow{2}{*}{zkratka} & \multirow{2}{*}{alg.} & chybovost \% & & & \\ \hline
& & & MAE & RSE & RMSE & RRSE \\ \hline
velikosti & vel. & NBM & & & & \\ \hline
& & c4.5 & & & & \\ \hline
& & kNN & & & & \\ \hline
& & SMO & & & & \\ \hline
bilateralne & bilat. & NBM & & & & \\ \hline
& & c4.5 & & & & \\ \hline
& & kNN & & & & \\ \hline
& & SMO & & & & \\ \hline
oprava & zkratka & NBM & & & & \\ \hline
& & c4.5 & & & & \\ \hline
& & kNN & & & & \\ \hline
& & SMO & & & & \\ \hline
oprava & zkratka & NBM & & & & \\ \hline
& & c4.5 & & & & \\ \hline
& & kNN & & & & \\ \hline
& & SMO & & & & \\ \hline
\end{tabular}
\end{center}
\caption{Multi-row table}
\label{tab:multicol}
\end{table}
And what I get is this:
I need to merge the cells, so that the text is not crossed out. The same for the rows with the repeated algorithms names - NBM, kNN etc ..... they should me merged and centered. Pls help.
Thanks
The solution to your problem is very simple. You should use \cline{4-7} instead of \hline. Namely \hline makes a horizontal line over the complete width of the table, while \cline{4-7} will only make a horizontal line from column 4 until 7, and thus not crossing the first ones.
To get the text in front of the repeated words centered and merged, you can use multirow{}{}, again in combination with \cline{}. More info about these commands at this link.
An example of the code is given below:
\begin{table}[]
\centering
\caption{My caption}
\label{my-label}
\begin{tabular}{|l|l|l|l|l|l|l|}
\hline
\multirow{2}{*}{Oprave} & \multirow{2}{*}{Zkratka} & \multirow{2}{*}{Alg.} & \multicolumn{4}{l|}{Chybovost \%} \\ \cline{4-7}
& & & MAE & RSE & RMSE & RRSE \\ \hline
\multirow{4}{*}{velikosti} & \multirow{4}{*}{vel.} & NBM & & & & \\ \cline{3-7}
& & c4.5 & & & & \\ \cline{3-7}
& & kNN & & & & \\ \cline{3-7}
& & SMO & & & & \\ \hline
\multirow{4}{*}{bilateralne} & \multirow{4}{*}{bilat.} & NBM & & & & \\ \cline{3-7}
& & c4.5 & & & & \\ \cline{3-7}
& & kNN & & & & \\ \cline{3-7}
& & SMO & & & & \\ \hline
\multirow{4}{*}{oprava} & \multirow{4}{*}{zkratka} & NBM & & & & \\ \cline{3-7}
& & c4.5 & & & & \\ \cline{3-7}
& & kNN & & & & \\ \cline{3-7}
& & SMO & & & & \\ \hline
\multirow{4}{*}{oprava} & \multirow{4}{*}{zkratka} & NBM & & & & \\ \cline{3-7}
& & c4.5 & & & & \\ \cline{3-7}
& & kNN & & & & \\ \cline{3-7}
& & SMO & & & & \\ \hline
\end{tabular}
\end{table}
Resulting into:
Note: if you have struggles with table generation, or you want a more quick way to easily make tables as you would do in Excel, you can use an online table generator for Latex.
I often use http://www.tablesgenerator.com/