我有一个 LaTeX 代码,它在特定行出现以下错误:
Incomplete \iffalse; all text was ignored after line 140.
Forbidden control sequence found while scanning text of \write.
在第 140 行
然后在文档末尾:
Argument of \@gobble has an extra }. \end{document}
Missing } inserted. \end{document}
- ETC。
以下代码引发了错误(第 140 行y[ row[i] ] += ...
)\section{COO Kernel}
:
\documentclass[11pt,oneside,czech,american]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[a4paper]{geometry}
\geometry{verbose,tmargin=4cm,bmargin=3cm,lmargin=3cm,rmargin=2cm,headheight=0.8cm,headsep=1cm,footskip=0.5cm}
\pagestyle{headings}
\setcounter{secnumdepth}{3}
\usepackage{url}
\usepackage{listings}
\usepackage{textcomp}
\usepackage{amsmath}
\usepackage{xcolor}
\makeatletter
\newenvironment{lyxlist}[1]
{\begin{list}{}
{\settowidth{\labelwidth}{#1}
\setlength{\leftmargin}{\labelwidth}
\addtolength{\leftmargin}{\labelsep}
\renewcommand{\makelabel}[1]{##1\hfil}}}
{\end{list}}
\usepackage[varg]{txfonts}
\usepackage{indentfirst}
\clubpenalty=9500
\widowpenalty=9500
\hyphenation{CDFA HARDI HiPPIES IKEM InterTrack MEGIDDO MIMD MPFA DICOM ASCLEPIOS MedInria}
\definecolor{light-gray}{gray}{0.95}
\newcommand{\code}[1]{\colorbox{light-gray}{\texttt{#1}}}
\definecolor{listinggray}{gray}{0.9}
\definecolor{lbcolor}{rgb}{0.9,0.9,0.9}
\definecolor{Darkgreen}{rgb}{0.0, 0.2, 0.13}
\lstset{
backgroundcolor=\color{lbcolor},
tabsize=4,
language=[GNU]C++,
basicstyle=\scriptsize,
upquote=true,
aboveskip={0.001\baselineskip},
columns=fixed,
showstringspaces=false,
extendedchars=false,
breaklines=true,
prebreak = \raisebox{0ex}[0ex][0ex]{\ensuremath{\hookleftarrow}},
frame=single,
numbers=left,
showtabs=false,
showspaces=false,
showstringspaces=false,
identifierstyle=\ttfamily,
keywordstyle=\color[rgb]{0,0,1},
commentstyle=\color[rgb]{0.026,0.112,0.095},
stringstyle=\color[rgb]{0.627,0.126,0.941},
numberstyle=\color[rgb]{0.205, 0.142, 0.73},
}
\lstset{
backgroundcolor=\color{lbcolor},
tabsize=4,
language=C++,
captionpos=b,
tabsize=3,
frame=lines,
numbers=left,
numberstyle=\tiny,
numbersep=5pt,
breaklines=true,
showstringspaces=false,
basicstyle=\footnotesize,
keywordstyle=\color[rgb]{0,0,1},
commentstyle=\color{Darkgreen},
stringstyle=\color{red},
}
\lstset{
morekeywords={__global__},
alsoletter={.},
morekeywords={blockDim.x},
morekeywords={blockIdx.x},
morekeywords={threadIdx.x}
}
\usepackage{babel}
\begin{document}
\tableofcontents{}
\chapter*{Implementation/Kernels of formats}
\addcontentsline{toc}{chapter}{Implementation/Kernels of formats}
\setcounter{chapter}{3}
\setcounter{section}{0}
\section{DIAG Kernel}
\begin{lstlisting}[caption= SpMV pseudocode using DIAG format for storing a matrix from \textit{Efficient sparse matrix-vector multiplication on CUDA} \cite{Bell-Garland}.]
__global__ void
spmv_dia_kernel ( const int num_rows,
const int num_cols,
const int num_diags,
const int * offsets,
const float * data,
const float * x,
float * y )
{
int row = blockDim.x * blockIdx.x + threadIdx.x;
if ( row < num_rows ){
float dot = 0;
for ( int n = 0; n < num_diags; n++ ){
int col = row + offsets[ n ];
float val = data[ num_rows * n + row ];
if ( col >= 0 && col < num_cols )
dot += val * x[ col ];
}
y[ row ] += dot;
}
}
\end{lstlisting}
\label{Code:Diagonal-matrix-example}
\section{COO Kernel}
\begin{lstlisting}[caption= SpMV pseudocode using COO format for storing a matrix \cite{Parallel-Uppsala}.]
__global__ void
spmv_coo_kernel ( const int num_non_zero_elements,
const float * data,
const int * row,
const int * col,
const float * x,
float * y )
{
int i = blockDim.x * blockIdx.x + threadIdx.x;
if ( row < num_non_zero_elements )
y[ row[i] ] += data[i] * x[ col[i] ];
}
\end{lstlisting}
\section{ELL Oriented Kernels}
\subsection{ELL Kernel}
\begin{lstlisting}[caption = SpMV pseudocode using ELL format for storing a matrix from \textit{Efficient sparse matrix-vector multiplication on CUDA} \cite{Bell-Garland}.]
__global__ void
spmv_ell_kernel ( const int num_rows,
const int num_cols,
const int num_cols_per_row,
const int * indices,
const float * data,
const float * x,
float * y )
{
int row = blockDim.x * blockIdx.x + threadIdx.x;
if( row < num_rows ){
float dot = 0;
for ( int n = 0; n < num_cols_per_row; n++ ){
int col = indices[ num_rows * n + row ];
float val = data[ num_rows * n + row ];
if ( val != 0 )
dot += val * x[ col ];
}
y[ row ] += dot;
}
}
\end{lstlisting}
\begin{thebibliography}{1}
\bibitem{Bell-Garland}N Bell, M. Garland: \emph{Efficient sparse matrix-vector multiplication on CUDA}. NVIDIA Technical Report NVR-2008-004, NVIDIA Corporation, 1-32, 2008.
\bibitem{Parallel-Uppsala}D. Lukarski: \emph{Sparse Matrix-Vector Multiplication and Matrix Formats}. Parallel Algorithms for Scientific Computing, Uppsala University, 2013. \url{https://www.it.uu.se/education/phd_studies/phd_courses/pasc/lecture-1}
\end{thebibliography}
\end{document}
由于某种原因,对bibitem
s 的引用未定义,即使似乎没有任何拼写错误。
如果我回滚导致错误的更改,为了正确编译文档,我必须删除.aux
和.toc
文件。
我简直傻眼了。
PS:该序言是一位教授创建的,作为所有学生使用的模板,我被告知不要对其进行改动。
[编辑]:按照建议创建最小的相同错误输出示例。
[编辑]:添加日志文件。
[编辑]:删除了 GitHub 链接、完整项目链接和日志文件链接,因为它们对于答案来说不是必需的。我会把它们放在单独的文件夹如果有人想看的话,我不会删除它。如果由于任何原因链接被破坏,请告诉我,我会以某种方式更新它们,因为我也会保留所述文件的备份。
答案1
解决这个问题的方法是在用户和管理员模式下更新我的 MiKTeX,就像@UlrikeFischer 所说的那样:
更新您的 tex 系统 - 最重要的是列表包。使用最新版本,它再次运行。(在用户和管理员模式下检查更新)。
对于窃取答案表示抱歉,我只是想关闭这个已解决的问题,而不是进一步发送垃圾邮件,要求将评论作为答案。
如果您希望我接受您的回答,请随时回答,我会接受。