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 would like to create a table like the following:
in which only one column has a color and the color is applied to alternate rows.
The basic table would be:
\documentclass{article}
\usepackage{siunitx}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{multirow}
\usepackage{float}
\usepackage[margin=2cm,left=2.5cm,includefoot]{geometry}
\begin{document}
\begin{table}[!h]
\centering
\caption{HS Sections}
\begin{tabular}{ccc}
& node & degree \\
\hline
& 1 & 1 \\
& 2 & 2 \\
& 3 & 2 \\
& 4 & 4 \\
& 5 & 2 \\
& 6 & 2 \\
& 7 & 1 \\
\hline
\end{tabular}
\label{tab:Table}
\end{table}
\end{document}
You could either manually use \cellcolor{...} to colour the cells you want or you could cheat a bit by colouring the whole rows in alternate colours and then overpaint the cells of the first column with white:
\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{siunitx}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{multirow}
\usepackage{float}
\usepackage[margin=2cm,left=2.5cm,includefoot]{geometry}
\begin{document}
\begin{table}[!h]
\centering
\caption{HS Sections}
\rowcolors{2}{cyan!50}{white}
\begin{tabular}{>{\cellcolor{white}}cc}
node & degree \\
\hline
1 & 1 \\
2 & 2 \\
3 & 2 \\
4 & 4 \\
5 & 2 \\
6 & 2 \\
7 & 1 \\
\hline
\end{tabular}
\label{tab:Table}
\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 need to use \footnote in a minipage environment, but it always gives an error
Command \itshape invalid in math mode. a\footnote{
mwe is
\documentclass{cta-author}
\begin{document}
\begin{table}
\begin{minipage}{\columnwidth}
\begin{tabular}{|c|c|}
\hline
Column 1 & Column2 \\
a\footnote{footnote example} & b\\
\hline
\end{tabular}
\end{minipage}
\end{table}
\end{document}
Latex class file is here
You can redefine the way cta-author makes the footnote mark. Instead of $^{...}$, use \textsuperscript{...}:
\documentclass{cta-author}
\makeatletter
\def\#makefnmark{\textsuperscript{\#thefnmark}}
\makeatother
\begin{document}
\begin{table}
\begin{minipage}{\columnwidth}
\begin{tabular}{|c|c|}
\hline
Column 1 & Column2 \\
a\footnote{footnote example} & b \\
\hline
\end{tabular}
\end{minipage}
\end{table}
% A possible work-around
\begin{table}
\begin{tabular}{|c|c|}
\hline
Column 1 & Column2 \\
a$^*$ & b \\
\hline
\end{tabular}
\medskip
\footnoterule
{\itshape\footnotesize $^*$footnote example}
\end{table}
\end{document}
And here is a visual of the work-around:
I am having problems with my threeparttable notes as they are somehow not covering the entire width of my table. Can anybody help me? Thank you already in advance!
Here is the code I use:
\documentclass[11pt, oneside]{article}
\usepackage{geometry}
\geometry{letterpaper}
\usepackage{graphicx}
\usepackage{lscape}
\usepackage{booktabs}
\usepackage{amssymb}
\usepackage[flushleft]{threeparttable}
\usepackage{longtable}
\usepackage{array}
\usepackage{pdflscape}
\usepackage{tabularx}
\usepackage{adjustbox}
\pagenumbering{gobble}
\usepackage{booktabs}
\begin{document}
{
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\begin{table}
\scalebox{0.6}{
\begin{threeparttable}
\begin{tabularx}
\textwidth{lccccccccc}
& \textbf{Neonatal} & \textbf{Infant} & \textbf{Low} \\
& \textbf{Mortality} & \textbf{Mortality} & \textbf{Birthweight} & \textbf{Stunting} & \textbf{Underweight} &\\
\multicolumn{10}{c}{\noindent\rule{18cm}{0.4pt}}\\
\textit{Mother is between 17 and 19 yrs} & -0.00517*** & -0.00857*** & -0.00896** & -0.0487*** & -0.0315*** \\
& [0.001] & [0.002] & [0.004] & [0.005] & [0.004] \\
\multicolumn{10}{c}{\noindent\rule{18cm}{0.2pt}}\\
\textbf{N} & 752543 & 574609 & 399845 & 501520 & 512482 \\
\multicolumn{10}{c}{\noindent\rule{18cm}{0.4pt}}\\
\end{tabularx}
\begin{tablenotes}
\item Results are from the main results regressions (4). ***, ** and * denote significance at the 1\%, 5\%, and 10\% levels, respectively. Std. Errors in square brackets and are clustered at PSU level.
\end{tablenotes}
\end{threeparttable}
}
\end{table}
}
\end{document}
I know it's been years since your question, I am learning creating tables right now that's how I've found this question.
I think you confused the threeparttable package by declaring 10 colunms, while you have only 6 in reality. Why don't you try using 6 columns and then some way linebreak the headers and long cells instead?
\documentclass[11pt, oneside]{article}
\usepackage{geometry}
\geometry{letterpaper}
\usepackage{graphicx}
\usepackage{lscape}
\usepackage{booktabs}
\usepackage{amssymb}
\usepackage[flushleft]{threeparttable}
\usepackage{longtable}
\usepackage{array}
\usepackage{pdflscape}
\usepackage{tabularx}
\usepackage{adjustbox}
\pagenumbering{gobble}
\usepackage{booktabs}
\usepackage{makecell}
\renewcommand\theadalign{bc}
\renewcommand\theadfont{\bfseries}
\renewcommand\theadgape{\Gape[4pt]}
\renewcommand\cellgape{\Gape[4pt]}
\begin{document}
{
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\begin{table}
\scalebox{0.8}{
\begin{threeparttable}
\begin{tabularx}
{16.5cm}{lccccc}
{} & \thead{Neonatal \\ Mortality} & \thead{Infant \\ Mortality} & \thead{Low \\ Birthweight} & \thead{Stunting} & \thead{Underweight} \\
\midrule
{\shortstack[l]{\textit{Mother is between} \\ \textit{17 and 19 yrs}}} & {\shortstack[c]{ $-0.00517$*** \\ $[0.001] $ }} & {\shortstack[c]{$ -0.00857$*** \\ $[0.002] $}} & {\shortstack[c]{$ -0.00896$** \\ $[0.004]$}} & {\shortstack[c]{$ -0.0487$*** \\ $[0.005]$}} & {\shortstack[c]{$-0.0315$*** \\ $[0.004]$}} \\
\midrule
\textbf{N} & 752543 & 574609 & 399845 & 501520 & 512482 \\
\midrule
\end{tabularx}
\begin{tablenotes}
\item Results are from the main results regressions (4). ***, ** and * denote significance at the 1\%, 5\%, and 10\% levels, respectively. Std. Errors in square brackets and are clustered at PSU level.
\end{tablenotes}
\end{threeparttable}
}
\end{table}
}