使用 Texstudio/Miktex 编译项目时表格出现错误

使用 Texstudio/Miktex 编译项目时表格出现错误

我是 LaTeX 的初学者。我在 Windows 7 x64 上使用 TeX Studio 和 MikTeX。

我正在尝试为我的论文制作一些表格。我使用另一篇论文中的现有论文作为某种“模板”。但是,当我尝试编译项目时,在我编辑模板表之后,我论文中的所有表格都出现了相同的错误。附件中显示了这 4 个错误以及我的代码。抱歉,但我仍然无法在此处正确格式化我的帖子。

您知道这些错误的原因以及如何修复它们吗?

我附加了一个带有最少代码示例的 .txt 文件,其中用“此处发生了一些事情”代替了原始文本。

抱歉,我不符合规则。我是 Stackexchange 的 TeX 论坛的新手。

谨致问候,KingBaboon

最小工作代码:

\documentclass[review]{elsarticle}

\usepackage{lineno.hyperref}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{inputenc}
\modulolinenumbers[5]

\journal{Something goes here}

%%%%%%%%%%%%%%%%%%%%%%%
%% Elsevier bibliography styles
%%%%%%%%%%%%%%%%%%%%%%%
%% To change the style. put a % in front of the second line of the current style and
%% remove the % from the second line of the style you would like to use.
%%%%%%%%%%%%%%%%%%%%%%%

%% Numbered
%\bibliographystyle{model1-num-names}

%% Numbered without titles
%\bibliographystyle{model1a-num-names}

%% Harvard
%\bibliographystyle{model2-names.bst}\biboptions{authoryear}

%% Vancouver numbered
%\usepackage{numcompress}\bibliographystyle{model3-num-names}

%% Vancouver name/year
%\usepackage{numcompress}\bibliographystyle{model4-names}\biboptions{authoryear}
%% APA style
%\bibliographystyle{model5-names}\biboptions{authoryear}

%% AMA style
%\usepackage{numcompress}\bibliographystyle{model6-num-names}

%% `Elsevier LaTeX' style
\bibliographystyle{elsarticle-num}
%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}
\begin{frontmatter}

\title{Something goes here}%%\tnoteref{mytitlenote}}
%\tnotetext[mytitlenote]{Fully documented templates are available in the elsarticle package on \href{http://www.ctan.org/tex-archive/macros/latex/contrib/elsarticle}{CTAN}.}

%% Group authors per affiliation:
\author{Something goes here\fnref{myfootnote}}
\ead{[email protected]}
\address{Something goes here}


\section{Results}

Something goes here

\begin{figure}[h!]
    \centering 
    \includegraphics[width=6cm]{fig3.png}
    \caption{Something goes here}\label{fig3}
\end{figure}

Something goes here

\begin{table}[h!]
    \centering
    \caption{Something goes here}\label{t16}
    \scriptsize
    \begin{center}
        \begin{tabular}{|c|c|c|c|c|c|c|c}
            \hline 
            abc & a & b & c & aaa & bbb & ccc & ddd ($%$) \\ 
            \hline 
            0.09 & 55 & 0.0433 & -5.7E-03 & 6.79E-03 & 2.564 & 198.345 &  \\ \hline 
            0.09 & 57 & 0.0433 & -5.7-03 & 6.79E-03  & 2.564 & 198.345 & \\ \hline
            0.09 & 59 & 0.0433 & -5.7E-03 & 6.79E-03  & 2.564 & 198.345 & \\ \hline 
            0.09 & 51 & 0.0433 & -5.7E-03 & 6.79E-03  & 3.564 & 198.345 & \\ \hline 
            0.09 & 53 & 0.0433 & -5.7E-03 & 6.79E-03  & 3.564 & 198.345 & \\ \hline
            0.09 & 55 & 0.0433 & -5.7E-03 & 6.79E-03  & 3.564 & 198.345 & \\ \hline 
            0.09 & 57 & 0.0433 & -5.7E-03 & 6.79E-03  & 4.564 & 198.345 & \\ \hline 
            0.09 & 59 & 0.0433 & -5.7E-03 & 6.79E-03  & 4.564 & 198.345 & \\ \hline
            0.09 & 51 & 0.0433 & -5.7E-03 & 6.79E-03  & 4.564 & 198.345 & \\ \hline 

        \end{tabular} 
    \end{center}
\end{table} 

Something goes here.



\section{Results}


Something goes here.

\bibliography{mybibfile}

\end{document}

答案1

你的 mwe 有很多问题:

  • graphicx包已由 elsarticle 加载
  • 必须hyperref在序言中最后加载(极少数例外,这种情况不存在)
  • \begin{frontmatter}不封闭end{frontmatter}
  • 最后一列类型输入不正确(而ddd ($%$)必须是ddd ($\%$)或简单ddd (\%)
  • table环境中使用cantering, so also use\begin{center} ... \end{center}` 就足够了

修正这个问题后,结果就符合预期了:

在此处输入图片描述

\documentclass[review,demo]{elsarticle}
\usepackage[utf8]{inputenc}
%\usepackage[demo]{graphicx} % loaded by elsarticle
\usepackage{amsmath}
\usepackage{longtable}
\usepackage{lineno,hyperref}
\modulolinenumbers[5]
\journal{Something goes here}

\bibliographystyle{elsarticle-num}

\begin{document}
%\begin{frontmatter}    % it is not used in mwe

\title{Something goes here}

%% Group authors per affiliation:
\author{Something goes here\fnref{myfootnote}}
\ead{[email protected]}
\address{Something goes here}

\section{Results}
Something goes here
    \begin{figure}[h!]
    \centering
\includegraphics[width=6cm]{fig3.png}
    \caption{Something goes here}
\label{fig3}
    \end{figure}

Something goes here

\begin{table}[h!]
    \centering
    \caption{Something goes here}\label{t16}
    \scriptsize
%    \begin{center}  % surplus
        \begin{tabular}{|c|c|c|c|c|c|c|c|}
            \hline
            abc & a & b & c & aaa & bbb & ccc & ddd (\%) \\
            \hline
            0.09 & 55 & 0.0433 & -5.7E-03 & 6.79E-03 & 2.564 & 198.345  &  \\ \hline
            0.09 & 57 & 0.0433 & -5.7-03 & 6.79E-03  & 2.564 & 198.345  & \\ \hline
            0.09 & 59 & 0.0433 & -5.7E-03 & 6.79E-03  & 2.564 & 198.345 & \\ \hline
            0.09 & 51 & 0.0433 & -5.7E-03 & 6.79E-03  & 3.564 & 198.345 & \\ \hline
            0.09 & 53 & 0.0433 & -5.7E-03 & 6.79E-03  & 3.564 & 198.345 & \\ \hline
            0.09 & 55 & 0.0433 & -5.7E-03 & 6.79E-03  & 3.564 & 198.345 & \\ \hline
            0.09 & 57 & 0.0433 & -5.7E-03 & 6.79E-03  & 4.564 & 198.345 & \\ \hline
            0.09 & 59 & 0.0433 & -5.7E-03 & 6.79E-03  & 4.564 & 198.345 & \\ \hline
            0.09 & 51 & 0.0433 & -5.7E-03 & 6.79E-03  & 4.564 & 198.345 & \\ \hline
        \end{tabular}
%    \end{center} % surplus
\end{table}
Something goes here.

\section{Results}
Something goes here.

%\bibliography{mybibfile}  % not available

\end{document}

相关内容