Referência de tabela com código VS

Referência de tabela com código VS

Sou muito novo no documento LaTeX e estou tendo problemas com referências de tabelas. Anteriormente compilei e construí no editor Atom.io e recentemente mudei para o VS Code. Funcionou anteriormente, mas agora comete erro de referência na tabela!

O console continua dizendo

Referência 'tab:table1' na página 2 indefinida.

Não entendo por que isso funcionou anteriormente e agora não funciona?

Isso mostra ???o \refvalor.

Abaixo está um código mínimo para a reprodução deste problema. Usei IEEEtranmodelo para meu documento.

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

insira a descrição da imagem aqui

Responder1

É necessário compilar o documento pelo menos duas vezes para que as referências estejam corretas. Seu código funcionou perfeitamente no Overleaf.

No entanto, sugiro que você carregue o pacoteinteligente, o que o ajudará a obter referências muito melhores. Eu também carrego o pacotevariedade.

Também limpei seu código, alterei o comando depreciado \bf\ para \bfseriese alterei a terceira coluna para p-column. Além disso, você definiu quatro colunas, mas usou apenas três. Consequentemente, removi a quarta coluna.

Também incluí um exemplo 2 onde usoguias de livrospara ter uma tabela muito mais bonita, sem linhas verticais. A menos que seja uma exigência do seu editor, eu teria movido a legenda acima da tabela e usado o pacoterubricapara formatá-lo. Além disso, sugiro usarmesa de três partes, para alinhar a legenda e o tabular corretamente na margem direita do tabular (além disso,mesa de três parteslida corretamente com as notas da tabela).

Exemplo 1

insira a descrição da imagem aqui

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

Exemplo 2 –guias de livros,rubricaemesa de três partes insira a descrição da imagem aqui

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

informação relacionada