Tabellenreferenzierung mit VS Code

Tabellenreferenzierung mit VS Code

Ich bin ziemlich neu bei LaTeX-Dokumenten und habe ein Problem mit Tabellenreferenzen. Zuvor habe ich im Atom.io-Editor kompiliert und erstellt und bin vor Kurzem zu VS Code gewechselt. Früher hat es funktioniert, aber jetzt macht es einen Referenzfehler mit der Tabelle!

Die Konsole sagt immer

Referenz „tab:table1“ auf Seite 2 undefiniert.

Ich verstehe nicht, warum das vorher funktioniert hat und jetzt nicht?

Es zeigt ???den \refWert.

Unten finden Sie einen minimalen Code zur Reproduktion dieses Problems. Ich habe IEEEtranfür mein Dokument eine Vorlage verwendet.

\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}

Bildbeschreibung hier eingeben

Antwort1

Sie müssen das Dokument mindestens zweimal kompilieren, damit die Referenzen korrekt sind. Ihr Code hat bei Overleaf einwandfrei funktioniert.

Ich empfehle jedoch, das Paket zu ladencleveref, wodurch Sie viel bessere Referenzen erhalten. Ich lade auch das PaketAnordnung.

Ich habe außerdem deinen Code bereinigt, den veralteten Befehl \bf\ in geändert \bfseriesund die dritte Spalte in eine p-Spalte geändert. Außerdem hattest du vier Spalten definiert, aber nur drei verwendet. Folglich habe ich die vierte Spalte entfernt.

Ich habe auch ein Beispiel 2 beigefügt, in dem ich verwendeBuchtabsum eine viel schönere Tabelle ohne vertikale Linien zu haben. Sofern es keine Anforderung Ihres Herausgebers ist, hätte ich die Überschrift über die Tabelle verschoben und das Paket verwendetUntertitelum es zu formatieren. Außerdem empfehle ich die Verwendung vondreiteiliger Tisch, um die Überschrift und die Tabelle am rechten Rand der Tabelle richtig auszurichten (zusätzlichdreiteiliger Tischbehandelt Tabellennotizen korrekt).

Beispiel 1

Bildbeschreibung hier eingeben

\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}

Beispiel 2 –Buchtabs,UntertitelUnddreiteiliger Tisch Bildbeschreibung hier eingeben

\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}

verwandte Informationen