How can I reproduce this table with Latex?
Some help would be appreciated.
My suggestion for this table:
\documentclass{article}
\begin{document}
Text.
\begin{table}[h]
\sffamily
\begin{tabular}{r|*{12}{r}}
& \multicolumn{12}{l}{Development year}\\
U/W year & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 \\
\hline
2001 & n & n & n & n & n & n & n & n & n & n & n & n\\
2002 & n & n & n & n & n & n & n & n & n & n & n & \\
2003 & n & n & n & n & n & n & n & n & n & n & & \\
2004 & n & n & n & n & n & n & n & n & n & & & \\
2005 & n & n & n & n & n & n & n & n & & & & \\
2006 & n & n & n & n & n & n & n & & & & & \\
2007 & n & n & n & n & n & n & & & & & & \\
2008 & n & n & n & n & n & & & & & & & \\
2009 & n & n & n & n & & & & & & & & \\
2010 & n & n & n & & & & & & & & & \\
2011 & n & n & & & & & & & & & & \\
2012 & n & & & & & & & & & & & \\
& & & & & & & & & & & & \\
\hline
link ratios: & a & b & c & d & e & f & g & h & i & j & k & %l
\end{tabular}
\end{table}
Text.
\end{document}
Within the "fine tuning", I noticed that cells in lines 2 and 3-16 are both right-aligned, but with different right margins: write a comment if you wish to reproduce that effect precisely.
Related
I have a longtable and I would like that both the first part and the second part of the table are identical. As you can see in the figure, on the first page you have a row "test (total) | test | test | test |Stest | test" . I would also like to see this on the second page (to increase readability of the table)
`
\documentclass[a4paper]{report}
\usepackage[a4paper, total={6in, 9in}]{geometry}
\usepackage{graphicx} % Required for box manipulation
\usepackage{helvet}
\usepackage{subfig}
\usepackage[utf8]{inputenc}
%\usepackage{natbib}
\usepackage[square, comma, sort&compress]{natbib}
\usepackage[USenglish]{babel}
\usepackage[useregional]{datetime2}
\usepackage{pgfgantt}
\usepackage{listings}
\usepackage{wrapfig}
\usepackage{setspace}
\usepackage{parskip} % Used to create spaces between paragraphs
\usepackage{dirtytalk} % quotes by talk
%\usepackage[hidelinks]{hyperref}
\usepackage[colorlinks=true,citecolor=red]{hyperref}
\usepackage[acronym, toc]{glossaries} % Used to add a wordlist/glossaries
\usepackage{mathtools}
\usepackage{amsfonts}
\usepackage{color, colortbl}
\usepackage{booktabs}
\usepackage{float}
\usepackage{csquotes}
%zelf toegevoegd
\usepackage[most]{tcolorbox}
\usepackage{multirow} %table
\usepackage{xcolor,colortbl}
\usepackage{pdflscape}
\usepackage{pifont} %%%bullet points
\usepackage{longtable}
\usepackage{graphicx}
%\usepackage{geometry} %table margin
\begin{longtable}{l|ccc|ccc|}
\caption{test}
\label{test}\\
\cline{2-7}
& \multicolumn{3}{c|}{\cellcolor{lightgray}\textbf{Duration test}} & \multicolumn{3}{c|}{\cellcolor{lightgray}\textbf{test(Count)}} \\ \hline
\endfirsthead
%
\multicolumn{7}{c}%
{{\bfseries Table \thetable\ continued from previous page}} \\
\cline{2-7}
& \multicolumn{3}{c|}{\cellcolor{lightgray}\textbf{Duration test)}} & \multicolumn{3}{c|}{\cellcolor{lightgray}\textbf{test(Count)}} \\ \hline
\endhead
%
\multicolumn{1}{|l|}{\cellcolor[HTML]{EFEFEF}test(Total)} &
\multicolumn{1}{|c|}{\cellcolor[HTML]{EFEFEF}test} &
\multicolumn{1}{c|}{\cellcolor[HTML]{EFEFEF}test} &
{\cellcolor[HTML]{EFEFEF}test} &
\multicolumn{1}{|c|}{\cellcolor[HTML]{EFEFEF}test} &
\multicolumn{1}{c|}{\cellcolor[HTML]{EFEFEF}test} &
{\cellcolor[HTML]{EFEFEF}test} \\ \hline
\multicolumn{1}{|l|}{test}
& \multicolumn{1}{c|}{00:04} & \multicolumn{1}{c|}{C} & \multicolumn{1}{c|}{D}
& \multicolumn{1}{c|}{1} & \multicolumn{1}{c|}{F} & \multicolumn{1}{c|}{G} \\ \hline
\multicolumn{1}{|l|}{test}
& \multicolumn{1}{c|}{07:21} & \multicolumn{1}{c|}{C} & \multicolumn{1}{c|}{D}
& \multicolumn{1}{c|}{47} & \multicolumn{1}{c|}{F} & \multicolumn{1}{c|}{G} \\ \hline
\multicolumn{1}{|l|}{test}
& \multicolumn{1}{c|}{00:18} & \multicolumn{1}{c|}{C} & \multicolumn{1}{c|}{D}
& \multicolumn{1}{c|}{3} & \multicolumn{1}{c|}{F} & \multicolumn{1}{c|}{G} \\ \hline
\multicolumn{1}{|l|}{test}
& \multicolumn{1}{c|}{00:18} & \multicolumn{1}{c|}{C} & \multicolumn{1}{c|}{D}
& \multicolumn{1}{c|}{3} & \multicolumn{1}{c|}{F} & \multicolumn{1}{c|}{G} \\ \hline
\multicolumn{1}{|l|}{test}
& \multicolumn{1}{c|}{00:40} & \multicolumn{1}{c|}{C} & \multicolumn{1}{c|}{D}
& \multicolumn{1}{c|}{9} & \multicolumn{1}{c|}{F} & \multicolumn{1}{c|}{G} \\ \hline
\multicolumn{1}{|l|}{test}
& \multicolumn{1}{c|}{01:20} & \multicolumn{1}{c|}{C} & \multicolumn{1}{c|}{D}
& \multicolumn{1}{c|}{24} & \multicolumn{1}{c|}{F} & \multicolumn{1}{c|}{G} \\ \hline
\multicolumn{1}{|l|}{test}
& \multicolumn{1}{c|}{00:50} & \multicolumn{1}{c|}{C} & \multicolumn{1}{c|}{D}
& \multicolumn{1}{c|}{7} & \multicolumn{1}{c|}{F} & \multicolumn{1}{c|}{G} \\ \hline
\multicolumn{1}{|l|}{test}
& \multicolumn{1}{c|}{00:16} & \multicolumn{1}{c|}{C} & \multicolumn{1}{c|}{D}
& \multicolumn{1}{c|}{2} & \multicolumn{1}{c|}{F} & \multicolumn{1}{c|}{G} \\ \hline
\multicolumn{1}{|l|}{test}
& \multicolumn{1}{c|}{00:28} & \multicolumn{1}{c|}{C} & \multicolumn{1}{c|}{D}
& \multicolumn{1}{c|}{7} & \multicolumn{1}{c|}{F} & \multicolumn{1}{c|}{G} \\ \hline
\multicolumn{1}{|l|}{test}
& \multicolumn{1}{c|}{00:24} & \multicolumn{1}{c|}{NOB} & \multicolumn{1}{c|}{NOB}
& \multicolumn{1}{c|}{1} & \multicolumn{1}{c|}{NOB} & \multicolumn{1}{c|}{NOB} \\ \hline
\multicolumn{1}{|l|}{test}
& \multicolumn{1}{c|}{01:53} & \multicolumn{1}{c|}{C} & \multicolumn{1}{c|}{D}
& \multicolumn{1}{c|}{33} & \multicolumn{1}{c|}{F} & \multicolumn{1}{c|}{G} \\ \hline
\multicolumn{1}{|l|}{test}
& \multicolumn{1}{c|}{04:32} & \multicolumn{1}{c|}{C} & \multicolumn{1}{c|}{D}
& \multicolumn{1}{c|}{63} & \multicolumn{1}{c|}{F} & \multicolumn{1}{c|}{G} \\ \hline
\multicolumn{1}{|l|}{test}
& \multicolumn{1}{c|}{00:05} & \multicolumn{1}{c|}{C} & \multicolumn{1}{c|}{D}
& \multicolumn{1}{c|}{3} & \multicolumn{1}{c|}{F} & \multicolumn{1}{c|}{G} \\ \hline
\multicolumn{1}{|l|}{test}
& \multicolumn{1}{c|}{13:21} & \multicolumn{1}{c|}{C} & \multicolumn{1}{c|}{D}
& \multicolumn{1}{c|}{128} & \multicolumn{1}{c|}{F} & \multicolumn{1}{c|}{G} \\ \hline
\multicolumn{1}{|l|}{test}
& \multicolumn{1}{c|}{00:16} & \multicolumn{1}{c|}{C} & \multicolumn{1}{c|}{D}
& \multicolumn{1}{c|}{4} & \multicolumn{1}{c|}{F} & \multicolumn{1}{c|}{G} \\ \hline
\multicolumn{1}{|l|}{test}
& \multicolumn{1}{c|}{00:25} & \multicolumn{1}{c|}{C} & \multicolumn{1}{c|}{D}
& \multicolumn{1}{c|}{6} & \multicolumn{1}{c|}{F} & \multicolumn{1}{c|}{G} \\ \hline
\multicolumn{1}{|l|}{test}
& \multicolumn{1}{c|}{10:19} & \multicolumn{1}{c|}{C} & \multicolumn{1}{c|}{D}
& \multicolumn{1}{c|}{41} & \multicolumn{1}{c|}{F} & \multicolumn{1}{c|}{G} \\ \hline
\multicolumn{1}{|l|}{test}
& \multicolumn{1}{c|}{00:26} & \multicolumn{1}{c|}{C} & \multicolumn{1}{c|}{D}
& \multicolumn{1}{c|}{10} & \multicolumn{1}{c|}{F} & \multicolumn{1}{c|}{G} \\ \hline
\multicolumn{1}{|l|}{test}
& \multicolumn{1}{c|}{00:07} & \multicolumn{1}{c|}{C} & \multicolumn{1}{c|}{D}
& \multicolumn{1}{c|}{3} & \multicolumn{1}{c|}{F} & \multicolumn{1}{c|}{G} \\ \hline
\multicolumn{1}{|l|}{test}
& \multicolumn{1}{c|}{00:12} & \multicolumn{1}{c|}{C} & \multicolumn{1}{c|}{D}
& \multicolumn{1}{c|}{3} & \multicolumn{1}{c|}{F} & \multicolumn{1}{c|}{G} \\ \hline
\multicolumn{1}{|l|}{test}
& \multicolumn{1}{c|}{00:14} & \multicolumn{1}{c|}{C} & \multicolumn{1}{c|}{D}
& \multicolumn{1}{c|}{2} & \multicolumn{1}{c|}{F} & \multicolumn{1}{c|}{G} \\ \hline
\multicolumn{1}{|l|}{test}
& \multicolumn{1}{c|}{NOB} & \multicolumn{1}{c|}{C} & \multicolumn{1}{c|}{D}
& \multicolumn{1}{c|}{NOB} & \multicolumn{1}{c|}{F} & \multicolumn{1}{c|}{G} \\ \hline
\multicolumn{1}{|l|}{\textbf{Grand Total}} & \multicolumn{1}{c|}{43:49} & \multicolumn{1}{c|}{43:25} & \multicolumn{1}{c|}{48:50}
& \multicolumn{1}{c|}{401} & \multicolumn{1}{c|}{397} & \multicolumn{1}{c|}{51} \\\hline
\end{longtable}
`
I tried to duplicate the following part of the code
`
\multicolumn{1}{|l|}{\cellcolor[HTML]{EFEFEF}test(Total)} &
\multicolumn{1}{|c|}{\cellcolor[HTML]{EFEFEF}test} &
\multicolumn{1}{c|}{\cellcolor[HTML]{EFEFEF}test} &
{\cellcolor[HTML]{EFEFEF}test} &
\multicolumn{1}{|c|}{\cellcolor[HTML]{EFEFEF}test} &
\multicolumn{1}{c|}{\cellcolor[HTML]{EFEFEF}test} &
{\cellcolor[HTML]{EFEFEF}test} \\ \hline
`
You can add the row you want to appear at the top of every page to your longtable header.
Wrapping each and every cell into a \multicolumn is neither necessary nor useful for anything.
\documentclass[a4paper]{report}
\usepackage[a4paper, total={6in, 9in}]{geometry}
\usepackage{graphicx} % Required for box manipulation
\usepackage{helvet}
\usepackage{subfig}
\usepackage[utf8]{inputenc}
%\usepackage{natbib}
\usepackage[square, comma, sort&compress]{natbib}
\usepackage[USenglish]{babel}
\usepackage[useregional]{datetime2}
\usepackage{pgfgantt}
\usepackage{listings}
\usepackage{wrapfig}
\usepackage{setspace}
\usepackage{parskip} % Used to create spaces between paragraphs
\usepackage{dirtytalk} % quotes by talk
%\usepackage[hidelinks]{hyperref}
\usepackage[colorlinks=true,citecolor=red]{hyperref}
\usepackage[acronym, toc]{glossaries} % Used to add a wordlist/glossaries
\usepackage{mathtools}
\usepackage{amsfonts}
\usepackage{color, colortbl}
\usepackage{booktabs}
\usepackage{float}
\usepackage{csquotes}
%zelf toegevoegd
\usepackage[most]{tcolorbox}
\usepackage{multirow} %table
\usepackage{xcolor,colortbl}
\usepackage{pdflscape}
\usepackage{pifont} %%%bullet points
\usepackage{longtable}
\usepackage{graphicx}
%\usepackage{geometry} %table margin
\begin{document}
\begin{longtable}{|l|ccc|ccc|}
\caption{test}
\label{test}\\
\cline{2-7}
\multicolumn{1}{l|}{} & \multicolumn{3}{c|}{\cellcolor{lightgray}\textbf{Duration test}} & \multicolumn{3}{c|}{\cellcolor{lightgray}\textbf{test(Count)}} \\ \hline
\rowcolor[HTML]{EFEFEF}test(Total) & test & test & test & test & test & test\\\hline
\endfirsthead
\multicolumn{7}{c}{{\bfseries Table \thetable\ continued from previous page}} \\
\cline{2-7}
\multicolumn{1}{l|}{} & \multicolumn{3}{c|}{\cellcolor{lightgray}\textbf{Duration test)}} & \multicolumn{3}{c|}{\cellcolor{lightgray}\textbf{test(Count)}} \\ \hline
\rowcolor[HTML]{EFEFEF}test(Total) & test & test & test & test & test & test\\\hline
\endhead
%
test & 00:04 & C & D & 1 & F & G \\ \hline
test & 07:21 & C & D & 47 & F & G \\ \hline
test & 00:18 & C & D & 3 & F & G \\ \hline
test & 00:18 & C & D & 3 & F & G \\ \hline
test & 00:40 & C & D & 9 & F & G \\ \hline
test & 01:20 & C & D & 24 & F & G \\ \hline
test & 00:50 & C & D & 7 & F & G \\ \hline
test & 00:16 & C & D & 2 & F & G \\ \hline
test & 00:28 & C & D & 7 & F & G \\ \hline
test & 00:24 & NOB & NOB & 1 & NOB & NOB \\ \hline
test & 01:53 & C & D & 33 & F & G \\ \hline
test & 04:32 & C & D & 63 & F & G \\ \hline
test & 00:05 & C & D & 3 & F & G \\ \hline
test & 13:21 & C & D & 128 & F & G \\ \hline
test & 00:16 & C & D & 4 & F & G \\ \hline
test & 00:25 & C & D & 6 & F & G \\ \hline
test & 10:19 & C & D & 41 & F & G \\ \hline
test & 00:26 & C & D & 10 & F & G \\ \hline
test & 00:07 & C & D & 3 & F & G \\ \hline
test & 00:12 & C & D & 3 & F & G \\ \hline
test & 00:14 & C & D & 2 & F & G \\ \hline
test & NOB & C & D & NOB & F & G \\ \hline
test & 00:04 & C & D & 1 & F & G \\ \hline
test & 07:21 & C & D & 47 & F & G \\ \hline
test & 00:18 & C & D & 3 & F & G \\ \hline
test & 00:18 & C & D & 3 & F & G \\ \hline
test & 00:40 & C & D & 9 & F & G \\ \hline
test & 01:20 & C & D & 24 & F & G \\ \hline
test & 00:50 & C & D & 7 & F & G \\ \hline
test & 00:16 & C & D & 2 & F & G \\ \hline
test & 00:28 & C & D & 7 & F & G \\ \hline
test & 00:24 & NOB & NOB & 1 & NOB & NOB \\ \hline
test & 01:53 & C & D & 33 & F & G \\ \hline
test & 04:32 & C & D & 63 & F & G \\ \hline
test & 00:05 & C & D & 3 & F & G \\ \hline
test & 13:21 & C & D & 128 & F & G \\ \hline
test & 00:16 & C & D & 4 & F & G \\ \hline
test & 00:25 & C & D & 6 & F & G \\ \hline
test & 10:19 & C & D & 41 & F & G \\ \hline
test & 00:26 & C & D & 10 & F & G \\ \hline
test & 00:07 & C & D & 3 & F & G \\ \hline
test & 00:12 & C & D & 3 & F & G \\ \hline
test & 00:14 & C & D & 2 & F & G \\ \hline
test & NOB & C & D & NOB & F & G \\ \hline
test & 00:04 & C & D & 1 & F & G \\ \hline
test & 07:21 & C & D & 47 & F & G \\ \hline
test & 00:18 & C & D & 3 & F & G \\ \hline
test & 00:18 & C & D & 3 & F & G \\ \hline
test & 00:40 & C & D & 9 & F & G \\ \hline
test & 01:20 & C & D & 24 & F & G \\ \hline
test & 00:50 & C & D & 7 & F & G \\ \hline
test & 00:16 & C & D & 2 & F & G \\ \hline
test & 00:28 & C & D & 7 & F & G \\ \hline
test & 00:24 & NOB & NOB & 1 & NOB & NOB \\ \hline
test & 01:53 & C & D & 33 & F & G \\ \hline
test & 04:32 & C & D & 63 & F & G \\ \hline
test & 00:05 & C & D & 3 & F & G \\ \hline
test & 13:21 & C & D & 128 & F & G \\ \hline
test & 00:16 & C & D & 4 & F & G \\ \hline
test & 00:25 & C & D & 6 & F & G \\ \hline
test & 10:19 & C & D & 41 & F & G \\ \hline
test & 00:26 & C & D & 10 & F & G \\ \hline
test & 00:07 & C & D & 3 & F & G \\ \hline
test & 00:12 & C & D & 3 & F & G \\ \hline
test & 00:14 & C & D & 2 & F & G \\ \hline
test & NOB & C & D & NOB & F & G \\ \hline
\textbf{Grand Total} & 43:49 & 43:25 & 48:50
& 401 & 397 & 51 \\\hline
\end{longtable}
\end{document}
I'm writing a document which will contain something like the image I included below. I don't want to use images because if I do, the document will contain a lot of images and I want to include this text in my LaTeX document the right way.
I don't know if this is possible, but can I have a section in latex, in which I can write whitespaces and tabs the way I do in a .txt document?
You can use the verbatim environment:
\begin{verbatim}
The verbatim environment
simply reproduces every
character you input,
including all s p a c e s!
\end{verbatim}
I'm not sure if tabs will do what you want; replace them by spaces if necessary.
An alternative to verbatim environment is to use a tabular-like environment, here's a sketch:
\documentclass{article}
\begin{document}
\begin{tabular}{*{14}{c}}
0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & & & \\
e & i & n & - & t & e & s & t & e & s & t & & & \\
t & e & s & t & & & & & & & & & I=0 & j=0\\
& t & e & s & t & & & & & & & & I=1 & j=0\\
& & t & e & s & t & & & & & & & I=2 & j=0\\
& & & t & e & s & t & & & & & & I=3 & j=0\\
& & & & t & e & s & t & & & & & I=4 & j=1\\
& & & & & t & e & s & t & & & & I=5 & j=2\\
& & & & & & t & e & s & t & & & I=6 & j=3\\
& & & & & & & t & e & s & t & & I=7 & j=4\\
\multicolumn{14}{l}{Und dann wird j auf 1... }\\
& & & & & & & & t & e & s & t & I=8 & j=2\\
\end{tabular}
\end{document}
and its output.
In my opinion a tabular (or other table environment) here has the advantage that you can then configure spacing, font family and size, etc.
I am working on the LaTeX overleaf. I am using the IEEE access template which is two column. I have to fix my table in a single column. Can you tell me how can i do this?
Code:
\begin{table}[h]
\centering
\caption{Comparison table}
\label{tab2}
\begin{tabular}{#{}p{3cm}lllll#{}}
\toprule
\multicolumn{1}{}{}Metric
&\cite{dagher2018ancile} &\cite{tripathi2020sms} &\cite{zheng2018blockchain} &\cite{gordon2018blockchain}
&Our architecture\\ \midrule
User Centric & Y & N & Y & Y & Y\\
User Authentication & N & N & N & N & Y \\
Privacy of data owner & Y & Y & Y & Y & Y\\
Store personal data into blockchain & N & N & N & N & Y\\
Transparent policy & N & N & N & N & Y\\
Use of cryptographic functions & N & Y & Y & N & Y\\
Blockchain based & Y & Y & Y & Y & Y\\
\bottomrule
\end{tabular}
\end{table}
The IEEEtran.cls documentclass provides the environment table*, arranged on one column instead of the default two columns:
\documentclass{IEEEtran}
\usepackage{lipsum,booktabs}
\begin{document}
\lipsum[1]
\begin{table*}[h]
\centering
\caption{Comparison table}
\label{tab2}
\begin{tabular}{#{}p{3cm}lllll#{}}
\toprule
\multicolumn{1}{}{}Metric & \cite{dagher2018ancile} & \cite{tripathi2020sms} & %
\cite{zheng2018blockchain} & \cite{gordon2018blockchain} & Our architecture\\
\midrule
User Centric & Y & N & Y & Y & Y\\
User Authentication & N & N & N & N & Y \\
Privacy of data owner & Y & Y & Y & Y & Y\\
Store personal data into blockchain & N & N & N & N & Y\\
Transparent policy & N & N & N & N & Y\\
Use of cryptographic functions & N & Y & Y & N & Y\\
Blockchain based & Y & Y & Y & Y & Y\\
\bottomrule
\end{tabular}
\end{table*}
\lipsum[2-16]
\end{document}
I used the package lipsum only to produce as much blind text as I needed. The output:
Also, see this very related thread.
I want table in overleaf with three main columns in one table. I used muticolumn, but instead of one table with three columns it comes as three tables. It comes like this:
Here is the code for it. I am trying to remove the spaces between columns and make it look like one table. Any help appreciated
\begin{table}[h!]
\center
\setlength{\tabcolsep}{2pt}
\caption{ Model of Dataset I Tested on Dataset III}
\label{my-label7}
\begin{tabular}{|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|}
\hline
\multicolumn{14}{|c|}{Model Based Approach } \\
\hline
Hosts & A & B & D & G & H & I & J & L & M & N & P & Q & R \\ \hline
DR & 1 & 0.85 & 0.6 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\
\hline
FPR & 0.04 & 0 & 0 & 0 & 0 & 0 & 0 &0 & 0 & 0 & 0 & 0 &
0 \\ \hline
\end{tabular}
\begin{tabular}{|l|l|l|l|l|l|l|}
\hline
\multicolumn{5}{|c|}{Instance Based Approach} \\
\hline
C & E & F & K & O \\ \hline
1 & 0.79 & 1 & 1 & 1 \\ \hline
0 & 0 & 0.5 & 0 & 0 \\ \hline
\end{tabular}
\begin{tabular}{|l|l|}
\hline
\multicolumn{1}{|c|}{Average} \\
\hline
All \\ \hline
\textbf{0.95} \\ \hline
\textbf{0.03} \\ \hline
\end{tabular}
\end{table}
The table is set as three different tables because it is set using three separate tabulars. Below I've combined them, but also used [booktabs](//ctan.org/pkg/booktabs for a less line-based approach.
\documentclass{article}
\usepackage{booktabs,makecell}
\begin{document}
\begin{table}
\centering
\setlength{\tabcolsep}{2pt}
\caption{Model of Dataset I Tested on Dataset III}
\begin{tabular}{ *{20}{l} }
\toprule
& \multicolumn{13}{c}{Model Based Approach} &
\multicolumn{5}{c}{\makecell[b]{Instance Based \\ Approach}} &
\multicolumn{1}{c}{Average} \\
\cmidrule(lr){2-14}
\cmidrule(lr){15-19}
\cmidrule(lr){20-20}
Hosts & A & B & D & G & H & I & J & L & M & N & P & Q & R &
C & E & F & K & O &
All \\
DR & 1 & 0.85 & 0.6 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 &
1 & 0.79 & 1 & 1 & 1 &
\textbf{0.95} \\
FPR & 0.04 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 &
0 & 0 & 0.5 & 0 & 0 &
\textbf{0.03} \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
I'm new to LaTeX and trying to make a truth table, but it won't compile. When I try to run the code, it says "Extra alignment tab has been changed to \cr." Here is my code:
\item (Textbook 1.1/38, 4 points) $((p\rightarrow q)\rightarrow r)\rightarrow s$
\begin{center}
\begin{tabular}{c|c|c|c|c|c}
\hline
$p$ & $q$ & $r$ & $s$ & $p\rightarrow q$ & $(p\rightarrow q)\rightarrow$ r & $((p\rightarrow q)\rightarrow r)\rightarrow s$ \\
\hline
T & T & T & T & T & T & T \\
T & T & T & F & T & T & F \\
T & T & F & T & T & F & T \\
T & F & T & T & F & T & T \\
T & F & T & F & F & T & F \\
T & F & F & T & F & T & T \\
T & F & F & F & F & T & F \\
F & T & T & T & T & T & T \\
F & T & T & F & T & T & F \\
F & T & F & T & T & F & T \\
F & T & F & F & T & F & T \\
F & F & T & T & T & T & T \\
F & F & T & F & T & T & F \\
F & F & F & T & T & F & T \\
F & F & F & F & T & F & T \\
\hline
\end{tabular}
\end{center}
Very easily, you declared six columns: there are six c in the line
\begin{tabular}{c|c|c|c|c|c}
Then, every line of your table has seven cells instead:
...
T & T & T & T & T & T & T \\
...
So, you should solve by changing
\begin{tabular}{c|c|c|c|c|c}
to
\begin{tabular}{c|c|c|c|c|c|c}
or
\begin{tabular}{c*{6}{|c}}
All you have to do is remove the \\ at the end of the last line of the truth table. I would also suggest trying out Overleaf it allows you to see your code in real time and gives an easier debugging experience.