Missing inserted latex ошибка

I try to write the following in latex:

\begin{itemize}
    \item \textbf{insert(element|text)} inserts the element or text passed at the start of the selection.
    \item \textbf{insert_after(element|text)} inserts the element or text passed at the end of the selection.
    \item \textbf{replace(element|text)} replaces the selection with the passed text/element.
    \item \textbf{delete()} deletes the selected text.
    \item \textbf{annotate(name,value)} annotates the selected text with the passed name and value-pair. This can either be a hidden meta-data about the selection, or can alter the visible appearance.
    \item \textbf{clear_annotation()} removes any annotation for this specific selection.
    \item \textbf{update_element(value)} performs an update of the element at the selection with the passed value.
\end{itemize}

For some reason, I get a bunch of errors. I think there is something with the use of the word «insert». I get errors like «Missing $ inserted», so it seems like the parses tries to fix some «errors» on my parts. Do I need to escape words like «insert», how do I do that?

asked Mar 19, 2010 at 11:34

Espen Herseth Halvorsen's user avatar

The «Missing $ inserted» is probably caused by the underscores and bars. These characters in LaTeX have special meaning in math mode (which is delimited by $ characters). Try escaping them; e.g. update\_element instead of update_element.

However, if you’re trying to display code, a better solution would be to use the \verb command, which will typeset the text in a monospaced font and will automatically handle underscores and bars correctly (no need to escape them with \).

answered Mar 19, 2010 at 11:41

Will Vousden's user avatar

Will VousdenWill Vousden

32.5k9 gold badges84 silver badges95 bronze badges

1

It’s actually the underscores. Use \_ instead, or include the underscore package.

answered Mar 19, 2010 at 11:42

Nietzche-jou's user avatar

Nietzche-jouNietzche-jou

14.4k4 gold badges34 silver badges45 bronze badges

2

I had this problem too. I solved it by removing the unnecessary blank line between equation tags. This gives the error:

\begin{equation}
P(\underline{\hat{X}} | \underline{Y}) = ...

\end{equation}

while this code compiles succesfully:

\begin{equation}
P(\underline{\hat{X}} | \underline{Y}) = ...
\end{equation}

answered Dec 21, 2012 at 9:03

Utku Özdemir's user avatar

Utku ÖzdemirUtku Özdemir

7,4102 gold badges52 silver badges49 bronze badges

1

also, I had this problem but the bib file wouldn’t recompile. I removed the problem, which was an underscore in the note field, and compiled the tex file again, but kept getting the same errors. In the end I del’d the compiled bib file (.bbl I think) and it worked fine. I had to escape the _ using a backslash.

answered Jul 21, 2011 at 16:38

Adrian's user avatar

AdrianAdrian

811 silver badge1 bronze badge

1

I had the same problem — and I have read all these answers, but unfortunately none of them worked for me. Eventually I tried removing this line

%\usepackage[latin1]{inputenc}

and all errors disappeared.

gariepy's user avatar

gariepy

3,5766 gold badges21 silver badges34 bronze badges

answered May 11, 2016 at 22:16

Matrix Software's user avatar

1

My first guess is that LaTeX chokes on | outside a math environment. Missing $ inserted is usually a symptom of something like that.

answered Mar 19, 2010 at 11:41

High Performance Mark's user avatar

1

You can also get this error if you use special character greek letters like \alpha \beta and so on outside of math mode.
After i wrapped them in \(…\) the error was gone.

answered Jan 21, 2018 at 22:43

Alphacoder's user avatar

AlphacoderAlphacoder

2992 silver badges10 bronze badges

3

I think it gives the error because of the underscore symbol.

Note : underscore symbol should not be written directly, you have to write like as \_.

So fix these kind special symbol errors.

Mark Rotteveel's user avatar

answered Dec 22, 2017 at 11:16

Achilles Ram Nakirekanti's user avatar

In my code, when I got the error, I checked the possible source, In a line, I had typed a beginning \[ and an ending \] due to which the error of missing $ appeared though I tried using $ for both the brackets. Removing the brackets or using $[$ instead of $\[$ solved my problem. If you’ve something like that, try altering.

answered Jun 7, 2018 at 12:28

Bhanu Chander's user avatar

Bhanu ChanderBhanu Chander

3901 gold badge6 silver badges16 bronze badges

I had this symbol _ in the head of one table and the code didn’t run, so I had to delete.

answered Feb 20, 2018 at 22:31

Edwin Torres's user avatar

My case was similar to Adrian’s. It was an incorrectly written online bib source.

I had

 @online{some_pretty_website, 
    title={Pretty Website}, 
    url={https://www.prettywebsite.com/foo_bar.pdf}
 } 

I had to escape the «_» symbol in the url

 @online{some_pretty_website, 
    title={Pretty Website}, 
    url={https://www.prettywebsite.com/foo\_bar.pdf}
 } 

answered Dec 3, 2022 at 17:29

pink_demon's user avatar

How to fix this error

This error can be triggered in different ways and, especially for those new to LaTeX, it’s not always immediately obvious why it happened, or, more importantly, how to resolve it. We’ll start with an overview of the general conditions which trigger this error then list some of the more common causes and how to fix them. The latter parts of this article offer more in-depth material for readers wishing to broaden their understanding.

Note: In this article we use the terms “TeX”, “LaTeX” and “TeX engine” but if you aren’t sure of their different meanings you can find out in the Overleaf article What’s in a Name: A Guide to the Many Flavours of TeX.

The main causes of Missing $ inserted

There are three main reasons why (La)TeX generates this error:

  1. You’ve made an explicit error in your math markup, such as writing $y=f(x)$$—we look at other examples later in this article.
  2. TeX has detected a character or command designed to be used only when TeX is typesetting mathematics but that character or command has been used when TeX was not typesetting mathematics.
    • TeXnically speaking: TeX detected a character or command designed to work inside math mode but you’ve tried to use it outside math mode. To clarify the issue with “characters” designed to work in math mode, what we really mean is using characters assigned certain category codes designed to operate inside mathematical material.
  3. TeX has detected a command designed to be used only when TeX is not typesetting mathematics but that command was detected (used) whilst TeX was typesetting mathematical material.
    • TeXnically speaking: TeX detected a command designed to work outside math mode but you’ve tried to use it inside math mode.

Examples of errors and their solutions

The following examples demonstrate some ways in which the Missing $ inserted error can be triggered, together with providing solutions to resolve the error.

Symbol commands must be used in math mode

Many math symbols in LaTeX are accessed using commands which must only be used when TeX is typesetting math; i.e., at a time when TeX is in math mode.

Examples of commonly-used symbol commands include those for Greek letters: \alpha \((\alpha)\), \beta \((\beta)\), \gamma (\(\gamma)\), \delta \((\delta)\), \Delta \((\Delta)\) and so forth. Many other LaTeX commands, such as those for modifiers: \vec{x} \((\vec{x})\), \tilde{x} \((\tilde{x})\), \hat{x} \((\hat{x})\) etc., are also designed for use in math mode.

Using modifiers, symbol commands—and many other math-related commands—outside of typesetting mathematical content will generate a Missing $ inserted error and force the compiler to enter into math mode.

The following example shows what happens if you try to use the command \alpha \((\alpha)\) outside of math (mode):

Writing \verb|\alpha| outside math mode will generate an error: \alpha and so this text will not be typeset correctly...

 Open this error-producing example in Overleaf

The following image shows part of the output produced by the LaTeX code above, demonstrating the error caused by using \alpha outside of math mode:

\alpha outside math mode

Fixing errors caused by LaTeX symbol commands

To use modifiers, or Greek math symbols, within sentences they must always be wrapped in single dollar signs $...$, or LaTeX’s \(...\) syntax, in order for TeX to process them in inline math mode, as shown below.

When writing the Greek letter alpha in a sentence, it must be written as \verb|$\alpha$| to generate $\alpha$,  or as \verb|\(\alpha\)| which also generates \(\alpha\).
 
When writing a vector x in a sentence, it must be written as \verb|$\vec{x}$| to produce $\vec{x}$ or as \verb|\(\vec{x}\)| which also yields \(\vec{x}\).

 Open this example in Overleaf

A list of LaTeX symbols

The Overleaf article List of Greek letters and math symbols provides a list of symbols which are exclusive to math mode, together with links to further useful resources.

Using math-mode-only characters outside math mode

Traditionally, TeX/LaTeX reserve certain common characters for use within math mode:

  • ^: reserved for creating superscripts
  • _: reserved for creating subscripts
  • $: reserved for starting/stopping math mode

Using them directly outside math mode triggers errors.

  • To type $ outside math mode use \$
  • To type _ outside math mode use \_
  • Multiple ways to type ^ outside math mode. A list is provided on tex.stackexchange
Using underscores outside of math mode

A common cause of the Missing $ inserted error is using underscores (_), a math mode character, outside of math mode—such as underscores present in filenames: an example of this is shown below.

Using a math character, such as an underscore, in a file name: math_example.tex.

 Open this error-generating code on Overleaf

Because the underscore character is assigned category code 8 it is reserved for creating subscripts when the TeX engine is in math mode. Consequently, when (La)TeX detects the _ in the file name math_example.tex it does so outside of math mode, which triggers an error and results in erroneous typesetting of subsequent text:

\(\text{Using a math character, such as an underscore, in a file name: math}_example.tex.\)

The _ character (technically its category code of 8) triggers an error and causes TeX to enter math mode: the letter e following immediately after the _ is treated as a character to be typeset as a subscript. Processing then continues in math mode resulting in the italicized text and, additionally, there is no way here for TeX to gracefully exit math mode, which will trigger further errors.

In order to avoid this particular error, you must always use _ in math mode—i.e., inside $..$, $$...$$ or, preferably, inside LaTeX’s notation of \(...\) and \[...\].

Outside math mode you need to write \_ to use or typeset an underscore, as shown in the corrected version of the example:

To use the math-mode underscore character in a file name, write it like this: math\_example.tex.

 Open this corrected version on Overleaf

Using underscores in URLs

You may also encounter this error when trying to typeset URLs with underscores, e.g. https://www.overleaf.com/learn/latex/Subscripts_and_superscripts. Instead of escaping each underscore character, you may want to load the url or hyperref package, and then use the \url command like this:

\documentclass{article}
\usepackage{url} 
\begin{document}
\url{https://www.overleaf.com/learn/latex/Subscripts_and_superscripts}
\end{document}

 Open this example in Overleaf

Underscores in .bib file URLs

If such URLs are in your bibliography .bib file, causing errors to be reported from the .bbl file, then make sure you use the url or doi fields to record these fields in the .bib file:

doi = {10.1007/978-94-015-6859-3_4},
url = {https://abc.com/latest_news_1.html}

and load the url or hyperref package in your preamble, if necessary. Most bibliography style files will then be able to automatically wrap these values in a \url{...} command.

Using commands not permitted in math mode

A number of low-level built-in TeX commands (called primitives) are not permitted in math mode and their use in math mode will trigger the Missing $ inserted error. Although most users are unlikely to use these commands in day-to-day LaTeX code, we make a note here because it’s possible they could be contained within LaTeX commands (macros) being used in math mode.

The following example tries to use the TeX command \vskip inside mathematical material. This is not permitted and generates an error.

\documentclass{article}
\begin{document}
I want to add some space, but this is not the way to do it...
\[y=f(x) \vskip5pt z=f(y)\]
$y=f(x) \vskip5pt z=f(y)$
\end{document}

 Open this error-generating code on Overleaf

Other TeX (primitive) commands not permitted when TeX is in math mode include \par, \hrule, \unvbox, \unvcopy and \valign.

Blank lines in mathematics

\documentclass{article}
\begin{document}
\begin{equation}
y=x^3,

z=x^3
\end{equation}
\end{document}

 Open this error-generating code on Overleaf

Cause: The blank line between the formulae is converted to a \par command which is not allowed in math mode. You can also see this by writing

\documentclass{article}
\begin{document}
\[y=x^3,\par z=x^3\]
\end{document}

 Open this error-generating code on Overleaf

To fix this, either delete the blank lines or comment them out:

\documentclass{article}
\begin{document}
\begin{equation}
y=x^3,
% This will suppress the blank line
z=x^3
\end{equation}
\end{document}

 Open this corrected version on Overleaf

Using $ inside math environments

Some LaTeX environments, such as the align and equation environments, do not require math to be wrapped in $ signs, or use of LaTeX’s math syntax: \(...\) or \[...\]. The LaTeX code which implements those environments takes care of entering and exiting math mode.

The following example shows use of the $ sign inside an amsmath align environment, which triggers a Missing $ inserted error, among many others….

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align*}
$2x - 5y &=  8 \\ 
3x + 9y &=  -12$
\end{align*}
\end{document}

 Open this error-generating code on Overleaf

The correct way to write these equations is:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align*}
2x - 5y &=  8 \\ 
3x + 9y &=  -12
\end{align*}
\end{document}

 Open this corrected version on Overleaf

Background to the Missing $ inserted error

The following section is for readers wishing to better understand the reasons behind the error Missing $ inserted. It’s not essential reading but it may assist you with finding and fixing errors.

There are no missing $ signs but I still get the error

In some circumstances the Missing $ inserted error can be very confusing because your LaTeX code might not actually have any problems with visibly missing $ characters. For example, the LaTeX fragment \(\verb|$$y=f(x)\par$$|\) superficially looks correct: the \(\verb|$$|\) pairs are balanced but it will trigger the “missing $” error. Here, it is due to the \par command which is not allowed in math mode:

\documentclass{article}
\begin{document}
This example generates the error \verb|Missing $ inserted|: 
$$y=f(x)\par$$
\end{document}

 Open this to see a Missing $ inserted error

The above LaTeX code actually triggers a cascade of errors, as shown below, so clearly you should not use \par inside math!

! Missing $ inserted.
<inserted text> 
                $
l.12 $$y=f(x)\par
                 $$
I’ve inserted a begin-math/end-math symbol since I think
you left one out. Proceed, with fingers crossed.

! Display math should end with $$.
<to be read again> 
                   \par 
l.12 $$y=f(x)\par
                 $$
The `$' that I just saw supposedly matches a previous `$$'.
So I shall assume that you typed `$$' both times.

! Missing $ inserted.
<inserted text> 
                $
l.13 \end{document}
                   
I've inserted a begin-math/end-math symbol since I think
you left one out. Proceed, with fingers crossed.

! Display math should end with $$.
<to be read again> 
                   \par 
l.13 \end{document}
                   
The `$' that I just saw supposedly matches a previous `$$'.
So I shall assume that you typed `$$' both times.

When the Missing $ inserted error occurs the TeX engine software is trying to recover and “get back on track” so it can continue processing after the point where the error occurred. The section Advanced: An explanation of TeX’s error recovery mechanism will help you understand why this cascade of errors arises due to TeX’s attempts at trying to fix the initial error.

Of modes, and when

Internally, TeX engines are designed operate using three “states of mind”, called modes, which depend on the type of material a TeX engine is currently typesetting. The mode a TeX engine is in at any point during typesetting is called its current mode, which changes throughout the process of typesetting the content of your LaTeX document.

For each of a TeX engine’s modes there are certain commands and characters (or, more correctly, category codes) which are “incompatible” with TeX’s current mode: they shouldn’t be used whilst TeX is in that specific mode. If you try to use those inappropriate characters or commands TeX will issue an error such as Missing $ inserted to tell you something is wrong.

Math mode

This error Missing $ inserted is related to TeX’s math mode—i.e., the mode a TeX engine is in when you ask LaTeX to typeset some maths.

Just for completeness we’ll note there are two types of math mode, reflecting the creation of inline or display math:

  • inline math mode
  • display math mode

TeX needs these two different math modes because it applies different rules for spacing, symbols sizes etc when typesetting math destined for inline or display.

Triggering TeX math modes

There are multiple ways to trigger a TeX engine to enter and then leave math mode.

  • You can use explicit markup such as:
    • LaTeX syntax: \(...\) to enter \( then leave \) inline math mode or \[...\] to enter \[ then leave \] display math mode;
    • (historic) TeX syntax: $...$ to enter (first $) then leave (second $) inline math mode or $$...$$ to enter (first $$ pair) then leave (second $$ pair) display math mode;
  • or any one of the LaTeX math environments:
    • \begin{align}...\end{align} etc. Behind the scenes these environment take care of entering and leaving math mode.

The actual text of the message Missing $ inserted is built into (“hardcoded” in) TeX engine software, which is why you will still see Missing $ even if you are not using $ characters to typeset mathematics and use purely LaTeX syntax to markup the math in your document. This can be confusing to new users of LaTeX but there’s little that can be done to change this error message text without modifying the source code of TeX engines!

Macros: testing for math mode

It’s possible to test if TeX is currently in math mode using the primitive command \ifmmode; that way you can write macros whose behavior can adapt to avoid generating mode-related errors. Here is a very basic example to demonstrate the principle, which prints Yes. or No. depending whether or not TeX is in math mode at the point of “executing” the macro.

\documentclass{article}
\begin{document}
\newcommand{\mytest}{\ifmmode \mathrm{Yes}\else No\fi.}

Is the macro being used in math mode? $\mytest$

Is the macro being used in math mode? $$\mytest$$

Is the macro being used in math mode? \(\mytest\) 

Is the macro being used in math mode? \[\mytest\]

Is the macro being used in math mode? \mytest
\end{document}

 Open this example in Overleaf

The following graphic shows the output produced by the example above:

LaTeX macro to test math mode

Advanced: An explanation of TeX’s error recovery mechanism

The error message Missing $ inserted is not output by Overleaf, LaTeX, or LaTeX packages; it actually originates from within the executable program responsible for typesetting your LaTeX document: that executable program is called a TeX engine—you can think of it as “driving” the typesetting process.

Within the source code of the TeX software, its author (Donald Knuth), makes this observation about the code responsible for generating the Missing $ inserted error:

Here is a list of cases where the user has probably gotten into or out of math
mode by mistake. TeX will insert a dollar sign and rescan the current token.

At the heart of the Missing $ inserted error is TeX detecting “something” that should not have been used inside math mode, or “something” expressly designed for math typesetting being used outside math mode.

The task facing TeX is: How do I recover from this? TeX does exactly what Knuth writes: it inserts a dollar sign and rescans the current token—a “token” is TeX’s internal numeric (integer) value which represents the character or command it has just read in. However, due to the precise context of the error, this strategy may, or may not, be successful—as the error text goes on to say “Proceed, with fingers crossed.”!

Worked example

Let’s explore Knuth’s comments by taking a closer look at the following example: \(\verb|$y=f(x)$$\vskip3pt|\). If you open the code below you’ll see it triggers the error Missing $ inserted.

Writing \verb|$y=f(x)$$\vskip3pt| produces...$y=f(x)$$\vskip3pt Start new line...

 Open this example in Overleaf

To review why this triggers an error let’s write subscripts to identify each \(\verb|$|\) in the expression to obtain \(\verb|$|_{\mathtt1}\verb|y=f(x)|\verb|$|_{\mathtt2}\verb|$|_{\mathtt3}\verb|\vskip3pt|\).
TeX is able to correctly process the first part \(\verb|$|_{\mathtt1}\verb|y=f(x)|\verb|$|_{\mathtt2}\) which is treated as a correctly formatted piece of inline math, producing \(y=f(x)\). Immediately after processing \(\verb|$|_{\mathtt2}\) TeX temporarily exits inline math mode—in our example we are creating inline math in a paragraph so it briefly enters so-called horizontal mode.

It’s what happens next that triggers the error. TeX continues to process the \(\verb|$|_{\mathtt3}\) which triggers TeX to re-enter inline math mode. TeX now reads the next token which is the \(\verb|\vskip|\) command—it has not yet read the \(\verb|3pt|\). At this point, TeX sees \(\verb|\vskip|\) but it’s in inline math mode: \(\verb|\vskip|\) is not allowed there so it triggers TeX’s error-handling process as described by Knuth:

TeX will insert a dollar sign and rescan the current token.

Here, the current token is the \(\verb|\vskip|\) command so what TeX does is place a new $ into its input, let’s call it \(\verb|$|_{\mathtt4}\). At this point, TeX is still in inline math mode but now it goes back to read the equivalent of \(\verb|$|_{\mathtt4}\verb|\vskip|\) which is read in inline math mode. The \(\verb|$|_{\mathtt4}\), inserted by TeX itself, now closes the current inline math mode and TeX goes on to read the \(\verb|\vskip|\) command outside inline math mode—here, TeX is in a paragraph so the \(\verb|\vskip3pt|\) causes the current paragraph to be ended and \(\verb|3pt|\) of space placed after it.

I try to write the following in latex:

\begin{itemize}
    \item \textbf{insert(element|text)} inserts the element or text passed at the start of the selection.
    \item \textbf{insert_after(element|text)} inserts the element or text passed at the end of the selection.
    \item \textbf{replace(element|text)} replaces the selection with the passed text/element.
    \item \textbf{delete()} deletes the selected text.
    \item \textbf{annotate(name,value)} annotates the selected text with the passed name and value-pair. This can either be a hidden meta-data about the selection, or can alter the visible appearance.
    \item \textbf{clear_annotation()} removes any annotation for this specific selection.
    \item \textbf{update_element(value)} performs an update of the element at the selection with the passed value.
\end{itemize}

For some reason, I get a bunch of errors. I think there is something with the use of the word «insert». I get errors like «Missing $ inserted», so it seems like the parses tries to fix some «errors» on my parts. Do I need to escape words like «insert», how do I do that?

asked Mar 19, 2010 at 11:34

Espen Herseth Halvorsen's user avatar

The «Missing $ inserted» is probably caused by the underscores and bars. These characters in LaTeX have special meaning in math mode (which is delimited by $ characters). Try escaping them; e.g. update\_element instead of update_element.

However, if you’re trying to display code, a better solution would be to use the \verb command, which will typeset the text in a monospaced font and will automatically handle underscores and bars correctly (no need to escape them with \).

answered Mar 19, 2010 at 11:41

Will Vousden's user avatar

Will VousdenWill Vousden

32.5k9 gold badges84 silver badges95 bronze badges

1

It’s actually the underscores. Use \_ instead, or include the underscore package.

answered Mar 19, 2010 at 11:42

Nietzche-jou's user avatar

Nietzche-jouNietzche-jou

14.4k4 gold badges34 silver badges45 bronze badges

2

I had this problem too. I solved it by removing the unnecessary blank line between equation tags. This gives the error:

\begin{equation}
P(\underline{\hat{X}} | \underline{Y}) = ...

\end{equation}

while this code compiles succesfully:

\begin{equation}
P(\underline{\hat{X}} | \underline{Y}) = ...
\end{equation}

answered Dec 21, 2012 at 9:03

Utku Özdemir's user avatar

Utku ÖzdemirUtku Özdemir

7,4102 gold badges52 silver badges49 bronze badges

1

also, I had this problem but the bib file wouldn’t recompile. I removed the problem, which was an underscore in the note field, and compiled the tex file again, but kept getting the same errors. In the end I del’d the compiled bib file (.bbl I think) and it worked fine. I had to escape the _ using a backslash.

answered Jul 21, 2011 at 16:38

Adrian's user avatar

AdrianAdrian

811 silver badge1 bronze badge

1

I had the same problem — and I have read all these answers, but unfortunately none of them worked for me. Eventually I tried removing this line

%\usepackage[latin1]{inputenc}

and all errors disappeared.

gariepy's user avatar

gariepy

3,5766 gold badges21 silver badges34 bronze badges

answered May 11, 2016 at 22:16

Matrix Software's user avatar

1

My first guess is that LaTeX chokes on | outside a math environment. Missing $ inserted is usually a symptom of something like that.

answered Mar 19, 2010 at 11:41

High Performance Mark's user avatar

1

You can also get this error if you use special character greek letters like \alpha \beta and so on outside of math mode.
After i wrapped them in \(…\) the error was gone.

answered Jan 21, 2018 at 22:43

Alphacoder's user avatar

AlphacoderAlphacoder

2992 silver badges10 bronze badges

3

I think it gives the error because of the underscore symbol.

Note : underscore symbol should not be written directly, you have to write like as \_.

So fix these kind special symbol errors.

Mark Rotteveel's user avatar

answered Dec 22, 2017 at 11:16

Achilles Ram Nakirekanti's user avatar

In my code, when I got the error, I checked the possible source, In a line, I had typed a beginning \[ and an ending \] due to which the error of missing $ appeared though I tried using $ for both the brackets. Removing the brackets or using $[$ instead of $\[$ solved my problem. If you’ve something like that, try altering.

answered Jun 7, 2018 at 12:28

Bhanu Chander's user avatar

Bhanu ChanderBhanu Chander

3901 gold badge6 silver badges16 bronze badges

I had this symbol _ in the head of one table and the code didn’t run, so I had to delete.

answered Feb 20, 2018 at 22:31

Edwin Torres's user avatar

My case was similar to Adrian’s. It was an incorrectly written online bib source.

I had

 @online{some_pretty_website, 
    title={Pretty Website}, 
    url={https://www.prettywebsite.com/foo_bar.pdf}
 } 

I had to escape the «_» symbol in the url

 @online{some_pretty_website, 
    title={Pretty Website}, 
    url={https://www.prettywebsite.com/foo\_bar.pdf}
 } 

answered Dec 3, 2022 at 17:29

pink_demon's user avatar

I had this problem too, and it wasn’t anywhere near the line number given in the logs.

Building on Leah’s answer, if you press Q, then look in the logs, you’ll see the message:

I've inserted something that you may have forgotten.
(See the <inserted text> above.)
With luck, this will get me unwedged. But if you
really didn't forget anything, try typing `2' now; then
my insertion and my current dilemma will both disappear.

So on the next run, try pressing 2 at the error prompt, which tells latex to ignore the problem, and continue, instead of trying to fix it. In doing so, it’ll print out the last bit of text it read (near the problem), and that should give you a clue where the problem is (you might need to do this a couple of times).

Turns out my problem was on line 366 of my .bib file, and no-where near line 20 as reported. It was caused by a ~ in a url that hadn’t been converted by the zotero exporter. Deleting that line removed the error.

Solution 1

The immediate reason for the error is the fact that you’ve inserted \\ in the numerator term of the \frac directive. I have removed it and it is works correctly.

enter image description here

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\begin{document}
\begin{multline}
\Delta T_s = \frac{T_s \times (\alpha \ln \frac{C}{C_0} + (\beta(\sqrt{M} - \sqrt{M_0})
- (f(M, N_0) - f(M_0, N_0))) + (\gamma (\sqrt{N} - \sqrt{N_0}) - (f(M_0, N) - f(M_0, N_0)))}{4F_{TOA}}
\end{multline}
\end{document}

To create a line break in the numerator, you can use \splitfrac, a macro provided by the mathtools package.

enter image description here

\documentclass{article}
\usepackage{mathtools}

\begin{document}
\begin{equation}
\Delta T_s =\frac{\splitfrac{T_s \times [\alpha \ln \frac{C}{C_0} + (\beta(\sqrt{M} - \sqrt{M_0}\,)
- (f(M, N_0) - f(M_0, N_0))] }{+\gamma (\sqrt{N} - \sqrt{N_0}\,) - (f(M_0, N) - f(M_0, N_0))}}{4F_{\mathit{TOA}}}
\end{equation}
\end{document}

Solution 2

I think you should use the \splitfrac from mathtools to make this long fraction fit textwidth. I also used different sizes for parentheses tm make the fraction more readable:

\documentclass[a4paper,12pt]{article}
\usepackage{mathtools}

\begin{document}

    \[ \Delta T_s = \frac{\splitfrac{T_s \times\Bigl(\alpha \ln \frac{C}{C_0} + \beta\bigl(\sqrt{M} - \sqrt{M_0}\bigr)
- \bigl(f(M, N_0) - f(M_0, N_0)\bigr)\Bigr)}{+ \Bigl(\gamma \bigl(\sqrt{N} - \sqrt{N_0}\bigr) - \bigl(f(M_0, N) - f(M_0, N_0)\bigr)\Bigr)}}{4F_{TOA}} \]%

\end{document} 

enter image description here

Solution 3

I know this is an old question, and I do not want to necro-bump it. However, I feel like the given answers somewhat misses the point. Yes, if you have to keep everything in a single equation, multiline is the way to go. But do you really have to? I can only think of a few circumstances.

  • I am submitting to a journal and I am really tight on space
  • I am working on a two or three?! column document and are tight on space.

In any other circumstance I would recommend rewriting the surrounding text, which will make it more bearable for the reader to digest as well. One suggestion could look like

enter image description here

Where X and Y needs to be given better names depending on the contect. It looks like you are running some two dimensional iteration scheme, but without context it is hard to suggest better names.

While a minor detail look how nicely everything is aligned in the top two equations despite M and N having different widths..


\documentclass[10pt,a4paper]{article}
\usepackage{mathtools}

\begin{document}
\noindent
Now let 
%
\bgroup
\newcommand{\NM}{\mathrlap{N}{\phantom{M}}}
\newcommand{\NMsqrt}{\mathrlap{\sqrt{N_0}}{\phantom{\sqrt{M_0}}}}
\begin{align*}
    X &= \beta\mspace{2mu}(\sqrt{M} - \sqrt{M_0}) - \bigl[f(M, N_0) - f(M_0, N_0)\bigr]\\
    Y &= \gamma\mspace{2mu}(\sqrt{\NM} - \NMsqrt) - \bigl[f(M_0, N) - f(M_0, N_0)\bigr]
\end{align*}
\egroup
%
then the change in $T_s$ is equal to
%
\begin{equation*}
\frac{\Delta T_s}{T_s}
  = \frac{\alpha \ln(C/C_0) + X + Y}{4F_{TOA}}
\end{equation*}
%
where $T_s$ represents ...
\end{document}

Related videos on Youtube

LaTeX Tutorial 13 Two Common LaTeX errors

03 : 28

LaTeX Tutorial 13 Two Common LaTeX errors

Common Errors in LaTeX (Latex Basic Tutorial-34)

07 : 53

Common Errors in LaTeX (Latex Basic Tutorial-34)

How to Manually Install Missing Packages in Latex [SOLVED] | Latex Missing Package Miktex Win 7,8,10

03 : 22

How to Manually Install Missing Packages in Latex [SOLVED] | Latex Missing Package Miktex Win 7,8,10

Installing Missing Packages in MikTeX distribution on Windows (LaTeX Advanced Tutorial-02)

05 : 22

Installing Missing Packages in MikTeX distribution on Windows (LaTeX Advanced Tutorial-02)

Latex Complete Installation with Missing Packages (English)

11 : 51

Latex Complete Installation with Missing Packages (English)

Comments

  • I have written this :

    \begin{multline}
    \Delta T_s = \frac{T_s \times (\alpha \ln \frac{C}{C_0} + (\beta(\sqrt{M} - \sqrt{M_0})\\
    - (f(M, N_0) - f(M_0, N_0))) + (\gamma (\sqrt{N} - \sqrt{N_0}) - (f(M_0, N) - f(M_0, N_0)))}{4F_{TOA}}
    \end{multline}
    

    but latex gives me the error «Missing } inserted», i tried some stuff but everytime latex gives me this.
    Can you help me please ?

    • Welcome to TeX.SE! Can you please make your code snippet be compilable? Then we do not have to guess what you are doing …

  • +1 for the use of \splitfrac.

  • To elaborate, TeX saw \\ inside a group started by { instead of the expected closing }. Hence the error message: Missing } inserted.

  • @MatthewLeingang Thank you for your advice. If you want you can edit my answer and explain better the reason. My best regards.

Recents

Понравилась статья? Поделить с друзьями:
  • Mitsubishi heavy ошибка e36
  • Mitsubishi a700 ошибки
  • Missing equal sign ошибка
  • Missing associated label input ошибка
  • Mitsubishi a500 ошибки