Я новичок в документах LaTeX и у меня проблема со ссылками на таблицы. Раньше я компилировал и строил в редакторе Atom.io, а недавно перешел на VS Code. Раньше это работало, но теперь выдает ошибку ссылки с таблицей!
Консоль продолжает говорить
Ссылка «tab:table1» на странице 2 не определена.
Я не понимаю, почему раньше это работало, а теперь нет?
Это показывает ???
ценность \ref
.
Ниже приведен минимальный код для воспроизведения этой проблемы. Я использовал IEEEtran
шаблон для своего документа.
\documentclass[conference,compsoc]{IEEEtran}
\begin{document}
\section{Introduction}
See \ref{tab:table1}\.
\begin{table}[ht] {\renewcommand\arraystretch{1.25}
\begin{tabular}{|l|l|l|l|} \hline
\bf Task & \bf Assignee & \bf \multicolumn{1}{l}{Description} \\ \hline
Project Manager & Alice & \multicolumn{1}{p{3.3cm}|}{\raggedright Schedule overall development plan and assign proper jobs to team members} \\ \hline
Consumer & Bob & \multicolumn{1}{p{3.3cm}|}{\raggedright Test and try out a prototype application, gather the potential improvement} \\ \hline
User & Chris & \multicolumn{1}{p{3.3cm}|}{\raggedright Gather basic feature requirement for this project by asking qeustioaires the eldery near the university.} \\ \hline
Developer & Daniel & \multicolumn{1}{p{3.3cm}|}{\raggedright Prepare a development environment for this project and build up the application} \\ \hline
\end{tabular}} \\
\caption{Task distribution for each participants of this project}
\label{tab:table1}
\end{table}
\end{document}
решение1
Вам нужно скомпилировать документ по крайней мере два раза, чтобы ссылки были правильными. Ваш код работал как по волшебству на Overleaf.
Однако я предлагаю вам загрузить пакетумный, что поможет вам получить гораздо лучшие ссылки. Я также загружаю пакетмножество.
Я также почистил ваш код, изменил устаревшую команду \bf
\ на \bfseries
и изменил третий столбец на -столбец p
. Кроме того, вы определили четыре столбца, но использовали только три. Следовательно, я удалил четвертый столбец.
Я также включил пример 2, где я используюзакладкииметь гораздо более приятную табличную форму без вертикальных линий. Если это не является требованием вашего издателя, я бы переместил заголовок над таблицей и использовал пакетподписьдля форматирования. Кроме того, я предлагаю использоватьтрехчастныйстол, чтобы правильно выровнять заголовок и таблицу по правому краю таблицы (кроме того,трехчастныйстолправильно обрабатывает заметки к таблице).
Пример 1
\documentclass[conference,compsoc]{IEEEtran}
\usepackage{cleveref, array}
\begin{document}
\section{Introduction}
See \cref{tab:table1}.
\begin{table}[ht] \renewcommand\arraystretch{1.25}
\begin{tabular}{|l|l|>{\raggedright\arraybackslash}p{3.3cm}|}
\hline
\bfseries Task & \bfseries Assignee & \multicolumn{1}{l|}{\bfseries Description} \\
\hline
Project Manager & Alice & Schedule overall development plan and assign proper jobs to team members \\
\hline
Consumer & Daniel & Test and try out a prototype application, gather the potential improvement \\
\hline
User & Bob & Gather basic feature requirement for this project by asking questionnaires the elderly near the university. \\
\hline
Developer & Chris & Prepare a development environment for this project and build up the application \\
\hline
\end{tabular} \\
\caption{Task distribution for each participants of this project%
\label{tab:table1}} %% Label inside caption
\end{table}
\end{document}
Пример 2 –закладки,подписьитрехчастныйстол
\documentclass[conference,compsoc]{IEEEtran}
\usepackage{cleveref, array, booktabs, threeparttable}
\usepackage[labelsep=period, font={footnotesize, sc}]{caption}
\begin{document}
\section{Introduction}
See \cref{tab:table1}.
\begin{table}[ht!] \renewcommand\arraystretch{1.25}
\begin{threeparttable}
\caption{Task distribution for each participants of this project%
\label{tab:table1}} %% Caption above tabular, label inside caption
\begin{tabular}{@{}l l>{\raggedright\arraybackslash}p{3.3cm}@{}}
\toprule
\bfseries Task & \bfseries Assignee & \multicolumn{1}{l}{\bfseries Description} \\
\midrule
Project Manager & Alice & Schedule overall development plan and assign proper jobs to team members \\
Consumer & Bob & Test and try out a prototype application, gather the potential improvement \\
User & Chris & Gather basic feature requirement for this project by asking questionnaires the elderly near the university. \\
Developer & Daniel & Prepare a development environment for this project and build up the application \\
\bottomrule
\end{tabular}
\end{threeparttable}
\end{table}
\end{document}