Can anyone give an idea on how to make this table?
Use \begin{table} [...] \end{table}
Here is a minimal working example:
\begin{table}
\centering
\begin{tabular}{l r}
& 119 Responses\\
Field & Percentage \\
\hline
Very convenient & 63\% \\
Sowewhat convenient & 28\% \\
Neutral & 5\% \\
Somewhat inconvenient & 2\% \\
Very inconvenient & 3\% \\
\end{tabular}
\end{table}
\end{document}
It looks like this:
I am trying to fix an issue with my latex document, and need help.
I am using \documentclass[12pt]{article} environment in Latex. The issue is the following:
I have added an appendix using
\appendix
\section{Appendix}\label{appendix_a}
and used
\setcounter{table}{0}
\renewcommand{\thetable}{A\arabic{table}}
to generate table names as Table A1 and so on.
However, when I use \setcounter to restart the table numbering, my labels stop working. But if I remove the \setcounter command, my labels work perfectly, but then the table number continue from where I left before appendix, that is Table A6 and not Table A1.
Here is my minimum working example:
\documentclass[12pt]{article}
\usepackage{amssymb,amsmath,amsfonts,eurosym,geometry,ulem,graphicx,caption,color,setspace,sectsty,comment,footmisc,caption,pdflscape,subfigure,array,hyperref,booktabs,dcolumn,threeparttable, adjustbox,apacite,dirtytalk,multirow,tabularx,booktabs}
\usepackage{ulem}
\usepackage{float}
\restylefloat{table}
\begin{document}
\section{Section A}
Table \ref{tab_main} is the first table.
\begin{table}
\centering
\input{Main_Table}
\caption{Main Table}
\label{tab_main}
\end{table}
See table \ref{tab_appendix} in the appendix.
\appendix
\section{Appendix}\label{appendix_a}
%\setcounter{table}{0}
\renewcommand{\thetable}{A\arabic{table}}
\begin{table}
\input{Appendix_Table}
\caption{Appendix Table}
\label{tab_appendix}
\end{table}
\end{document}
And here are tables that I have used:
Main_Table.tex
\begin{centre}
\begin{table}[H]
\\[-1.8ex]\hline
\hline \\[-1.8ex]
\begin{tabularx}{1\textwidth}{>{\raggedright\arraybackslash}X >{\centering\arraybackslash}X >{\centering\arraybackslash}X >{\centering\arraybackslash}X >{\centering\arraybackslash}X}
\small
& & \multicolumn{3}{c}{Heading} \\
\midrule
\multicolumn{2}{l}{Koo} & 1 & 2 & 3 \\
\multicolumn{2}{l}{Koo} & 1 & 2 & 3 \\
\midrule
\multicolumn{2}{l}{Koo} & A & B & C \\
\multicolumn{2}{l}{Koo} & A & B & C \\
\multicolumn{2}{l}{Koo} & A & B & C \\
\multicolumn{2}{l}{Koo} & A & B & C \\
\tiny
\end{tabularx}
\hline
\hline \\[-1.8ex]
\smallskip
\multicolumn{5}{l}{\parbox[t]{\textwidth}{\footnotesize{\emph{Notes}: Main}}}
\end{table}
\end{centre}
Appendix_Table.tex
\begin{centre}
\begin{table}[H]
\\[-1.8ex]\hline
\hline \\[-1.8ex]
\begin{tabularx}{1\textwidth}{>{\raggedright\arraybackslash}X >{\centering\arraybackslash}X >{\centering\arraybackslash}X >{\centering\arraybackslash}X >{\centering\arraybackslash}X}
\small
& & \multicolumn{3}{c}{Heading} \\
\midrule
\multicolumn{2}{l}{Foo} & 1 & 2 & 3 \\
\multicolumn{2}{l}{Foo} & 1 & 2 & 3 \\
\midrule
\multicolumn{2}{l}{Foo} & A & B & C \\
\multicolumn{2}{l}{Foo} & A & B & C \\
\multicolumn{2}{l}{Foo} & A & B & C \\
\multicolumn{2}{l}{Foo} & A & B & C \\
\tiny
\end{tabularx}
\hline
\hline \\[-1.8ex]
\smallskip
\multicolumn{5}{l}{\parbox[t]{\textwidth}{\footnotesize{\emph{Notes}: Appendix}}}
\end{table}
\end{centre}
Any help on this front would be appreciated.
Thank You
\documentclass[12pt]{article}
\usepackage{amssymb,amsmath,amsfonts,eurosym,geometry,ulem,graphicx,caption,color,setspace,sectsty,comment,footmisc,caption,pdflscape,subfigure,array,hyperref,booktabs,dcolumn,threeparttable, adjustbox,apacite,dirtytalk,multirow,tabularx,booktabs}
\usepackage{ulem}
\usepackage{float}
\restylefloat{table}
\usepackage{appendix}
\begin{document}
\section{Section A}
Table \ref{tab_main} is the first table.
\begin{table}[htbp]
\centering
main table
\caption{Main Table}
\label{tab_main}
\end{table}
See table \ref{tab_appendix} in the appendix.
\appendix
\section{Appendix}\label{appendix_a}
\setcounter{table}{0}
\renewcommand{\thetable}{A\arabic{table}}
\renewcommand*{\theHtable}{\thetable}
\begin{table}[htbp]
\centering
appendix table
\caption{Appendix Table}
\label{tab_appendix}
\end{table}
\end{document}
I am attempting to create a table in latex as below, although I am a bit confused about where and when the \multirow and \multicolumn commands are to be used inside a tabular environment. Col_1, Col_2, and Col_3 are supposed to be subheadings but they need to appear in the second row.
What I started off with is, (the columns are duplicated, so I wanted to split it into multiple rows as shown in the image) :
\begin{table}[H]
\begin{tabular}{lSSSSSSSS}
\toprule
\multirow{2}{*}{\textbf{A}} &
\multicolumn{3}{c}{\textbf{Model_1}} &
\multicolumn{5}{c}{\textbf{Model_2}} \\
& {Col_1} & {Col_2} & {Col_3} & {Col_1} & {Col_2} & {Col_3} & {Col_4} & {Col_5} \\
\midrule
x\% & a\% b\% & c\% & x\% & y\% & z\% & 0. & 0. \\
\bottomrule
\end{tabular}
\caption{results}
\end{table}
You can place your subheaders in a row of their own, no need to worry about mutirows and such
\documentclass{article}
\usepackage{siunitx}
%\usepackage{booktabs}
\usepackage{float}
\begin{document}
\begin{table}[H]
\begin{tabular}{l|S|S|S}
\textbf{A} & \multicolumn{3}{c}{x\%} \\
\hline
& {Col\_1} & {Col\_2} & {Col\_3} \\
Model\_1 & a\% & b\% & c\% \\
\hline
Model\_2 & x\% & y\% & z\% \\
\end{tabular}
\caption{results}
\end{table}
\end{document}
Instead of the layout you show in your image, I rather suggest to avoid vertical lines for a more professional looking result:
\documentclass{article}
\usepackage{siunitx}
\usepackage{booktabs}
\begin{document}
\begin{table}[htbp]
\centering
\begin{tabular}{#{}lSSSSSSSS#{}}
\toprule
\textbf{A} &
\multicolumn{3}{c}{\textbf{Model\_1}} &
\multicolumn{5}{c}{\textbf{Model\_2}} \\
& {Col\_1} & {Col\_2} & {Col\_3} & {Col\_1} & {Col\_2} & {Col\_3} & {Col\_4} & {Col\_5} \\
\cmidrule(r){2-4}\cmidrule(l){5-9}
x\% & a\% & b\% & c\% & x\% & y\% & z\% & 0. & 0. \\
\bottomrule
\end{tabular}
\caption{results}
\end{table}
\end{document}
I get a "misplaced \noaling" error within an tabularx environment if I am using \ifstrequal.
This is working:
\documentclass{article}
\usepackage{tabularx}
\usepackage{etoolbox}
\begin{document}
\begin{tabularx}{\textwidth}{rrrrr}
I & am & a & useless & table \\
\ifstrequal{a}{a}{
I & am & a & useless & table \\
} {
I & am & a & useless & table \\
}
\end{tabularx}
\end{document}
This not:
\documentclass{article}
\usepackage{tabularx}
\usepackage{etoolbox}
\begin{document}
\begin{tabularx}{\textwidth}{rrrrr}
I & am & a & useless & table \\
\ifstrequal{a}{a}{
\hline
I & am & a & useless & table \\
\hline
} {
I & am & a & useless & table \\
}
\end{tabularx}
\end{document}
You could resort to good old \ifx:
\documentclass{article}
\usepackage{tabularx}
\usepackage{booktabs}
\newcommand{\stringa}{a}
\newcommand{\stringb}{b}
\begin{document}
\begin{tabularx}{\textwidth}{rrrrr}
I & am & a & useless & table \\
\ifx\stringa\stringa
\midrule
I & am & a & useless & table \\
\midrule
\else
I & am & a & useless & table \\
\fi
\end{tabularx}
\end{document}
(I'm using rules from the booktabs package instead of \hline because they give better spacing)
I'm creating table from https://www.tablesgenerator.com/# but getting error with multirow:
! Undefined control sequence.
\#sharp ->\multirow {2}{*}{}
l.70 \multicolumn{3}{|l|}{\multirow{2}{*}{}}
I've tried removing the square brackets but didn't work.
\begin{table}[]
\begin{tabular}{lll}
\hline
\multicolumn{3}{|l|}{\multirow{2}{*}{}} \\
\multicolumn{3}{|l|}{} \\ \hline
& & \\
& & \\
& & \\
& &
\end{tabular}
\end{table}
I have all the packages installed. what can be done to resolve this please?
You need \usepackage{multirow} if you want to use \multirow:
\documentclass{article}
\usepackage{multirow}
\begin{document}
\begin{table}[htbp]
\begin{tabular}{lll}
\hline
\multicolumn{3}{|l|}{\multirow{2}{*}{}} \\
\multicolumn{3}{|l|}{} \\ \hline
& & \\
& & \\
& & \\
& &
\end{tabular}
\end{table}
\end{document}