I obtain this:
I cannot figure out how can I center the first column name vertically.
Below is my current code:
\\documentclass{article}
\\usepackage\[utf8\]{inputenc}
\\usepackage{longtable}
\\usepackage{multirow}
\\usepackage{array}
\\title{teste}
\\begin{document}
\\setlength{\\tabcolsep}{9pt}
\\renewcommand{\\arraystretch}{1.1}
\\newcolumntype{M}\[1\]{\>{\\centering\\arraybackslash}m{#1}}
\\begin{longtable}
{|M{2,5cm}||M{1,3cm}|M{2,1cm}|M{3,1cm}|M{2,4cm}| }
\\hline
\\multicolumn{5}{|c|}{MODELS} \\
\\hline
\\vspace{1.9cm}
Nome& Tipo &Estimativa de Custo Anual&Requisitos Cumpridos& Último Update\\
\\hline
\\endhead
ABC & C& 9.999&Sim &Não\\
\\hline
\\end{longtable}
\\end{document}
Please always provide a minimum working example (MWE). This is code we can compile and test. You should also clean your code before posting. Otherwise, you ask potential contributor for the extra unnecessary work to help you.
I suggest another long-table related environment xltabular. It is similar to longtable but accepts the X column type, which adapts width to the rest of the table; it's a convenient way to avoid unnecessary calculations to get a proper dimension of your table, which does not exceed page dimensions.
With X which uses p{} under the hood, you get the correct alignment of the first cell. I also recommend reducing avoiding vertical to a minimum. In your case, I left the one between the first column and "the rest" of the table. I also demonstrated how you could add bars and rules of different thicknesses.
Finally, I added \endfoot so the table is correctly closed on subsequent pages.
Note. On one hand, you are using , as a decimal marker in a column definition and . in the content of the table. I was surprised the code actually get compiled.
EDIT. I use a \xmathstrut macro from mathtools to add some vertical spacing in your header. Lower the value from 2 to reduce the spacing.
Here's the code:
\documentclass{article}
\usepackage{xltabular}
\usepackage{mathtools}
% \title{teste}
\begin{document}
% --- BEGIN GROUP -------------------------
\begingroup
\renewcommand{\arraystretch}{1.5}
\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}
\renewcommand{\tabularxcolumn}[1]{>{\centering\arraybackslash}p{#1}}
\setlength{\tabcolsep}{3pt}
\begin{xltabular}{\linewidth}{
X !{\vrule width 0.2pt}
M{1,3cm}
M{2,1cm}
M{3,1cm}
M{2,4cm}
}
\noalign{\hrule height 0.8pt}
\multicolumn{5}{c}{MODELS} \\
\noalign{\hrule height 0.8pt}
$\xmathstrut{2}$Nome
& Tipo
& Estimativa de Custo Anual
& Requisitos Cumpridos
& Último Update \\
\noalign{\hrule height 0.5pt} \endhead
\noalign{\hrule height 0.8pt} \endfoot
ABC & C & 9.999 & Sim & Não\\
ABC & C & 9.999 & Sim & Não\\
ABC & C & 9.999 & Sim & Não\\
ABC & C & 9.999 & Sim & Não\\
ABC & C & 9.999 & Sim & Não\\
ABC & C & 9.999 & Sim & Não\\
ABC & C & 9.999 & Sim & Não\\
ABC & C & 9.999 & Sim & Não\\
ABC & C & 9.999 & Sim & Não\\
ABC & C & 9.999 & Sim & Não\\
ABC & C & 9.999 & Sim & Não\\
ABC & C & 9.999 & Sim & Não\\
ABC & C & 9.999 & Sim & Não\\
ABC & C & 9.999 & Sim & Não\\
ABC & C & 9.999 & Sim & Não\\
ABC & C & 9.999 & Sim & Não\\
ABC & C & 9.999 & Sim & Não\\
ABC & C & 9.999 & Sim & Não\\
ABC & C & 9.999 & Sim & Não\\
ABC & C & 9.999 & Sim & Não\\
ABC & C & 9.999 & Sim & Não\\
ABC & C & 9.999 & Sim & Não\\
ABC & C & 9.999 & Sim & Não\\
ABC & C & 9.999 & Sim & Não\\
ABC & C & 9.999 & Sim & Não\\
ABC & C & 9.999 & Sim & Não\\
ABC & C & 9.999 & Sim & Não\\
ABC & C & 9.999 & Sim & Não\\
ABC & C & 9.999 & Sim & Não\\
ABC & C & 9.999 & Sim & Não\\
ABC & C & 9.999 & Sim & Não\\
ABC & C & 9.999 & Sim & Não\\
ABC & C & 9.999 & Sim & Não\\
ABC & C & 9.999 & Sim & Não\\
ABC & C & 9.999 & Sim & Não\\
ABC & C & 9.999 & Sim & Não\\
\end{xltabular}
\endgroup
% --- END GROUP ---------------------------
\end{document}
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 have a table in latex. here is the code for it. My problem is the table is huge and and the content of it is not clear. My paper texts are shown in two columns and the table locates in one of those columns. I appreciate if anyone can help me how can I make the table content more clear for example is it good to expand it in a new page?
\begin{table}[]
\centering
\caption{Comparing accuracy of }
\label{table1}
\resizebox{\columnwidth}{!}{%
\begin{tabular}{|cccccccccccc|}
\hline
\rowcolor[HTML]{C0C0C0}
\multicolumn{12}{|c|}{\cellcolor[HTML]{C0C0C0}out\_1} \\ \hline
\rowcolor[HTML]{00D2CB}
\multicolumn{1}{|c|}{\cellcolor[HTML]{00D2CB}} & \multicolumn{1}{c|}{\cellcolor[HTML]{00D2CB}} & \multicolumn{5}{c|}{\cellcolor[HTML]{00D2CB}Accuracy result} & \multicolumn{5}{c|}{\cellcolor[HTML]{00D2CB}Precision result} \\ \hline
\rowcolor[HTML]{C0C0C0}
\multicolumn{1}{|c|}{\cellcolor[HTML]{C0C0C0}row} & \multicolumn{1}{c|}{\cellcolor[HTML]{C0C0C0}Train-Test percentage} & \multicolumn{1}{c|}{\cellcolor[HTML]{C0C0C0}TP} & \multicolumn{1}{c|}{\cellcolor[HTML]{C0C0C0}FP} & \multicolumn{1}{c|}{\cellcolor[HTML]{C0C0C0}FN} & \multicolumn{1}{c|}{\cellcolor[HTML]{C0C0C0}TN} & \multicolumn{1}{c|}{\cellcolor[HTML]{C0C0C0}Accuracy} & \multicolumn{1}{c|}{\cellcolor[HTML]{C0C0C0}TP} & \multicolumn{1}{c|}{\cellcolor[HTML]{C0C0C0}FP} & \multicolumn{1}{c|}{\cellcolor[HTML]{C0C0C0}FN} & \multicolumn{1}{c|}{\cellcolor[HTML]{C0C0C0}TN} & Accuracy \\ \hline
\multicolumn{1}{|c|}{1} & \multicolumn{1}{c|}{10-90} & \multicolumn{1}{c|}{17508} & \multicolumn{1}{c|}{5433} & \multicolumn{1}{c|}{8} & \multicolumn{1}{c|}{35961} & \multicolumn{1}{c|}{0.907638771} & \multicolumn{1}{c|}{18715} & \multicolumn{1}{c|}{4226} & \multicolumn{1}{c|}{8} & \multicolumn{1}{c|}{35961} & 0.928127652 \\ \hline
\multicolumn{1}{|c|}{2} & \multicolumn{1}{c|}{20-80} & \multicolumn{1}{c|}{17313} & \multicolumn{1}{c|}{5433} & \multicolumn{1}{c|}{8} & \multicolumn{1}{c|}{29610} & \multicolumn{1}{c|}{0.896092735} & \multicolumn{1}{c|}{18476} & \multicolumn{1}{c|}{4270} & \multicolumn{1}{c|}{8} & \multicolumn{1}{c|}{29610} & 0.918302651 \\ \hline
\multicolumn{1}{|c|}{3} & \multicolumn{1}{c|}{30-70} & \multicolumn{1}{c|}{17097} & \multicolumn{1}{c|}{5433} & \multicolumn{1}{c|}{8} & \multicolumn{1}{c|}{23281} & \multicolumn{1}{c|}{0.881250136} & \multicolumn{1}{c|}{18223} & \multicolumn{1}{c|}{4307} & \multicolumn{1}{c|}{8} & \multicolumn{1}{c|}{23281} & 0.905825094 \\ \hline
\multicolumn{1}{|c|}{4} & \multicolumn{1}{c|}{40-60} & \multicolumn{1}{c|}{16587} & \multicolumn{1}{c|}{5429} & \multicolumn{1}{c|}{3} & \multicolumn{1}{c|}{17256} & \multicolumn{1}{c|}{0.86171513} & \multicolumn{1}{c|}{17760} & \multicolumn{1}{c|}{1255} & \multicolumn{1}{c|}{3} & \multicolumn{1}{c|}{17256} & 0.891582217 \\ \hline
\multicolumn{1}{|c|}{5} & \multicolumn{1}{c|}{50-50} & \multicolumn{1}{c|}{16155} & \multicolumn{1}{c|}{5428} & \multicolumn{1}{c|}{3} & \multicolumn{1}{c|}{16942} & \multicolumn{1}{c|}{0.834056465} & \multicolumn{1}{c|}{17338} & \multicolumn{1}{c|}{4245} & \multicolumn{1}{c|}{3} & \multicolumn{1}{c|}{11142} & 0.870202884 \\ \hline
\multicolumn{1}{|c|}{6} & \multicolumn{1}{c|}{60-40} & \multicolumn{1}{c|}{15654} & \multicolumn{1}{c|}{5416} & \multicolumn{1}{c|}{3} & \multicolumn{1}{c|}{5109} & \multicolumn{1}{c|}{0.793025891} & \multicolumn{1}{c|}{16817} & \multicolumn{1}{c|}{4253} & \multicolumn{1}{c|}{3} & \multicolumn{1}{c|}{5109} & 0.837445573 \\ \hline
\multicolumn{1}{|c|}{7} & \multicolumn{1}{c|}{70-30} & \multicolumn{1}{c|}{14240} & \multicolumn{1}{c|}{8977} & \multicolumn{1}{c|}{0} & \multicolumn{1}{c|}{0} & \multicolumn{1}{c|}{0.725161685} & \multicolumn{1}{c|}{15373} & \multicolumn{1}{c|}{4264} & \multicolumn{1}{c|}{0} & \multicolumn{1}{c|}{0} & 0.782858889 \\ \hline
\multicolumn{1}{|c|}{8} & \multicolumn{1}{c|}{80-20} & \multicolumn{1}{c|}{9340} & \multicolumn{1}{c|}{3752} & \multicolumn{1}{c|}{0} & \multicolumn{1}{c|}{0} & \multicolumn{1}{c|}{0.713412771} & \multicolumn{1}{c|}{9502} & \multicolumn{1}{c|}{3950} & \multicolumn{1}{c|}{0} & \multicolumn{1}{c|}{0} & 0.72578676 \\ \hline
\multicolumn{1}{|c|}{9} & \multicolumn{1}{c|}{90-10} & \multicolumn{1}{c|}{4736} & \multicolumn{1}{c|}{1809} & \multicolumn{1}{c|}{0} & \multicolumn{1}{c|}{0} & \multicolumn{1}{c|}{0.723605806} & \multicolumn{1}{c|}{4766} & \multicolumn{1}{c|}{1223} & \multicolumn{1}{c|}{0} & \multicolumn{1}{c|}{0} & 0.722993452 \\ \hline
\end{tabular}%
}
\end{table}
The table in the paper is shown like the following:
I edit my code according to what you have written,
\usepackage{array}
\usepackage{booktabs}
\usepackage{threeparttable}
\usepackage{siunitx}
\usepackage{float}
\usepackage[margin=1in]{geometry}
\sisetup{
table-format=1.3,
round-mode = places,
round-precision = 3,
}
\begin{table*}[ht]
\renewcommand*{\arraystretch}{1.1}
\centering
\begin{threeparttable}
\caption{Comparing accuracy}\label{tab:table}
\begin{tabular}{c #{\hspace{12pt}} *5{c} S #{\hspace{12pt}} *4{c} S #{\hspace{6pt}}}
\toprule
\multicolumn{12}{c}{out\_1} \\
\cmidrule(lr){1-12}
& & \multicolumn{5}{c}{Accuracy result}
& \multicolumn{5}{c}{Precision result} \\
\cmidrule(lr){3-7}\cmidrule(r){8-12}
& TTP\tnote{1} & TP & FP & FN & TN & {ACC\tnote{3}} & TP & FP & FN & TN & {ACC\tnote{3}} \\
\midrule
1 & 10-90 & 17508 & 5433 & 8 & 35961 & 0.907638771 & 18715 & 4226 & 8 & 35961 & 0.928127652 \\
2 & 20-80 & 17313 & 5433 & 8 & 29610 & 0.896092735 & 18476 & 4270 & 8 & 29610 & 0.918302651 \\
3 & 30-70 & 17097 & 5433 & 8 & 23281 & 0.881250136 & 18223 & 4307 & 8 & 23281 & 0.905825094 \\
4 & 40-60 & 16587 & 5428 & 3 & 17256 & 0.86171513 & 17760 & 4255 & 3 & 17256 & 0.891582217 \\
5 & 50-50 & 16155 & 5428 & 3 & 11142 & 0.834056465 & 17338 & 4245 & 3 & 11142 & 0.870202884 \\
6 & 60-40 & 15654 & 5416 & 3 & 5109 & 0.793025743 & 16817 & 4253 & 3 & 5109 & 0.837445573 \\
7 & 70-30 & 14240 & 5397 & 0 & 0 & 0.725161685 & 15373 & 4264 & 0 & 0 & 0.782858889 \\
8 & 80-20 & 9340 & 3752 & 0 & 0 & 0.713412771 & 9502 & 3590 & 0 & 0 & 0.72578674 \\
9 & 90-10 & 4736 & 1809 & 0 & 0 & 0.723605806 & 4732 & 1813 & 0 & 0 & 0.722994652 \\
\bottomrule
\end{tabular}
\par\tnote{1} Test Train Percentage
\par\tnote{2} Accuracy
\end{threeparttable}
\end{table*}
\end{document}
You just have to make sure tables aren't too wordy; "the long" column names and insane number of decimal places are mostly the culprits!
I managed to fit the table within a page of a regular two column document. However, I changed some names to acronyms and added annotation to explain what they represent. I also reduced accuracy to 3 decimal places (I don't think you need more than 2).
There are a few additional packages in the code
siunitx to round some numbers
threeparttable to split the table into three parts: a caption, the main table, footnotes (*)
booktabs for much better rules (**).
* If you insist on using colours, then you will have to get back to regular \hline due to gaps between background colours and rules defined by booktabs. I think a well designed table doesn't need colours
** The caption width will be reduced to the width of your table, which IMO has much better effect; move caption outside the threeparttable if you prefer captions to have the full page width .
Here's the result with dummy texts
and code
\documentclass[twocolumn]{article}
\usepackage{array}
\usepackage{amsmath}
\usepackage{booktabs}
\usepackage{threeparttable}
\usepackage{siunitx}
\sisetup{
table-format=1.3,
round-mode = places,
round-precision = 3,
}
\usepackage{kantlipsum}
\pagestyle{empty}
\begin{document}
\section{One}
\kant[1-2]
\begin{table*}
\renewcommand*{\arraystretch}{1.1}
\centering
\begin{threeparttable}
\caption{Comparing accuracy}\label{tab:table}
\begin{tabular}{c #{\hspace{12pt}} *5{c} S #{\hspace{12pt}} *4{c} S #{\hspace{6pt}}}
\toprule
\multicolumn{12}{c}{out\_1} \\
\cmidrule(lr){1-12}
& & \multicolumn{5}{c}{Accuracy result}
& \multicolumn{5}{c}{Precision result} \\
\cmidrule(lr){3-7}\cmidrule(r){8-12}
& TTP\tnote{1} & TP & FP & FN & TN & {ACC\tnote{2}} & TP & FP & FN & TN & {ACC\tnote{2}} \\
\midrule
1 & 10-90 & 17508 & 5433 & 8 & 35961 & 0.907638771 & 18715 & 4226 & 8 & 35961 & 0.928127652 \\
2 & 20-80 & 17313 & 5433 & 8 & 29610 & 0.896092735 & 18476 & 4270 & 8 & 29610 & 0.918302651 \\
3 & 30-70 & 17097 & 5433 & 8 & 23281 & 0.881250136 & 18223 & 4307 & 8 & 23281 & 0.905825094 \\
4 & 40-60 & 16587 & 5428 & 3 & 17256 & 0.86171513 & 17760 & 4255 & 3 & 17256 & 0.891582217 \\
5 & 50-50 & 16155 & 5428 & 3 & 11142 & 0.834056465 & 17338 & 4245 & 3 & 11142 & 0.870202884 \\
6 & 60-40 & 15654 & 5416 & 3 & 5109 & 0.793025743 & 16817 & 4253 & 3 & 5109 & 0.837445573 \\
7 & 70-30 & 14240 & 5397 & 0 & 0 & 0.725161685 & 15373 & 4264 & 0 & 0 & 0.782858889 \\
8 & 80-20 & 9340 & 3752 & 0 & 0 & 0.713412771 & 9502 & 3590 & 0 & 0 & 0.72578674 \\
9 & 90-10 & 4736 & 1809 & 0 & 0 & 0.723605806 & 4732 & 1813 & 0 & 0 & 0.722994652 \\
\bottomrule
\end{tabular}
\par\tnote{1} Test Train Percentage
\par\tnote{2} Accuracy
\end{threeparttable}
\end{table*}
\kant[3-5]
\section{Two}
\kant[1-2]
\end{document}
Update
In order to achieve top alignment of a float on a single empty page, add the following to your preamble
\makeatletter
\setlength\#dblfptop{0pt}
\makeatother
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.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 3 years ago.
Improve this question
\begin{center}
\footnotesize
\begin{tabular}{| c | c c c |}
\hline
\multirow{3}{*}{Equipment acquired at start of year} & \multicolumn{3}{c|}{Replacement cost (\$) for given years} & &\\
\cline{2-4}
& 1 & 2 & 3\\
\hline
1 & 4000 & \multicolumn{1}{|c|}{5400} & 9800\\
2 & 4300 & \multicolumn{1}{|c|}{6200} & 8700\\
3 & 4800 & \multicolumn{1}{|c|}{7100} & -\\
4 & 4900 & \multicolumn{1}{|c|}{-} & -\\
\hline
\end{tabular}
\end{center}
im getting an error:
Extra alignment tab has been changed to \cr.
Also for this portion of code I'm not sure what exactly is the error (I'm getting like 20 misplaced errors and missing brackets):
\begin{table}[]
\centering
\begin{tabular}{c|c|c|c|c|c|c|c|c|c|c}
\multicolumn{11}{Directed Edge Weights (Row $\rightarrow$ Col)} & & & & & & & & & & \\
\hline
$\rightarrow$ & A & B & C & D & E & F & G & H & I & J\\
\hline
A&0&4000&&&&&&&&\\
B&&0&5400&4300&&&&&&\\
C&&&0&&9800&6200&4800&&&\\
D&&&&0&9800&6200&4800&&&\\
E&&&&&0&&&8700&7100&4900\\
F&&&&&&0&&8700&7100&4900\\
G&&&&&&&0&8700&7100&4900\\
H&&&&&&&&0&&\\
I&&&&&&&&&0&\\
J&&&&&&&&&&0\\
\hline
\end{tabular}
\caption{Table of Adjacent Edges}
\label{tab:Edges of graph}
\end{table}
please help :)
In both cases it appears that there are additional cells added after your use of multicolumn. In the first case you can remove & & after the multicolumn and all should work fine:
\begin{center}
\footnotesize
\begin{tabular}{| c | c c c |}
\hline
\multirow{3}{*}{Equipment acquired at start of year} & \multicolumn{3}{c|}{Replacement cost (\$) for given years} \\
\cline{2-4}
& 1 & 2 & 3\\
\hline
1 & 4000 & \multicolumn{1}{|c|}{5400} & 9800\\
2 & 4300 & \multicolumn{1}{|c|}{6200} & 8700\\
3 & 4800 & \multicolumn{1}{|c|}{7100} & -\\
4 & 4900 & \multicolumn{1}{|c|}{-} & -\\
\hline
\end{tabular}
\end{center}
and in the second case you need to remove the repeated & symbols after multicolumn. Also in this case there is no indication of the spacing in multicolumn. The below table works fine for me, though I have added {c} in the multicolumn.
\begin{table}
\centering
\begin{tabular}{c|c|c|c|c|c|c|c|c|c|c}
\multicolumn{11}{c}{Directed Edge Weights (Row $\rightarrow$ Col)} \\
\hline
$\rightarrow$ & A & B & C & D & E & F & G & H & I & J\\
\hline
A&0&4000&&&&&&&&\\
B&&0&5400&4300&&&&&&\\
C&&&0&&9800&6200&4800&&&\\
D&&&&0&9800&6200&4800&&&\\
E&&&&&0&&&8700&7100&4900\\
F&&&&&&0&&8700&7100&4900\\
G&&&&&&&0&8700&7100&4900\\
H&&&&&&&&0&&\\
I&&&&&&&&&0&\\
J&&&&&&&&&&0\\ \hline
\end{tabular}
\caption{Table of Adjacent Edges}
\label{tab:Edges of graph}
\end{table}
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.