2

I'm trying to compile this:

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

I'm gonna create a new document and use \include{filename} to include the code above. At my main .tex file, I use these packages:

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

The "best" part is: I'm creating some books (I'm a math teacher). This is the second one. The first one I compiled at college AND IT WORKS! --' So then I started to work at home, using WinEdt 8 and the latest version of MikTex, and it shows the follow error:

Missing $ inserted. HOW? I tried to compile with no text, actually, with no math text, and it keeps showing that $ is missing. I really don't know what to do!

And what makes me "happy": compiling here, at home, the first book (that I wrote at college), it works! So I copy, paste the code, change what I have to change, but it stills show the same error message!

I'm so sorry for writing such a big question, but I don't know what really matters to help you to help me (lol), so I decided to write all the code here.

Thank you so much! :D

migrated from meta.tex.stackexchange.com Mar 6 '14 at 18:03

This question came from our discussion, support, and feature requests site for users of TeX, LaTeX, ConTeXt, and related typesetting systems.

  • 1
    I think Your problem is related with babel package. Please look here: tex.stackexchange.com/questions/117732/tikz-and-babel-error – ferahfeza Mar 6 '14 at 18:19
  • But when I compile another file (with the same main file, just changing the "subfiles") that I made in the college, it works! By the way, how should I use the babel for portuguese-br? Thanks! – mvfs314 Mar 6 '14 at 19:36
  • I think it is same character with ngerman babel, i.e {"}. Use same \tikzset environment described in the link above. – ferahfeza Mar 6 '14 at 20:00
  • 1
    Adding all the code is not the best option, it's better with a minimal example showing the problem. That is, code starting with \documentclass and ending with \end{document}, but containing only those packages and definitions, and the content necessary to reproduce the problem. Read more about creating such 'minimal working examples' at meta.tex.stackexchange.com/q/228 I can reduce your code to \documentclass{book} \usepackage[latin1]{inputenc} \begin{document} \chapter{soluções} \end{document} and still get that error. – Torbjørn T. Mar 9 '14 at 19:48
8

Your code can be reduced to

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

and it will still throw the ! Missing $ inserted. error. Exactly what happens 'behind the scenes' I don't know, but it may be that this is caused by your editor using a different character encoding than that specified for inputenc. According to http://www.winedt.com/installing.html, WinEdt 8 uses UTF-8 by default, but you've set latin1 as input encoding. If I change latin1 to utf8 in the above code it compiles fine.

Indeed, õ in UTF-8 is the two byte character 0xC3 0xB5; the first byte, in the one byte Latin-1 encoding corresponds to \~A, while the second one to \mu and this is the cause for the error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.