I'm trying to compile this:

 \chapter{Respostas e soluções}
 \section*{\textcolor{ocre}{1. Matrizes}}
 \subsection*{Exercícios de fixação}
 \item $\ds A=\begin{bmatrix} 0 & -1 & -2 \\ 1 & 0 & -1 \\ 2 & 1 & 0 \end{bmatrix}$

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:




% Font Settings


% Bibliography

% Index

% Enumerate

% Math

% Others

% TikZ

\tikzstyle{pre}=[<-,shorten >=1pt,>=stealth',semithick]

    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{\suchthat}{\;\ifnum\currentgrouptype=16 \middle\fi|\;}

% Comandos

% Gráficos
\let\pgfmath@function@exp\relax % undefine old exp function
        \divide\pgfmath@xa by\pgfmathcounter
        \advance\pgfmath@x by\pgfmath@xa
        \pgfmath@x=\pgfmathresult pt\relax

% Distributiva
\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};}
  \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);

\newcommand{\tikzmarklog}[1]{\tikz[overlay,remember picture] \node (#1) {};}
  \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);

% Matrices
\renewcommand*\env@matrix[1][*\c@MaxMatrixCols c]{%
  \hskip -\arraycolsep


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






\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



\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




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

  • 1
    I think Your problem is related with babel package. Please look here: tex.stackexchange.com/questions/117732/tikz-and-babel-error
    – user31034
    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.
    – user31034
    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. Mar 9 '14 at 19:48

Your code can be reduced to


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.