编译错误:缺少插入$

编译错误:缺少插入$

我正在尝试编译这个:

 %\chapterimage{m2summary.pdf}
 \chapter{Respostas e soluções}
 \begin{multicols}{2}
 \section*{\textcolor{ocre}{1. Matrizes}}
 \subsection*{Exercícios de fixação}
 \begin{enumerate}[label=\arabic*.]
 \tiny{
 \item $\ds A=\begin{bmatrix} 0 & -1 & -2 \\ 1 & 0 & -1 \\ 2 & 1 & 0 \end{bmatrix}$
 }
 \end{enumerate}
 \end{multicols}

我将创建一个新文档并用于\include{filename}包含上述代码。在我的主 .tex 文件中,我使用这些包:

\documentclass[11pt,fleqn]{book}

\usepackage[top=3cm,bottom=3cm,left=3.2cm,right=3.2cm,headsep=10pt,a4paper]{geometry}

\usepackage{xcolor}
\definecolor{ocre}{RGB}{131,50,165}
\definecolor{yl}{RGB}{204,0,255}

% Font Settings
\usepackage{avant}
\usepackage{times}
\usepackage{mathptmx}
\usepackage{pifont,bbding}

\usepackage{microtype}
\usepackage[latin1]{inputenc}
\usepackage[brazilian]{babel}
\usepackage[T1]{fontenc}

% Bibliography
\usepackage[style=alphabetic,sorting=nyt,sortcites=true,autopunct=true,babel=hyphen,hyperref=true,abbreviate=false,backref=true,backend=biber]{biblatex}
\addbibresource{bibliography.bib}
\defbibheading{bibempty}{}

% Index
\usepackage{calc}
\usepackage{makeidx}
\makeindex

% Enumerate
%\usepackage{enumerate}

% Math
\usepackage{amsmath}

% Others
\usepackage{cancel,relsize}
\usepackage{pdfpages}
\usepackage{multicol}
\usepackage{xcolor,colortbl,subfigure}
\usepackage{stackrel}

% TikZ
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{shapes,snakes,calc,arrows}
\usetikzlibrary{intersections,through,backgrounds}
\usetikzlibrary{shapes.arrows,chains,positioning}
%\usetikzlibrary{shadows.blur}
\usetikzlibrary{matrix,decorations.pathmorphing}

\tikzstyle{dot}=[circle,fill,scale=0.4]
\tikzstyle{dote}=[circle,fill,scale=0.2]
\tikzstyle{doto}=[circle,draw=black,fill=white,scale=0.4]
\tikzstyle{dotred}=[circle,fill=ocre,scale=0.4]
\tikzstyle{dotrede}=[circle,fill=ocre,scale=0.5]
\tikzstyle{dotredo}=[circle,draw=ocre,fill=white,scale=0.5]
\tikzstyle{dotreda}=[circle,draw=ocre,fill=white,scale=0.4]
\tikzstyle{pre}=[<-,shorten >=1pt,>=stealth',semithick]

\tikzset{
    node style sp/.style={draw,circle,minimum size=1cm},
    node style ge/.style={circle,minimum size=1cm},
    node style spe/.style={draw,circle,minimum size=.4cm},
    node style gee/.style={circle,minimum size=.4cm},
    arrow style mul/.style={draw,sloped,midway,fill=white},
    arrow style plus/.style={midway,sloped,fill=white},
}



% Letras \mathbb
\newcommand{\NN}{\mathbb N}
\newcommand{\RR}{\mathbb R}
\newcommand{\ZZ}{\mathbb Z}
\newcommand{\CC}{\mathbb C}
\newcommand{\QQ}{\mathbb Q}
\newcommand{\PP}{\mathbb P}

% Operadores
\newcommand{\mdc}{\operatorname{mdc}}
\newcommand{\mmc}{\operatorname{mmc}}
\newcommand{\sen}{\operatorname{sen}}
\newcommand{\cotg}{\operatorname{cotg}}
\newcommand{\tg}{\operatorname{tg}}
\newcommand{\cossec}{\operatorname{cossec}}
\newcommand{\dom}{\operatorname{D}}
\newcommand{\cdom}{\operatorname{CD}}
\newcommand{\ima}{\operatorname{Im}}
\newcommand{\idx}{\operatorname{id}}
\newcommand{\idm}{\operatorname{I}}
\newcommand{\suchthat}{\;\ifnum\currentgrouptype=16 \middle\fi|\;}
\renewcommand{\CancelColor}{\color{ocre}}

% Comandos
\newcommand{\ds}{\displaystyle}
\newcommand{\tf}{\therefore}
\newcommand{\raw}{\Rightarrow}
\newcommand{\lfraw}{\Leftrightarrow}
\newcommand{\lfaw}{\Leftarrow}

% Gráficos
\makeatletter
\let\pgfmath@function@exp\relax % undefine old exp function
\pgfmathdeclarefunction{exp}{1}{%
  \begingroup
    \pgfmath@xc=#1pt\relax
    \pgfmath@yc=#1pt\relax
    \ifdim\pgfmath@xc<-9pt
      \pgfmath@x=1sp\relax
    \else
      \ifdim\pgfmath@xc<0pt
        \pgfmath@xc=-\pgfmath@xc
      \fi
      \pgfmath@x=1pt\relax
      \pgfmath@xa=1pt\relax
      \pgfmath@xb=\pgfmath@x
      \pgfmathloop%
        \divide\pgfmath@xa by\pgfmathcounter
        \pgfmath@xa=\pgfmath@tonumber\pgfmath@xc\pgfmath@xa%
        \advance\pgfmath@x by\pgfmath@xa
      \ifdim\pgfmath@x=\pgfmath@xb
      \else
        \pgfmath@xb=\pgfmath@x
      \repeatpgfmathloop%
      \ifdim\pgfmath@yc<0pt
        \pgfmathreciprocal@{\pgfmath@tonumber\pgfmath@x}%
        \pgfmath@x=\pgfmathresult pt\relax
      \fi
    \fi
    \pgfmath@returnone\pgfmath@x%
  \endgroup
}
\makeatother

% Distributiva
\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};}
\newcommand{\DrawBox}[2]{%
  \begin{tikzpicture}[overlay,remember picture]
    \draw[->,shorten >=5pt,shorten <=5pt,out=70,in=130,distance=0.5cm,#1] (MarkA.north) to (MarkC.north);
    \draw[->,shorten >=5pt,shorten <=5pt,out=50,in=140,distance=0.3cm,#2] (MarkA.north) to (MarkB.north);
  \end{tikzpicture}
}

\newcommand{\tikzmarklog}[1]{\tikz[overlay,remember picture] \node (#1) {};}
\newcommand{\DrawBoxlog}[2]{%
  \begin{tikzpicture}[overlay,remember picture]
    \draw[->,shorten >=5pt,shorten <=5pt,out=70,in=130,distance=0.5cm,#1] (MarkB.north) to (MarkC.north);
    \draw[->,shorten >=5pt,shorten <=5pt,out=50,in=140,distance=0.3cm,#2] (MarkA.south) to (MarkB.south);
  \end{tikzpicture}
}

% Matrices
\makeatletter
\renewcommand*\env@matrix[1][*\c@MaxMatrixCols c]{%
  \hskip -\arraycolsep
  \let\@ifnextchar\new@ifnextchar
  \array{#1}}
\makeatother

%----------------------------------------------------------------------------------------

\input{structure} % Insert the commands.tex file which contains the majority of the structure behind the template

\begin{document}

%----------------------------------------------------------------------------------------
%   TITLE PAGE
%----------------------------------------------------------------------------------------

\includepdf{capam2}
\phantom{a}{\thispagestyle{empty}}

%----------------------------------------------------------------------------------------
%   COPYRIGHT PAGE
%----------------------------------------------------------------------------------------

\newpage
~\vfill
\thispagestyle{empty}

\noindent Copyright \copyright\ 2013 X ao Cubo\\ % Copyright notice

\noindent \textsc{Publicado por X ao Cubo}\\ % Publisher

\noindent \textsc{XaoCubo.com}\\ % URL

%\noindent  % License information

%\noindent \textit{First printing, March 2013} % Printing/edition date

%----------------------------------------------------------------------------------------
%   TABLE OF CONTENTS
%----------------------------------------------------------------------------------------

\clearpage
\pagenumbering{roman}

\chapterimage{m2c1head.pdf} % Table of contents heading image

\pagestyle{empty} % No headers

\tableofcontents % Print the table of contents itself

\cleardoublepage % Forces the first chapter to start on an odd page so it's on the right

\pagestyle{fancy} % Print headers again


%----------------------------------------------------------------------------------------
%   CHAPTERS
%----------------------------------------------------------------------------------------

\cleardoublepage
\pagenumbering{arabic}

\include{filename}
\end{document} 

“最好的”部分是:我正在写一些书(我是一名数学老师)。这是第二本。第一本是我在大学编写的,而且它有效!——’于是我开始在家工作,使用 WinEdt 8 和最新版本的 MikTex,它显示了以下错误:

Missing $插入。怎么办?我尝试在没有文本的情况下进行编译,实际上,没有数学文本,但它一直显示缺少 $。我真的不知道该怎么办!

让我“高兴”的是:在家里编译第一本书(我在大学写的),它成功了!所以我复制、粘贴代码,更改需要更改的内容,但它仍然显示相同的错误消息!

很抱歉写了这么大的问题,但我不知道什么才是真正有助于帮助我的(哈哈),所以我决定把所有的代码都写在这里。

非常感谢!:D

答案1

您的代码可以简化为

\documentclass{article}
\usepackage[latin1]{inputenc}
\begin{document}
õ
\end{document}

仍然会抛出! Missing $ inserted.错误。我不知道“幕后”到底发生了什么,但这可能是由于您的编辑器使用的字符编码与 指定的字符编码不同inputenc。根据http://www.winedt.com/installing.html,WinEdt 8 默认使用 UTF-8,但您已将其设置latin1为输入编码。如果我在上面的代码中更改latin1为,它可以编译成功。utf8

确实,õ在 UTF-8 中是双字节字符0xC3 0xB5;第一个字节在单字节 Latin-1 编码中对应于\~A,而第二个字节对应于 ,\mu这就是导致错误的原因。

相关内容