I'm trying to include URLs in my .tex or .bib, but I got an error "Missing $ inserted"
Your URL might be containing some underscore characters _
, which are special characters in LaTeX — they're the subscript operator when in math mode, e.g. $x_i$
will produce \($x_i$\). Usually, if you want to use a literal underscore character in normal text, you'll have to write escape it as \_
.
Fortunately there's an easier way to include URLs with underscores. If you add \usepackage{url}
or \usepackage{hyperref}
just before your \begin{document}
, you can then write:
\url{https://www.example.com/url_with_underscore}
in your document.
For further details, refer to the Overleaf help article Missing $ inserted.