我在正文中引用了附录表格。根据我放置标签的位置,我要么
- 收到一条错误消息,提示引用未定义(并且正文为“表格??”)
- 使用整个部分的名称引用表格,因此它是“表格 B”而不是“表格 B1”(该表格出现在附录的 B 部分)。
有人可以让我知道我做错了什么吗?以下是说明第一种情况的 MWE ('Table ??'):
\documentclass[12pt]{article}
\usepackage{amssymb, hyperref, amsmath,amsfonts, bm, eurosym,geometry,ulem,graphicx,caption,mathtools,natbib, xcolor,setspace,comment,footmisc,caption,pdflscape,subfigure,array, parskip, bbm, csquotes, multirow, booktabs,caption}
\usepackage[flushleft]{threeparttable}
\usepackage[toc,page]{appendix}
\graphicspath{ {./images/} }
\newcommand{\red}[1]{{\color{red} #1}}
\newcommand{\blue}[1]{{\color{blue} #1}}
\geometry{left=1.0in,right=1.0in,top=1.0in,bottom=1.0in}
\begin{document}
Here is some text. I will try to reference Table \ref{overview}
\clearpage
\setlength{\bibhang}{0pt}
\bibliographystyle{apalike}
\bibliography{bibliography.bib}
\newpage
\setcounter{table}{0}
\renewcommand{\thetable}{A\arabic{table}}
\setcounter{figure}{0}
\renewcommand{\thefigure}{A\arabic{figure}}
\begin{appendices}
\section{Proofs} \label{proofs}
Here are some proofs
\newpage
\section{Additional tables and figures} \label{tables_figures}
\setcounter{table}{0}
\renewcommand{\thetable}{B\arabic{table}}
\setcounter{figure}{0}
\renewcommand{\thefigure}{B\arabic{figure}}
\begin{center}
\begin{threeparttable}[h]
\begin{tabular}{cclcc}
\hline
\caption{Overview}\label{overview}
Moose & Rabbit & \hspace{3em}Deer & Elephant & Mango \\ \hline
1 & Yes & a & 10 & 18 \\
2 & Yes & b & 10 & 18 \\
3 & No & c & 10 & 10 \\
4 & No & d & 10 & 10 \\
5 & No & e & 9 & 10 \\
6 & No & e & 9 & 10 \\ \hline
\end{tabular}
\begin{tablenotes}
\footnotesize
\item \hspace{-0.2em}\textit{Notes}: Here are some notes...
\end{tablenotes}
\end{threeparttable}
\end{center}
\end{appendices}
\end{document}
下面是说明第二种情况 ('表 B') 的 MWE:
\documentclass[12pt]{article}
\usepackage{amssymb, hyperref, amsmath,amsfonts, bm, eurosym,geometry,ulem,graphicx,caption,mathtools,natbib, xcolor,setspace,comment,footmisc,caption,pdflscape,subfigure,array, parskip, bbm, csquotes, multirow, booktabs,caption}
\usepackage[flushleft]{threeparttable}
\usepackage[toc,page]{appendix}
\graphicspath{ {./images/} }
\newcommand{\red}[1]{{\color{red} #1}}
\newcommand{\blue}[1]{{\color{blue} #1}}
\geometry{left=1.0in,right=1.0in,top=1.0in,bottom=1.0in}
\begin{document}
Here is some text. I will try to reference Table \ref{overview}
\clearpage
\setlength{\bibhang}{0pt}
\bibliographystyle{apalike}
\bibliography{bibliography.bib}
\newpage
\setcounter{table}{0}
\renewcommand{\thetable}{A\arabic{table}}
\setcounter{figure}{0}
\renewcommand{\thefigure}{A\arabic{figure}}
\begin{appendices}
\section{Proofs} \label{proofs}
Here are some proofs
\newpage
\section{Additional tables and figures} \label{tables_figures}
\setcounter{table}{0}
\renewcommand{\thetable}{B\arabic{table}}
\setcounter{figure}{0}
\renewcommand{\thefigure}{B\arabic{figure}}
\begin{center}
\begin{threeparttable}[h]
\begin{tabular}{cclcc}
\hline
\caption{Overview}
Moose & Rabbit & \hspace{3em}Deer & Elephant & Mango \\ \hline
1 & Yes & a & 10 & 18 \\
2 & Yes & b & 10 & 18 \\
3 & No & c & 10 & 10 \\
4 & No & d & 10 & 10 \\
5 & No & e & 9 & 10 \\
6 & No & e & 9 & 10 \\ \hline
\end{tabular}
\begin{tablenotes}
\footnotesize
\item \hspace{-0.2em}\textit{Notes}: Here are some notes...
\end{tablenotes}
\end{threeparttable}
\label{overview}
\end{center}
\end{appendices}
\end{document}
答案1
LaTeX 必须发出两个与表相关的单独的错误消息。
\caption
不允许在 LaTeX 浮点数之外使用指令(例如table
和figure
)。\caption
环境内不允许使用指令tabular
。
补救措施?(a)将threeparttable
材料放入环境中table
。(b)\caption
从当前位置移除指令并将其插入到后面\begin{threeparttable}
。
\documentclass[12pt]{article}
%% I've left some comments next to some of your preamble directives
\usepackage{amssymb,
hyperref,
%amsmath, % is loaded automatically by mathtools
%amsfonts, % is loaded automatically by amssymb
bm, eurosym, geometry, ulem, graphicx, caption,
mathtools, natbib, xcolor, setspace, comment,
footmisc,
%%caption, % don't load packages twice
pdflscape,
%%subfigure, % obsolete and incompatible with caption package
array, parskip, bbm, csquotes, multirow, booktabs %,
%%caption % and most definitely don't load a package three times!
}
\captionsetup{skip=0.333\baselineskip} % <-- new (default is '1\baselineskip')
\hypersetup{colorlinks=true, allcolors=blue} % <-- new
\usepackage[flushleft]{threeparttable}
\usepackage[toc,page]{appendix}
\graphicspath{ {./images/} }
\newcommand{\red}[1]{{\color{red} #1}}
\newcommand{\blue}[1]{{\color{blue} #1}}
%% "margin=1in" is a lot easier than "left=1.0in,right=1.0in,top=1.0in,bottom=1.0in"
\geometry{margin=1in}
\begin{document}
\begin{appendices}
\renewcommand{\thetable}{\thesection\arabic{table}}
\renewcommand{\thefigure}{\thesection\arabic{figure}}
\section{Proofs} \label{proofs}
Here are some proofs
\newpage
\section{Additional tables and figures} \label{tables_figures}
\begin{table}[ht] % <-- new
\centering % <-- new
\begin{threeparttable}
\caption{Overview} % <-- new location
\label{overview}
\begin{tabular}{@{} cclcc @{}}
\toprule
Moose & Rabbit & Deer & Elephant & Mango \\
\midrule
1 & Yes & a & 10 & 18 \\
2 & Yes & b & 10 & 18 \\
3 & No & c & 10 & 10 \\
4 & No & d & 10 & 10 \\
5 & No & e & 9 & 10 \\
6 & No & e & 9 & 10 \\
\bottomrule
\end{tabular}
\footnotesize
\begin{tablenotes}
\item[]\hspace{-0.2em}\textit{Notes}: Here are some notes \dots
\end{tablenotes}
\end{threeparttable}
\end{table} % <-- new
A cross-reference to \autoref{overview}.
\end{appendices}
\end{document}